diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml index 175bc0a9bdd..4f41156d45c 100644 --- a/.github/workflows/submit.yml +++ b/.github/workflows/submit.yml @@ -13,6 +13,7 @@ on: description: "Platform(s) to execute on" required: true default: "Linux x64, Windows x64, macOS x64" +# default: "Linux additional (hotspot only), Linux x64, Linux x86, Windows aarch64, Windows x64, macOS x64" jobs: prerequisites: @@ -21,7 +22,10 @@ jobs: outputs: should_run: ${{ steps.check_submit.outputs.should_run }} bundle_id: ${{ steps.check_bundle_id.outputs.bundle_id }} + platform_linux_additional: ${{ steps.check_platforms.outputs.platform_linux_additional }} platform_linux_x64: ${{ steps.check_platforms.outputs.platform_linux_x64 }} + platform_linux_x86: ${{ steps.check_platforms.outputs.platform_linux_x86 }} + platform_windows_aarch64: ${{ steps.check_platforms.outputs.platform_windows_aarch64 }} platform_windows_x64: ${{ steps.check_platforms.outputs.platform_windows_x64 }} platform_macos_x64: ${{ steps.check_platforms.outputs.platform_macos_x64 }} dependencies: ${{ steps.check_deps.outputs.dependencies }} @@ -34,7 +38,10 @@ jobs: - name: Check which platforms should be included id: check_platforms run: | + echo "::set-output name=platform_linux_additional::${{ contains(github.event.inputs.platforms, 'linux additional (hotspot only)') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux additional (hotspot only)'))) }}" echo "::set-output name=platform_linux_x64::${{ contains(github.event.inputs.platforms, 'linux x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux x64'))) }}" + echo "::set-output name=platform_linux_x86::${{ contains(github.event.inputs.platforms, 'linux x86') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'linux x86'))) }}" + echo "::set-output name=platform_windows_aarch64::${{ contains(github.event.inputs.platforms, 'windows aarch64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'windows aarch64'))) }}" echo "::set-output name=platform_windows_x64::${{ contains(github.event.inputs.platforms, 'windows x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'windows x64'))) }}" echo "::set-output name=platform_macos_x64::${{ contains(github.event.inputs.platforms, 'macos x64') || (github.event.inputs.platforms == '' && (secrets.JDK_SUBMIT_PLATFORMS == '' || contains(secrets.JDK_SUBMIT_PLATFORMS, 'macos x64'))) }}" if: steps.check_submit.outputs.should_run != 'false' @@ -52,7 +59,7 @@ jobs: - name: Determine versions and locations to be used for dependencies id: check_deps - run: "echo ::set-output name=dependencies::`cat make/autoconf/version-numbers make/conf/test-dependencies | sed -e '1i {' -e 's/#.*//g' -e 's/\"//g' -e 's/\\(.*\\)=\\(.*\\)/\"\\1\": \"\\2\",/g' -e '$s/,\\s\\{0,\\}$/\\}/'`" + run: "echo ::set-output name=dependencies::`cat make/conf/version-numbers.conf make/conf/test-dependencies | sed -e '1i {' -e 's/#.*//g' -e 's/\"//g' -e 's/\\(.*\\)=\\(.*\\)/\"\\1\": \"\\2\",/g' -e '$s/,\\s\\{0,\\}$/\\}/'`" working-directory: jdk if: steps.check_submit.outputs.should_run != 'false' @@ -101,7 +108,7 @@ jobs: name: Linux x64 runs-on: "ubuntu-20.04" needs: prerequisites - if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_linux_x64 != 'false' + if: needs.prerequisites.outputs.should_run != 'false' && (needs.prerequisites.outputs.platform_linux_x64 != 'false' || needs.prerequisites.outputs.platform_linux_additional == 'true') strategy: fail-fast: false @@ -377,6 +384,564 @@ jobs: path: ~/linux-x64${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip continue-on-error: true + linux_additional_build: + name: Linux additional + runs-on: "ubuntu-20.04" + needs: + - prerequisites + - linux_x64_build + if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_linux_additional != 'false' + + strategy: + fail-fast: false + matrix: + flavor: + - hs x64 build only + - hs x64 zero build only + - hs x64 minimal build only + - hs x64 optimized build only + - hs aarch64 build only + - hs arm build only + - hs s390x build only + - hs ppc64le build only + include: + - flavor: hs x64 build only + flags: --enable-debug --disable-precompiled-headers + - flavor: hs x64 zero build only + flags: --enable-debug --disable-precompiled-headers --with-jvm-variants=zero + - flavor: hs x64 minimal build only + flags: --enable-debug --disable-precompiled-headers --with-jvm-variants=minimal + - flavor: hs x64 optimized build only + flags: --with-debug-level=optimized --disable-precompiled-headers + - flavor: hs aarch64 build only + flags: --enable-debug --disable-precompiled-headers + debian-arch: arm64 + gnu-arch: aarch64 + - flavor: hs arm build only + flags: --enable-debug --disable-precompiled-headers + debian-arch: armhf + gnu-arch: arm + gnu-flavor: eabihf + - flavor: hs s390x build only + flags: --enable-debug --disable-precompiled-headers + debian-arch: s390x + gnu-arch: s390x + - flavor: hs ppc64le build only + flags: --enable-debug --disable-precompiled-headers + debian-arch: ppc64el + gnu-arch: powerpc64le + + env: + JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).DEFAULT_VERSION_FEATURE }}" + BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" + BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" + BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" + BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" + + steps: + - name: Checkout the source + uses: actions/checkout@v2 + with: + path: jdk + + - name: Restore boot JDK from cache + id: bootjdk + uses: actions/cache@v2 + with: + path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} + key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 + + - name: Download boot JDK + run: | + mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" + echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - + tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" + if: steps.bootjdk.outputs.cache-hit != 'true' + + - name: Restore build JDK + id: build_restore + uses: actions/download-artifact@v2 + with: + name: transient_jdk-linux-x64_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jdk-linux-x64 + continue-on-error: true + + - name: Restore build JDK (retry) + uses: actions/download-artifact@v2 + with: + name: transient_jdk-linux-x64_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jdk-linux-x64 + if: steps.build_restore.outcome == 'failure' + + - name: Unpack build JDK + run: | + mkdir -p "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin" + tar -xf "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin.tar.gz" -C "${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin" + + - name: Find root of build JDK image dir + run: | + build_jdk_root=`find ${HOME}/jdk-linux-x64/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x64_bin -name release -type f` + echo "build_jdk_root=`dirname ${build_jdk_root}`" >> $GITHUB_ENV + + - name: Update apt + run: sudo apt-get update + + - name: Install native host dependencies + run: | + sudo apt-get install gcc-10=10.2.0-5ubuntu1~20.04 g++-10=10.2.0-5ubuntu1~20.04 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 + if: matrix.debian-arch == '' + + - name: Install cross-compilation host dependencies + run: sudo apt-get install gcc-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.2.0-5ubuntu1~20.04cross1 g++-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.2.0-5ubuntu1~20.04cross1 + if: matrix.debian-arch != '' + + - name: Cache sysroot + id: cache-sysroot + uses: actions/cache@v2 + with: + path: ~/sysroot-${{ matrix.debian-arch }}/ + key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('jdk/.github/workflows/submit.yml') }} + if: matrix.debian-arch != '' + + - name: Install sysroot host dependencies + run: sudo apt-get install debootstrap qemu-user-static + if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' + + - name: Create sysroot + run: > + sudo qemu-debootstrap + --arch=${{ matrix.debian-arch }} + --verbose + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev + --resolve-deps + buster + ~/sysroot-${{ matrix.debian-arch }} + http://httpredir.debian.org/debian/ + if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' + + - name: Prepare sysroot for caching + run: | + sudo chroot ~/sysroot-${{ matrix.debian-arch }} symlinks -cr . + sudo chown ${USER} -R ~/sysroot-${{ matrix.debian-arch }} + rm -rf ~/sysroot-${{ matrix.debian-arch }}/{dev,proc,run,sys} + if: matrix.debian-arch != '' && steps.cache-sysroot.outputs.cache-hit != 'true' + + - name: Configure cross compiler + run: | + echo "CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}-gcc-10" >> $GITHUB_ENV + echo "CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}-g++-10" >> $GITHUB_ENV + if: matrix.debian-arch != '' + + - name: Configure cross specific flags + run: > + echo "cross_flags= + --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}} + --with-sysroot=${HOME}/sysroot-${{ matrix.debian-arch }}/ + --with-toolchain-path=${HOME}/sysroot-${{ matrix.debian-arch }}/ + --with-freetype-lib=${HOME}/sysroot-${{ matrix.debian-arch }}/usr/lib/${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}/ + --with-freetype-include=${HOME}/sysroot-${{ matrix.debian-arch }}/usr/include/freetype2/ + --x-libraries=${HOME}/sysroot-${{ matrix.debian-arch }}/usr/lib/${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}/ + " >> $GITHUB_ENV + if: matrix.debian-arch != '' + + - name: Configure + run: > + bash configure + --with-conf-name=linux-${{ matrix.gnu-arch }}-hotspot + ${{ matrix.flags }} + ${{ env.cross_flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-version-build=0 + --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION} + --with-build-jdk=${{ env.build_jdk_root }} + --with-default-make-target="hotspot" + --with-zlib=system + working-directory: jdk + + - name: Build + run: make CONF_NAME=linux-${{ matrix.gnu-arch }}-hotspot + working-directory: jdk + + linux_x86_build: + name: Linux x86 + runs-on: "ubuntu-20.04" + needs: prerequisites + if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_linux_x86 != 'false' + + strategy: + fail-fast: false + matrix: + flavor: + - build release + - build debug + include: + - flavor: build debug + flags: --enable-debug + artifact: -debug + + # Reduced 32-bit build uses the same boot JDK as 64-bit build + env: + JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).DEFAULT_VERSION_FEATURE }}" + BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" + BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" + BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" + BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" + + steps: + - name: Checkout the source + uses: actions/checkout@v2 + with: + path: jdk + + - name: Restore boot JDK from cache + id: bootjdk + uses: actions/cache@v2 + with: + path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} + key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 + + - name: Download boot JDK + run: | + mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" + echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - + tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" + if: steps.bootjdk.outputs.cache-hit != 'true' + + - name: Restore jtreg artifact + id: jtreg_restore + uses: actions/download-artifact@v2 + with: + name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jtreg/ + continue-on-error: true + + - name: Restore jtreg artifact (retry) + uses: actions/download-artifact@v2 + with: + name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jtreg/ + if: steps.jtreg_restore.outcome == 'failure' + + - name: Checkout gtest sources + uses: actions/checkout@v2 + with: + repository: "google/googletest" + ref: "release-${{ fromJson(needs.prerequisites.outputs.dependencies).GTEST_VERSION }}" + path: gtest + + # Roll in the multilib environment and its dependencies. + # Some multilib libraries do not have proper inter-dependencies, so we have to + # install their dependencies manually. Additionally, upgrading apt solves + # the libc6 installation bugs until base image catches up, see JDK-8260460. + - name: Install dependencies + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install --only-upgrade apt + sudo apt-get install gcc-10-multilib g++-10-multilib libfreetype6-dev:i386 libxrandr-dev:i386 libxtst-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386 libcups2-dev:i386 libasound2-dev:i386 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 + + - name: Configure + run: > + bash configure + --with-conf-name=linux-x86 + --with-target-bits=32 + ${{ matrix.flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-version-build=0 + --with-boot-jdk=${HOME}/bootjdk/${BOOT_JDK_VERSION} + --with-jtreg=${HOME}/jtreg + --with-gtest=${GITHUB_WORKSPACE}/gtest + --with-default-make-target="product-bundles test-bundles" + --with-zlib=system + --enable-jtreg-failure-handler + working-directory: jdk + + - name: Build + run: make CONF_NAME=linux-x86 + working-directory: jdk + + - name: Persist test bundles + uses: actions/upload-artifact@v2 + with: + name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} + path: | + jdk/build/linux-x86/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}.tar.gz + jdk/build/linux-x86/bundles/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}.tar.gz + + linux_x86_test: + name: Linux x86 + runs-on: "ubuntu-20.04" + needs: + - prerequisites + - linux_x86_build + + strategy: + fail-fast: false + matrix: + test: + - jdk/tier1 part 1 + - jdk/tier1 part 2 + - jdk/tier1 part 3 + - langtools/tier1 + - hs/tier1 common + - hs/tier1 compiler + - hs/tier1 gc + - hs/tier1 runtime + - hs/tier1 serviceability + include: + - test: jdk/tier1 part 1 + suites: test/jdk/:tier1_part1 + - test: jdk/tier1 part 2 + suites: test/jdk/:tier1_part2 + - test: jdk/tier1 part 3 + suites: test/jdk/:tier1_part3 + - test: langtools/tier1 + suites: test/langtools/:tier1 + - test: hs/tier1 common + suites: test/hotspot/jtreg/:tier1_common + artifact: -debug + - test: hs/tier1 compiler + suites: test/hotspot/jtreg/:tier1_compiler + artifact: -debug + - test: hs/tier1 gc + suites: test/hotspot/jtreg/:tier1_gc + artifact: -debug + - test: hs/tier1 runtime + suites: test/hotspot/jtreg/:tier1_runtime + artifact: -debug + - test: hs/tier1 serviceability + suites: test/hotspot/jtreg/:tier1_serviceability + artifact: -debug + + # Reduced 32-bit build uses the same boot JDK as 64-bit build + env: + JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).DEFAULT_VERSION_FEATURE }}" + BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" + BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_FILENAME }}" + BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_URL }}" + BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).LINUX_X64_BOOT_JDK_SHA256 }}" + + steps: + - name: Checkout the source + uses: actions/checkout@v2 + + - name: Restore boot JDK from cache + id: bootjdk + uses: actions/cache@v2 + with: + path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} + key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 + + - name: Download boot JDK + run: | + mkdir -p "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + wget -O "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" "${BOOT_JDK_URL}" + echo "${BOOT_JDK_SHA256} ${HOME}/bootjdk/${BOOT_JDK_FILENAME}" | sha256sum -c >/dev/null - + tar -xf "${HOME}/bootjdk/${BOOT_JDK_FILENAME}" -C "${HOME}/bootjdk/${BOOT_JDK_VERSION}" + mv "${HOME}/bootjdk/${BOOT_JDK_VERSION}/"*/* "${HOME}/bootjdk/${BOOT_JDK_VERSION}/" + if: steps.bootjdk.outputs.cache-hit != 'true' + + - name: Restore jtreg artifact + id: jtreg_restore + uses: actions/download-artifact@v2 + with: + name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jtreg/ + continue-on-error: true + + - name: Restore jtreg artifact (retry) + uses: actions/download-artifact@v2 + with: + name: transient_jtreg_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jtreg/ + if: steps.jtreg_restore.outcome == 'failure' + + - name: Restore build artifacts + id: build_restore + uses: actions/download-artifact@v2 + with: + name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jdk-linux-x86${{ matrix.artifact }} + continue-on-error: true + + - name: Restore build artifacts (retry) + uses: actions/download-artifact@v2 + with: + name: transient_jdk-linux-x86${{ matrix.artifact }}_${{ needs.prerequisites.outputs.bundle_id }} + path: ~/jdk-linux-x86${{ matrix.artifact }} + if: steps.build_restore.outcome == 'failure' + + - name: Unpack jdk + run: | + mkdir -p "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}" + tar -xf "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }}" + + - name: Unpack tests + run: | + mkdir -p "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}" + tar -xf "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}.tar.gz" -C "${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }}" + + - name: Find root of jdk image dir + run: | + imageroot=`find ${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin${{ matrix.artifact }} -name release -type f` + echo "imageroot=`dirname ${imageroot}`" >> $GITHUB_ENV + + - name: Run tests + run: > + JDK_IMAGE_DIR=${{ env.imageroot }} + TEST_IMAGE_DIR=${HOME}/jdk-linux-x86${{ matrix.artifact }}/jdk-${{ env.JDK_VERSION }}-internal+0_linux-x86_bin-tests${{ matrix.artifact }} + BOOT_JDK=${HOME}/bootjdk/${BOOT_JDK_VERSION} + JT_HOME=${HOME}/jtreg + make test-prebuilt + CONF_NAME=run-test-prebuilt + LOG_CMDLINES=true + JTREG_VERBOSE=fail,error,time + TEST="${{ matrix.suites }}" + TEST_OPTS_JAVA_OPTIONS= + JTREG_KEYWORDS="!headful" + JTREG="JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash" + + - name: Check that all tests executed successfully + if: always() + run: > + if ! grep --include=test-summary.txt -lqr build/*/test-results -e "TEST SUCCESS" ; then + cat build/*/test-results/*/text/newfailures.txt ; + exit 1 ; + fi + + - name: Create suitable test log artifact name + if: always() + run: echo "logsuffix=`echo ${{ matrix.test }} | sed -e 's!/!_!'g -e 's! !_!'g`" >> $GITHUB_ENV + + - name: Package test results + if: always() + working-directory: build/run-test-prebuilt/test-results/ + run: > + zip -r9 + "$HOME/linux-x86${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip" + . + continue-on-error: true + + - name: Package test support + if: always() + working-directory: build/run-test-prebuilt/test-support/ + run: > + zip -r9 + "$HOME/linux-x86${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip" + . + -i *.jtr + -i */hs_err*.log + -i */replay*.log + continue-on-error: true + + - name: Persist test results + if: always() + uses: actions/upload-artifact@v2 + with: + path: ~/linux-x86${{ matrix.artifact }}_testresults_${{ env.logsuffix }}.zip + continue-on-error: true + + - name: Persist test outputs + if: always() + uses: actions/upload-artifact@v2 + with: + path: ~/linux-x86${{ matrix.artifact }}_testsupport_${{ env.logsuffix }}.zip + continue-on-error: true + + windows_aarch64_build: + name: Windows aarch64 + runs-on: "windows-2019" + needs: prerequisites + if: needs.prerequisites.outputs.should_run != 'false' && needs.prerequisites.outputs.platform_windows_aarch64 != 'false' + + strategy: + fail-fast: false + matrix: + flavor: + - build debug + include: + - flavor: build debug + flags: --enable-debug + artifact: -debug + + env: + JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).DEFAULT_VERSION_FEATURE }}" + BOOT_JDK_VERSION: "${{ fromJson(needs.prerequisites.outputs.dependencies).BOOT_JDK_VERSION }}" + BOOT_JDK_FILENAME: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_FILENAME }}" + BOOT_JDK_URL: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_URL }}" + BOOT_JDK_SHA256: "${{ fromJson(needs.prerequisites.outputs.dependencies).WINDOWS_X64_BOOT_JDK_SHA256 }}" + + steps: + - name: Restore cygwin packages from cache + id: cygwin + uses: actions/cache@v2 + with: + path: ~/cygwin/packages + key: cygwin-packages-${{ runner.os }}-v1 + + - name: Install cygwin + run: | + New-Item -Force -ItemType directory -Path "$HOME\cygwin" + & curl -L "https://www.cygwin.com/setup-x86_64.exe" -o "$HOME/cygwin/setup-x86_64.exe" + Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow + + - name: Checkout the source + uses: actions/checkout@v2 + with: + path: jdk + + - name: Restore boot JDK from cache + id: bootjdk + uses: actions/cache@v2 + with: + path: ~/bootjdk/${{ env.BOOT_JDK_VERSION }} + key: bootjdk-${{ runner.os }}-${{ env.BOOT_JDK_VERSION }}-${{ env.BOOT_JDK_SHA256 }}-v1 + + - name: Download boot JDK + run: | + mkdir -p "$HOME\bootjdk\$env:BOOT_JDK_VERSION" + & curl -L "$env:BOOT_JDK_URL" -o "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" + $FileHash = Get-FileHash -Algorithm SHA256 "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" + $FileHash.Hash -eq $env:BOOT_JDK_SHA256 + & tar -xf "$HOME/bootjdk/$env:BOOT_JDK_FILENAME" -C "$HOME/bootjdk/$env:BOOT_JDK_VERSION" + Get-ChildItem "$HOME\bootjdk\$env:BOOT_JDK_VERSION\*\*" | Move-Item -Destination "$HOME\bootjdk\$env:BOOT_JDK_VERSION" + if: steps.bootjdk.outputs.cache-hit != 'true' + + - name: Ensure a specific version of MSVC is installed + run: > + Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe' -Wait -NoNewWindow -ArgumentList + 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet + --add Microsoft.VisualStudio.Component.VC.14.28.arm64' + + - name: Configure + run: > + $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; + $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; + $env:BOOT_JDK = cygpath "$HOME/bootjdk/$env:BOOT_JDK_VERSION" ; + & bash configure + --with-conf-name=windows-aarch64 + --with-msvc-toolset-version=14.28 + --openjdk-target=aarch64-unknown-cygwin + ${{ matrix.flags }} + --with-version-opt="$env:GITHUB_ACTOR-$env:GITHUB_SHA" + --with-version-build=0 + --with-boot-jdk="$env:BOOT_JDK" + --with-default-make-target="hotspot" + working-directory: jdk + + - name: Build + run: | + $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; + $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; + & make CONF_NAME=windows-aarch64 + working-directory: jdk + windows_x64_build: name: Windows x64 runs-on: "windows-2019" @@ -463,24 +1028,26 @@ jobs: run: > Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe' -Wait -NoNewWindow -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet - --add Microsoft.VisualStudio.Component.VC.14.27.x86.x64' + --add Microsoft.VisualStudio.Component.VC.14.28.x86.x64' - name: Configure run: > $env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ; $env:Path = $env:Path -split ";" -match "C:\\Windows|PowerShell|cygwin" -join ";" ; + $env:BOOT_JDK = cygpath "$HOME/bootjdk/$env:BOOT_JDK_VERSION" ; + $env:JT_HOME = cygpath "$HOME/jtreg" ; + $env:GTEST = cygpath "$env:GITHUB_WORKSPACE/gtest" ; & bash configure --with-conf-name=windows-x64 - --with-msvc-toolset-version=14.27 + --with-msvc-toolset-version=14.28 ${{ matrix.flags }} --with-version-opt="$env:GITHUB_ACTOR-$env:GITHUB_SHA" --with-version-build=0 - --with-boot-jdk="$HOME/bootjdk/$env:BOOT_JDK_VERSION" - --with-jtreg="$HOME/jtreg" - --with-gtest="$env:GITHUB_WORKSPACE/gtest" + --with-boot-jdk="$env:BOOT_JDK" + --with-jtreg="$env:JT_HOME" + --with-gtest="$env:GTEST" --with-default-make-target="product-bundles test-bundles" --enable-jtreg-failure-handler - --disable-precompiled-headers working-directory: jdk - name: Build @@ -994,7 +1561,10 @@ jobs: continue-on-error: true needs: - prerequisites + - linux_additional_build + - windows_aarch64_build - linux_x64_test + - linux_x86_test - windows_x64_test - macos_x64_test diff --git a/doc/building.html b/doc/building.html index 318a24aa840..0522bc4888b 100644 --- a/doc/building.html +++ b/doc/building.html @@ -97,12 +97,10 @@

Building the JDK

  • Getting Help
  • Hints and Suggestions for Advanced Users
  • Understanding the Build System

    TL;DR (Instructions for the Impatient)

    -

    If you are eager to try out building the JDK, these simple steps works most of the time. They assume that you have installed Mercurial (and Cygwin if running on Windows) and cloned the top-level JDK repository that you want to build.

    +

    If you are eager to try out building the JDK, these simple steps works most of the time. They assume that you have installed Git (and Cygwin if running on Windows) and cloned the top-level JDK repository that you want to build.

    1. Get the complete source code:
      -hg clone http://hg.openjdk.java.net/jdk/jdk

    2. +git clone https://git.openjdk.java.net/jdk/

    3. Run configure:
      bash configure

      If configure fails due to missing dependencies (to either the toolchain, build tools, external libraries or the boot JDK), most of the time it prints a suggestion on how to resolve the situation on your platform. Follow the instructions, and try running bash configure again.

    4. @@ -135,8 +133,8 @@

      Introduction

      The JDK is a complex software project. Building it requires a certain amount of technical expertise, a fair number of dependencies on external software, and reasonably powerful hardware.

      If you just want to use the JDK and not build it yourself, this document is not for you. See for instance OpenJDK installation for some methods of installing a prebuilt JDK.

      Getting the Source Code

      -

      Make sure you are getting the correct version. As of JDK 10, the source is no longer split into separate repositories so you only need to clone one single repository. At the OpenJDK Mercurial server you can see a list of all available repositories. If you want to build an older version, e.g. JDK 8, it is recommended that you get the jdk8u forest, which contains incremental updates, instead of the jdk8 forest, which was frozen at JDK 8 GA.

      -

      If you are new to Mercurial, a good place to start is the Mercurial Beginner's Guide. The rest of this document assumes a working knowledge of Mercurial.

      +

      Make sure you are getting the correct version. As of JDK 10, the source is no longer split into separate repositories so you only need to clone one single repository. At the OpenJDK Git site you can see a list of all available repositories. If you want to build an older version, e.g. JDK 11, it is recommended that you get the jdk11u repo, which contains incremental updates, instead of the jdk11 repo, which was frozen at JDK 11 GA.

      +

      If you are new to Git, a good place to start is the book Pro Git. The rest of this document assumes a working knowledge of Git.

      Special Considerations

      For a smooth building experience, it is recommended that you follow these rules on where and how to check out the source code.

      @@ -194,7 +196,7 @@

      Windows

      Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.

      On Windows, it is important that you pay attention to the instructions in the Special Considerations.

      Windows is the only non-POSIX OS supported by the JDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. Currently, the only supported such layers are Cygwin and Windows Subsystem for Linux (WSL). (Msys is no longer supported due to a too old bash; msys2 would likely be possible to support in a future version but that would require effort to implement.)

      -

      Internally in the build system, all paths are represented as Unix-style paths, e.g. /cygdrive/c/hg/jdk9/Makefile rather than C:\hg\jdk9\Makefile. This rule also applies to input to the build system, e.g. in arguments to configure. So, use --with-msvcr-dll=/cygdrive/c/msvcr100.dll rather than --with-msvcr-dll=c:\msvcr100.dll. For details on this conversion, see the section on Fixpath.

      +

      Internally in the build system, all paths are represented as Unix-style paths, e.g. /cygdrive/c/git/jdk/Makefile rather than C:\git\jdk\Makefile. This rule also applies to input to the build system, e.g. in arguments to configure. So, use --with-msvcr-dll=/cygdrive/c/msvcr100.dll rather than --with-msvcr-dll=c:\msvcr100.dll. For details on this conversion, see the section on Fixpath.

      Cygwin

      A functioning Cygwin environment is required for building the JDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.

      Note: Cygwin has a model of continuously updating all packages without any easy way to install or revert to a specific version of a package. This means that whenever you add or update a package in Cygwin, you might (inadvertently) update tools that are used by the JDK build process, and that can cause unexpected build problems.

      @@ -297,6 +299,7 @@

      Apple Xcode

      Microsoft Visual Studio

      The minimum accepted version of Visual Studio is 2017. Older versions will not be accepted by configure and will not work. The maximum accepted version of Visual Studio is 2019.

      If you have multiple versions of Visual Studio installed, configure will by default pick the latest. You can request a specific version to be used by setting --with-toolchain-version, e.g. --with-toolchain-version=2017.

      +

      If you have Visual Studio installed but configure fails to detect it, it may be because of spaces in path.

      IBM XL C/C++

      Please consult the AIX section of the Supported Build Platforms OpenJDK Build Wiki page for details about which versions of XLC are supported.

      Boot JDK Requirements

      @@ -400,7 +403,7 @@

      Configure Arguments for Tai
    5. --enable-jvm-feature-<feature> or --disable-jvm-feature-<feature> - Include (or exclude) <feature> as a JVM feature in Hotspot. You can also specify a list of features to be enabled, separated by space or comma, as --with-jvm-features=<feature>[,<feature>...]. If you prefix <feature> with a -, it will be disabled. These options will modify the default list of features for the JVM variant(s) you are building. For the custom JVM variant, the default list is empty. A complete list of valid JVM features can be found using bash configure --help.
    6. --with-target-bits=<bits> - Create a target binary suitable for running on a <bits> platform. Use this to create 32-bit output on a 64-bit build platform, instead of doing a full cross-compile. (This is known as a reduced build.)
    7. -

      On Linux, BSD and AIX, it is possible to override where Java by default searches for runtime/JNI libraries. This can be useful in situations where there is a special shared directory for system JNI libraries. This setting can in turn be overriden at runtime by setting the java.library.path property.

      +

      On Linux, BSD and AIX, it is possible to override where Java by default searches for runtime/JNI libraries. This can be useful in situations where there is a special shared directory for system JNI libraries. This setting can in turn be overridden at runtime by setting the java.library.path property.

      • --with-jni-libpath=<path> - Use the specified path as a default when searching for runtime libraries.
      @@ -439,7 +442,7 @@

      Configure Arguments for E

      Configure Control Variables

      It is possible to control certain aspects of configure by overriding the value of configure variables, either on the command line or in the environment.

      Normally, this is not recommended. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, configure will print a warning if this is detected.

      -

      However, there are a few configure variables, known as control variables that are supposed to be overriden on the command line. These are variables that describe the location of tools needed by the build, like MAKE or GREP. If any such variable is specified, configure will use that value instead of trying to autodetect the tool. For instance, bash configure MAKE=/opt/gnumake4.0/bin/make.

      +

      However, there are a few configure variables, known as control variables that are supposed to be overridden on the command line. These are variables that describe the location of tools needed by the build, like MAKE or GREP. If any such variable is specified, configure will use that value instead of trying to autodetect the tool. For instance, bash configure MAKE=/opt/gnumake4.0/bin/make.

      If a configure argument exists, use that instead, e.g. use --with-jtreg instead of setting JTREGEXE.

      Also note that, despite what autoconf claims, setting CFLAGS will not accomplish anything. Instead use --with-extra-cflags (and similar for cxxflags and ldflags).

      Running Make

      @@ -476,7 +479,7 @@

      Common Make Targets

      Make Control Variables

      It is possible to control make behavior by overriding the value of make variables, either on the command line or in the environment.

      Normally, this is not recommended. If used improperly, it can lead to a broken build. Unless you're well versed in the build system, this is hard to use properly. Therefore, make will print a warning if this is detected.

      -

      However, there are a few make variables, known as control variables that are supposed to be overriden on the command line. These make up the "make time" configuration, as opposed to the "configure time" configuration.

      +

      However, there are a few make variables, known as control variables that are supposed to be overridden on the command line. These make up the "make time" configuration, as opposed to the "configure time" configuration.

      General Make Control Variables

      Excluded Features

      * * @since 1.8 - * @jls 9.6 Annotation Types + * @jls 9.6 Annotation Interfaces * @jls 9.6.4.3 {@code @Inherited} * @jls 9.7.4 Where Annotations May Appear - * @jls 9.7.5 Multiple Annotations of the Same Type + * @jls 9.7.5 Multiple Annotations of the Same Interface */ public interface AnnotatedConstruct { /** @@ -145,8 +145,8 @@ public interface AnnotatedConstruct { List getAnnotationMirrors(); /** - * Returns this construct's annotation of the specified type if - * such an annotation is present, else {@code null}. + * {@return this construct's annotation of the specified type if + * such an annotation is present, else {@code null}} * *

      The annotation returned by this method could contain an element * whose value is of type {@code Class}. @@ -176,8 +176,6 @@ public interface AnnotatedConstruct { * @param the annotation type * @param annotationType the {@code Class} object corresponding to * the annotation type - * @return this construct's annotation for the specified - * annotation type if present, else {@code null} * * @see #getAnnotationMirrors() * @see java.lang.reflect.AnnotatedElement#getAnnotation @@ -186,7 +184,7 @@ public interface AnnotatedConstruct { * @see IncompleteAnnotationException * @see MirroredTypeException * @see MirroredTypesException - * @jls 9.6.1 Annotation Type Elements + * @jls 9.6.1 Annotation Interface Elements */ A getAnnotation(Class annotationType); @@ -246,8 +244,8 @@ public interface AnnotatedConstruct { * @see IncompleteAnnotationException * @see MirroredTypeException * @see MirroredTypesException - * @jls 9.6 Annotation Types - * @jls 9.6.1 Annotation Type Elements + * @jls 9.6 Annotation Interfaces + * @jls 9.6.1 Annotation Interface Elements */ A[] getAnnotationsByType(Class annotationType); } diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java index 6900bf7280c..7df7b914c5e 100644 --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java @@ -223,18 +223,24 @@ public enum SourceVersion { * * @since 16 */ - RELEASE_16; + RELEASE_16, + + /** + * The version recognized by the Java Platform, Standard Edition + * 17. + * + * @since 17 + */ + RELEASE_17; // Note that when adding constants for newer releases, the // behavior of latest() and latestSupported() must be updated too. /** - * Returns the latest source version that can be modeled. - * - * @return the latest source version that can be modeled + * {@return the latest source version that can be modeled} */ public static SourceVersion latest() { - return RELEASE_16; + return RELEASE_17; } private static final SourceVersion latestSupported = getLatestSupported(); @@ -249,13 +255,13 @@ public static SourceVersion latest() { private static SourceVersion getLatestSupported() { int intVersion = Runtime.version().feature(); return (intVersion >= 11) ? - valueOf("RELEASE_" + Math.min(16, intVersion)): + valueOf("RELEASE_" + Math.min(17, intVersion)): RELEASE_10; } /** - * Returns the latest source version fully supported by the - * current execution environment. {@code RELEASE_9} or later must + * {@return the latest source version fully supported by the + * current execution environment} {@code RELEASE_9} or later must * be returned. * * @apiNote This method is included alongside {@link latest} to @@ -272,8 +278,6 @@ private static SourceVersion getLatestSupported() { * current execution environment, the processor should only use * platform features up to the {@code latestSupported} release, * which may be earlier than the {@code latest} release. - * - * @return the latest source version that is fully supported */ public static SourceVersion latestSupported() { return latestSupported; @@ -392,7 +396,7 @@ public static boolean isName(CharSequence name, SourceVersion version) { * literal, or null literal, {@code false} otherwise. * @jls 3.9 Keywords * @jls 3.10.3 Boolean Literals - * @jls 3.10.7 The Null Literal + * @jls 3.10.8 The Null Literal */ public static boolean isKeyword(CharSequence s) { return isKeyword(s, latest()); @@ -410,7 +414,7 @@ public static boolean isKeyword(CharSequence s) { * literal, or null literal, {@code false} otherwise. * @jls 3.9 Keywords * @jls 3.10.3 Boolean Literals - * @jls 3.10.7 The Null Literal + * @jls 3.10.8 The Null Literal * @since 9 */ public static boolean isKeyword(CharSequence s, SourceVersion version) { diff --git a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java index c6bb2fc384e..1f493cadbb2 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ /** * Represents an annotation. An annotation associates a value with - * each element of an annotation type. + * each element of an annotation interface. * *

      Annotations should be compared using the {@code equals} * method. There is no guarantee that any particular annotation will @@ -44,9 +44,7 @@ public interface AnnotationMirror { /** - * Returns the type of this annotation. - * - * @return the type of this annotation + * {@return the type of this annotation} */ DeclaredType getAnnotationType(); diff --git a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java index 68b54210c61..ed7a180537e 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.lang.model.element; /** - * Represents a value of an annotation type element. + * Represents a value of an annotation interface element. * A value is of one of the following types: *

      . * @since 1.4 */ + @Serial private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); @@ -857,6 +863,7 @@ private void writeObject(ObjectOutputStream s) throws IOException { * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap * @since 1.4 */ + @Serial private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); diff --git a/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java b/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java index 8ded4061570..b9e8efb8b5b 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.Serial; import java.io.Serializable; import java.util.TooManyListenersException; @@ -92,6 +93,10 @@ public class DragSourceContext implements DragSourceListener, DragSourceMotionListener, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -115407898692194719L; // used by updateCurrentCursor @@ -553,6 +558,7 @@ private void setCursorImpl(Cursor c) { * {@code null}. * @since 1.4 */ + @Serial private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); @@ -578,6 +584,7 @@ private void writeObject(ObjectOutputStream s) throws IOException { * @throws IOException if an I/O error occurs * @since 1.4 */ + @Serial private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { diff --git a/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java index 141603f1320..077d640a6b6 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package java.awt.dnd; import java.awt.event.InputEvent; +import java.io.Serial; /** * The {@code DragSourceDragEvent} is @@ -71,6 +72,10 @@ public class DragSourceDragEvent extends DragSourceEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = 481346297933902471L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/DragSourceDropEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DragSourceDropEvent.java index 84317613ddc..9cf83fe13ad 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DragSourceDropEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DragSourceDropEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.awt.dnd; +import java.io.Serial; + /** * The {@code DragSourceDropEvent} is delivered * from the {@code DragSourceContextPeer}, @@ -42,6 +44,10 @@ public class DragSourceDropEvent extends DragSourceEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -5571321229470821891L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/DragSourceEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DragSourceEvent.java index 5a389b0dd08..460daa8e78d 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DragSourceEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DragSourceEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package java.awt.dnd; import java.awt.Point; - +import java.io.Serial; import java.util.EventObject; /** @@ -59,6 +59,10 @@ public class DragSourceEvent extends EventObject { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -763287114604032641L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java b/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java index a7e5c8b71bf..a05dbdebad2 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.Serial; import java.io.Serializable; import java.util.TooManyListenersException; @@ -67,6 +68,10 @@ public class DropTarget implements DropTargetListener, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -6283860791671019047L; /** @@ -581,6 +586,7 @@ protected DropTargetContext createDropTargetContext() { * instance, or {@code null}. * @since 1.4 */ + @Serial private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); @@ -604,6 +610,7 @@ private void writeObject(ObjectOutputStream s) throws IOException { * @throws IOException if an I/O error occurs * @since 1.4 */ + @Serial private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { diff --git a/src/java.desktop/share/classes/java/awt/dnd/DropTargetContext.java b/src/java.desktop/share/classes/java/awt/dnd/DropTargetContext.java index 839c543cb8e..8eac26a5fd2 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DropTargetContext.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DropTargetContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,16 +26,13 @@ package java.awt.dnd; import java.awt.Component; - import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; - import java.awt.dnd.peer.DropTargetContextPeer; - import java.io.IOException; +import java.io.Serial; import java.io.Serializable; - import java.util.Arrays; import java.util.List; @@ -58,6 +55,10 @@ public class DropTargetContext implements Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -634158968993743371L; static { diff --git a/src/java.desktop/share/classes/java/awt/dnd/DropTargetDragEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DropTargetDragEvent.java index 9a6b57d450b..e7d53f40126 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DropTargetDragEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DropTargetDragEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,9 @@ package java.awt.dnd; import java.awt.Point; - import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; - +import java.io.Serial; import java.util.List; /** @@ -72,6 +71,10 @@ public class DropTargetDragEvent extends DropTargetEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -8422265619058953682L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/DropTargetDropEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DropTargetDropEvent.java index 7fdee103b3d..6fea3bafc0d 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DropTargetDropEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DropTargetDropEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,9 @@ package java.awt.dnd; import java.awt.Point; - import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; - +import java.io.Serial; import java.util.List; /** @@ -71,6 +70,10 @@ public class DropTargetDropEvent extends DropTargetEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = -1721911170440459322L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/DropTargetEvent.java b/src/java.desktop/share/classes/java/awt/dnd/DropTargetEvent.java index 3dfe215b0a2..7bacb7392fc 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/DropTargetEvent.java +++ b/src/java.desktop/share/classes/java/awt/dnd/DropTargetEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,7 @@ package java.awt.dnd; -import java.util.EventObject; -import java.awt.dnd.DropTargetContext; +import java.io.Serial; /** * The {@code DropTargetEvent} is the base @@ -42,6 +41,10 @@ public class DropTargetEvent extends java.util.EventObject { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = 2821229066521922993L; /** diff --git a/src/java.desktop/share/classes/java/awt/dnd/InvalidDnDOperationException.java b/src/java.desktop/share/classes/java/awt/dnd/InvalidDnDOperationException.java index c57573797e0..539feb59912 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/InvalidDnDOperationException.java +++ b/src/java.desktop/share/classes/java/awt/dnd/InvalidDnDOperationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.awt.dnd; +import java.io.Serial; + /** * This exception is thrown by various methods in the java.awt.dnd package. * It is usually thrown to indicate that the target in question is unable @@ -36,6 +38,10 @@ public class InvalidDnDOperationException extends IllegalStateException { + /** + * Use serialVersionUID from JDK 1.8 for interoperability. + */ + @Serial private static final long serialVersionUID = -6062568741193956678L; private static String dft_msg = "The operation requested cannot be performed by the DnD system since it is not in the appropriate state"; diff --git a/src/java.desktop/share/classes/java/awt/dnd/MouseDragGestureRecognizer.java b/src/java.desktop/share/classes/java/awt/dnd/MouseDragGestureRecognizer.java index 0c5a623f754..f155ea4cfe5 100644 --- a/src/java.desktop/share/classes/java/awt/dnd/MouseDragGestureRecognizer.java +++ b/src/java.desktop/share/classes/java/awt/dnd/MouseDragGestureRecognizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,10 @@ package java.awt.dnd; import java.awt.Component; - import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import java.io.Serial; /** * This abstract subclass of {@code DragGestureRecognizer} @@ -64,6 +64,10 @@ public abstract class MouseDragGestureRecognizer extends DragGestureRecognizer implements MouseListener, MouseMotionListener { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + @Serial private static final long serialVersionUID = 6220099344182281120L; /** diff --git a/src/java.desktop/share/classes/java/awt/doc-files/AWTThreadIssues.html b/src/java.desktop/share/classes/java/awt/doc-files/AWTThreadIssues.html index 75ff54a7ffa..f5f7d314e87 100644 --- a/src/java.desktop/share/classes/java/awt/doc-files/AWTThreadIssues.html +++ b/src/java.desktop/share/classes/java/awt/doc-files/AWTThreadIssues.html @@ -5,7 +5,7 @@ AWT Threading Issues 0; ) - q.poll(1L, TimeUnit.MICROSECONDS); - assertTrue(nodeCount(q) <= initialNodeCount + SWEEP_THRESHOLD); - - if (blockHead != null) { - blockHead.interrupt(); - blockHead.join(); - } - } - /** Checks conditions which should always be true. */ void assertInvariants(LinkedTransferQueue q) { assertNotNull(head(q)); diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java new file mode 100644 index 00000000000..7ae3a0a6853 --- /dev/null +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @run testng AsyncShutdownNow + * @summary Test invoking shutdownNow with threads blocked in Future.get, + * invokeAll, and invokeAny + */ + +// TODO: this test is far too slow + +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class AsyncShutdownNow { + + // long running interruptible task + private static final Callable SLEEP_FOR_A_DAY = () -> { + Thread.sleep(86400_000); + return null; + }; + + private ScheduledExecutorService scheduledExecutor; + + @BeforeClass + public void setup() { + scheduledExecutor = Executors.newScheduledThreadPool(1); + } + + @AfterClass + public void teardown() { + scheduledExecutor.shutdown(); + } + + /** + * Schedule the given executor service to be shutdown abruptly after the given + * delay, in seconds. + */ + private void scheduleShutdownNow(ExecutorService executor, int delayInSeconds) { + scheduledExecutor.schedule(() -> { + executor.shutdownNow(); + return null; + }, delayInSeconds, TimeUnit.SECONDS); + } + + /** + * The executors to test. + */ + @DataProvider(name = "executors") + public Object[][] executors() { + return new Object[][] { + { new ForkJoinPool() }, + { new ForkJoinPool(1) }, + }; + } + + /** + * Test shutdownNow with running task and thread blocked in Future::get. + */ + @Test(dataProvider = "executors") + public void testFutureGet(ExecutorService executor) throws Exception { + System.out.format("testFutureGet: %s%n", executor); + scheduleShutdownNow(executor, 5); + try { + // submit long running task, the task should be cancelled + Future future = executor.submit(SLEEP_FOR_A_DAY); + try { + future.get(); + assertTrue(false); + } catch (ExecutionException e) { + // expected + } + } finally { + executor.shutdown(); + } + } + + /** + * Test shutdownNow with running task and thread blocked in a timed Future::get. + */ + @Test(dataProvider = "executors") + public void testTimedFutureGet(ExecutorService executor) throws Exception { + System.out.format("testTimedFutureGet: %s%n", executor); + scheduleShutdownNow(executor, 5); + try { + // submit long running task, the task should be cancelled + Future future = executor.submit(SLEEP_FOR_A_DAY); + try { + future.get(1, TimeUnit.HOURS); + assertTrue(false); + } catch (ExecutionException e) { + // expected + } + } finally { + executor.shutdown(); + } + } + + /** + * Test shutdownNow with thread blocked in invokeAll. + */ + @Test(dataProvider = "executors") + public void testInvokeAll(ExecutorService executor) throws Exception { + System.out.format("testInvokeAll: %s%n", executor); + scheduleShutdownNow(executor, 5); + try { + // execute long running tasks + List> futures = executor.invokeAll(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); + for (Future f : futures) { + assertTrue(f.isDone()); + try { + Object result = f.get(); + assertTrue(false); + } catch (ExecutionException | CancellationException e) { + // expected + } + } + } finally { + executor.shutdown(); + } + } + + /** + * Test shutdownNow with thread blocked in invokeAny. + */ + @Test(dataProvider = "executors") + public void testInvokeAny(ExecutorService executor) throws Exception { + System.out.format("testInvokeAny: %s%n", executor); + scheduleShutdownNow(executor, 5); + try { + try { + // execute long running tasks + executor.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); + assertTrue(false); + } catch (ExecutionException e) { + // expected + } + } finally { + executor.shutdown(); + } + } +} diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java new file mode 100644 index 00000000000..4b1f2eccfe2 --- /dev/null +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @run testng AsyncShutdownNowInvokeAny + * @summary A variant of AsyncShutdownNow useful for race bug hunting + */ + +// TODO: reorganize all of the AsyncShutdown tests + +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class AsyncShutdownNowInvokeAny { + + // long running interruptible task + private static final Callable SLEEP_FOR_A_DAY = () -> { + Thread.sleep(86400_000); + return null; + }; + + private ScheduledExecutorService scheduledExecutor; + + @BeforeClass + public void setup() { + scheduledExecutor = Executors.newScheduledThreadPool(1); + } + + @AfterClass + public void teardown() { + scheduledExecutor.shutdown(); + } + + /** + * Schedule the given executor service to be shutdown abruptly after the given + * delay, in seconds. + */ + private void scheduleShutdownNow(ExecutorService executor, int delayInSeconds) { + scheduledExecutor.schedule(() -> { + executor.shutdownNow(); + return null; + }, delayInSeconds, TimeUnit.SECONDS); + } + + /** + * Test shutdownNow with thread blocked in invokeAny. + */ + @Test + public void testInvokeAny() throws Exception { + final int reps = 4; + for (int rep = 1; rep < reps; rep++) { + ExecutorService pool = new ForkJoinPool(1); + scheduleShutdownNow(pool, 5); + try { + try { + // execute long running tasks + pool.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); + assertTrue(false); + } catch (ExecutionException e) { + // expected + } + } finally { + pool.shutdown(); + } + } + } +} diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAnyRace.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAnyRace.java new file mode 100644 index 00000000000..c48cf949546 --- /dev/null +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAnyRace.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @run testng AsyncShutdownNowInvokeAnyRace + * @summary A variant of AsyncShutdownNow useful for race bug hunting + */ + +// TODO: reorganize all of the AsyncShutdown tests + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.lang.management.ManagementFactory; +import java.lang.management.LockInfo; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class AsyncShutdownNowInvokeAnyRace { + + // TODO: even more jitter-inducing parallelism? + +// int nThreads = ThreadLocalRandom.current().nextInt(1, 50); +// ExecutorService pool = Executors.newCachedThreadPool(); +// Callable task = () -> { testInvokeAny_1(); return null; }; +// List> tasks = Collections.nCopies(nThreads, task); +// try { +// for (Future future : pool.invokeAll(tasks)) { +// future.get(); +// } +// } finally { +// pool.shutdown(); +// } +// } + +// public void testInvokeAny_1() throws Exception { + + /** + * Test shutdownNow with thread blocked in invokeAny. + */ + @Test + public void testInvokeAny() throws Exception { + final int reps = 30_000; + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + int falseAlarms = 0; + for (int rep = 1; rep < reps; rep++) { + ForkJoinPool pool = new ForkJoinPool(1); + CountDownLatch pleaseShutdownNow = new CountDownLatch(1); + int nTasks = rnd.nextInt(2, 5); + AtomicInteger threadsStarted = new AtomicInteger(0); + AtomicReference poolAtShutdownNow = new AtomicReference<>(); + Callable blockPool = () -> { + threadsStarted.getAndIncrement(); + // await submission quiescence; may false-alarm + // TODO: consider re-checking to reduce false alarms + while (threadsStarted.get() + pool.getQueuedSubmissionCount() < nTasks) + Thread.yield(); + pleaseShutdownNow.countDown(); + Thread.sleep(86400_000); + return null; + }; + List> tasks = Collections.nCopies(nTasks, blockPool); + Runnable shutdown = () -> { + try { + pleaseShutdownNow.await(); + poolAtShutdownNow.set(pool.toString()); + pool.shutdownNow(); + } catch (Throwable t) { throw new AssertionError(t); } + }; + Future shutdownResult = CompletableFuture.runAsync(shutdown); + try { + try { + if (rnd.nextBoolean()) + pool.invokeAny(tasks, 10L, SECONDS); + else + pool.invokeAny(tasks); + throw new AssertionError("should throw"); + } catch (RejectedExecutionException re) { + falseAlarms++; + } catch (CancellationException re) { + } catch (ExecutionException ex) { + Throwable cause = ex.getCause(); + if (!(cause instanceof InterruptedException) && + !(cause instanceof CancellationException)) + throw ex; + } catch (TimeoutException ex) { + dumpTestThreads(); + int i = rep; + String detail = String.format( + "invokeAny timed out, " + + "nTasks=%d rep=%d threadsStarted=%d%n" + + "poolAtShutdownNow=%s%n" + + "poolAtTimeout=%s%n" + + "queuedTaskCount=%d queuedSubmissionCount=%d", + nTasks, i, threadsStarted.get(), + poolAtShutdownNow, + pool, + pool.getQueuedTaskCount(), + pool.getQueuedSubmissionCount()); + throw new AssertionError(detail, ex); + } + } finally { + pool.shutdown(); + } + if (falseAlarms != 0) + System.out.println("Premature shutdowns = " + falseAlarms); + shutdownResult.get(); + } + } + + //--- thread stack dumping (from JSR166TestCase.java) --- + + private static final ThreadMXBean THREAD_MXBEAN + = ManagementFactory.getThreadMXBean(); + + /** Returns true if thread info might be useful in a thread dump. */ + static boolean threadOfInterest(ThreadInfo info) { + final String name = info.getThreadName(); + String lockName; + if (name == null) + return true; + if (name.equals("Signal Dispatcher") + || name.equals("WedgedTestDetector")) + return false; + if (name.equals("Reference Handler")) { + // Reference Handler stacktrace changed in JDK-8156500 + StackTraceElement[] stackTrace; String methodName; + if ((stackTrace = info.getStackTrace()) != null + && stackTrace.length > 0 + && (methodName = stackTrace[0].getMethodName()) != null + && methodName.equals("waitForReferencePendingList")) + return false; + // jdk8 Reference Handler stacktrace + if ((lockName = info.getLockName()) != null + && lockName.startsWith("java.lang.ref")) + return false; + } + if ((name.equals("Finalizer") || name.equals("Common-Cleaner")) + && (lockName = info.getLockName()) != null + && lockName.startsWith("java.lang.ref")) + return false; + if (name.startsWith("ForkJoinPool.commonPool-worker") + && (lockName = info.getLockName()) != null + && lockName.startsWith("java.util.concurrent.ForkJoinPool")) + return false; + return true; + } + + /** + * A debugging tool to print stack traces of most threads, as jstack does. + * Uninteresting threads are filtered out. + */ + static void dumpTestThreads() { + System.err.println("------ stacktrace dump start ------"); + for (ThreadInfo info : THREAD_MXBEAN.dumpAllThreads(true, true)) + if (threadOfInterest(info)) + System.err.print(info); + System.err.println("------ stacktrace dump end ------"); + } + +} diff --git a/test/jdk/java/util/concurrent/forkjoin/FJExceptionTableLeak.java b/test/jdk/java/util/concurrent/forkjoin/FJExceptionTableLeak.java deleted file mode 100644 index f62c7beb019..00000000000 --- a/test/jdk/java/util/concurrent/forkjoin/FJExceptionTableLeak.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Written by Doug Lea and Martin Buchholz with assistance from - * members of JCP JSR-166 Expert Group and released to the public - * domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -/* - * @test - * @bug 8004138 8205576 - * @modules java.base/java.util.concurrent:open - * @run testng FJExceptionTableLeak - * @summary Checks that ForkJoinTask thrown exceptions are not leaked. - * This whitebox test is sensitive to forkjoin implementation details. - */ - -import static org.testng.Assert.*; -import org.testng.annotations.Test; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; - -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.RecursiveAction; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.locks.ReentrantLock; -import java.util.function.BooleanSupplier; - -@Test -public class FJExceptionTableLeak { - final ThreadLocalRandom rnd = ThreadLocalRandom.current(); - final VarHandle NEXT, EX; - final Object[] exceptionTable; - final ReentrantLock exceptionTableLock; - - FJExceptionTableLeak() throws ReflectiveOperationException { - MethodHandles.Lookup lookup = MethodHandles.privateLookupIn( - ForkJoinTask.class, MethodHandles.lookup()); - Class nodeClass = Class.forName( - ForkJoinTask.class.getName() + "$ExceptionNode"); - VarHandle exceptionTableHandle = lookup.findStaticVarHandle( - ForkJoinTask.class, "exceptionTable", arrayClass(nodeClass)); - VarHandle exceptionTableLockHandle = lookup.findStaticVarHandle( - ForkJoinTask.class, "exceptionTableLock", ReentrantLock.class); - exceptionTable = (Object[]) exceptionTableHandle.get(); - exceptionTableLock = (ReentrantLock) exceptionTableLockHandle.get(); - - NEXT = lookup.findVarHandle(nodeClass, "next", nodeClass); - EX = lookup.findVarHandle(nodeClass, "ex", Throwable.class); - } - - static Class arrayClass(Class klazz) { - try { - return (Class) Class.forName("[L" + klazz.getName() + ";"); - } catch (ReflectiveOperationException ex) { - throw new Error(ex); - } - } - - Object next(Object node) { return NEXT.get(node); } - Throwable ex(Object node) { return (Throwable) EX.get(node); } - - static class FailingTaskException extends RuntimeException {} - static class FailingTask extends RecursiveAction { - public void compute() { throw new FailingTaskException(); } - } - - /** Counts all FailingTaskExceptions still recorded in exceptionTable. */ - int retainedExceptions() { - exceptionTableLock.lock(); - try { - int count = 0; - for (Object node : exceptionTable) - for (; node != null; node = next(node)) - if (ex(node) instanceof FailingTaskException) - count++; - return count; - } finally { - exceptionTableLock.unlock(); - } - } - - @Test - public void exceptionTableCleanup() throws Exception { - ArrayList failedTasks = failedTasks(); - - // Retain a strong ref to one last failing task - FailingTask lastTask = failedTasks.get(rnd.nextInt(failedTasks.size())); - - // Clear all other strong refs, making exception table cleanable - failedTasks.clear(); - - BooleanSupplier exceptionTableIsClean = () -> { - try { - // Trigger exception table expunging as side effect - lastTask.join(); - throw new AssertionError("should throw"); - } catch (FailingTaskException expected) {} - int count = retainedExceptions(); - if (count == 0) - throw new AssertionError("expected to find last task"); - return count == 1; - }; - gcAwait(exceptionTableIsClean); - } - - /** Sequestered into a separate method to inhibit GC retention. */ - ArrayList failedTasks() - throws Exception { - final ForkJoinPool pool = new ForkJoinPool(rnd.nextInt(1, 4)); - - assertEquals(0, retainedExceptions()); - - final ArrayList tasks = new ArrayList<>(); - - for (int i = exceptionTable.length; i--> 0; ) { - FailingTask task = new FailingTask(); - pool.execute(task); - tasks.add(task); // retain strong refs to all tasks, for now - task = null; // excessive GC retention paranoia - } - for (FailingTask task : tasks) { - try { - task.join(); - throw new AssertionError("should throw"); - } catch (FailingTaskException success) {} - task = null; // excessive GC retention paranoia - } - - if (rnd.nextBoolean()) - gcAwait(() -> retainedExceptions() == tasks.size()); - - return tasks; - } - - // --------------- GC finalization infrastructure --------------- - - /** No guarantees, but effective in practice. */ - static void forceFullGc() { - long timeoutMillis = 1000L; - CountDownLatch finalized = new CountDownLatch(1); - ReferenceQueue queue = new ReferenceQueue<>(); - WeakReference ref = new WeakReference<>( - new Object() { protected void finalize() { finalized.countDown(); }}, - queue); - try { - for (int tries = 3; tries--> 0; ) { - System.gc(); - if (finalized.await(timeoutMillis, MILLISECONDS) - && queue.remove(timeoutMillis) != null - && ref.get() == null) { - System.runFinalization(); // try to pick up stragglers - return; - } - timeoutMillis *= 4; - } - } catch (InterruptedException unexpected) { - throw new AssertionError("unexpected InterruptedException"); - } - throw new AssertionError("failed to do a \"full\" gc"); - } - - static void gcAwait(BooleanSupplier s) { - for (int i = 0; i < 10; i++) { - if (s.getAsBoolean()) - return; - forceFullGc(); - } - throw new AssertionError("failed to satisfy condition"); - } -} diff --git a/test/jdk/java/util/concurrent/tck/AbstractExecutorServiceTest.java b/test/jdk/java/util/concurrent/tck/AbstractExecutorServiceTest.java index 997563e2547..a2068f39bbf 100644 --- a/test/jdk/java/util/concurrent/tck/AbstractExecutorServiceTest.java +++ b/test/jdk/java/util/concurrent/tck/AbstractExecutorServiceTest.java @@ -74,7 +74,7 @@ static class DirectExecutorService extends AbstractExecutorService { public void shutdown() { shutdown = true; } public List shutdownNow() { shutdown = true; - return Collections.EMPTY_LIST; + return Collections.emptyList(); } public boolean isShutdown() { return shutdown; } public boolean isTerminated() { return isShutdown(); } @@ -138,7 +138,7 @@ public void testSubmitPrivilegedAction() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedAction() { + Future future = e.submit(Executors.callable(new PrivilegedAction() { public Object run() { return TEST_STRING; }})); @@ -159,7 +159,7 @@ public void testSubmitPrivilegedExceptionAction() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { + Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { public Object run() { return TEST_STRING; }})); @@ -177,7 +177,7 @@ public void testSubmitFailedPrivilegedExceptionAction() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { + Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { public Object run() throws Exception { throw new IndexOutOfBoundsException(); }})); @@ -208,7 +208,7 @@ public void testNullTaskSubmission() { public void testInterruptedSubmit() throws InterruptedException { final CountDownLatch submitted = new CountDownLatch(1); final CountDownLatch quittingTime = new CountDownLatch(1); - final Callable awaiter = new CheckedCallable() { + final Callable awaiter = new CheckedCallable<>() { public Void realCall() throws InterruptedException { assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS)); return null; @@ -240,7 +240,7 @@ public void testSubmitEE() throws InterruptedException { 60, TimeUnit.SECONDS, new ArrayBlockingQueue(10)); try (PoolCleaner cleaner = cleaner(p)) { - Callable c = new Callable() { + Callable c = new Callable<>() { public Object call() { throw new ArithmeticException(); }}; try { p.submit(c).get(); @@ -611,7 +611,7 @@ public void testTimedInvokeAll6() throws Exception { e.invokeAll(tasks, timeout, MILLISECONDS); assertEquals(tasks.size(), futures.size()); assertTrue(millisElapsedSince(startTime) >= timeout); - for (Future future : futures) + for (Future future : futures) assertTrue(future.isDone()); try { assertEquals("0", futures.get(0).get()); diff --git a/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java b/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java index 583ebf71e49..429dc72d2fa 100644 --- a/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java @@ -49,26 +49,26 @@ public static Test suite() { return new TestSuite(AbstractQueueTest.class); } - static class Succeed extends AbstractQueue { - public boolean offer(Integer x) { + static class Succeed extends AbstractQueue { + public boolean offer(Item x) { if (x == null) throw new NullPointerException(); return true; } - public Integer peek() { return one; } - public Integer poll() { return one; } + public Item peek() { return one; } + public Item poll() { return one; } public int size() { return 0; } - public Iterator iterator() { return null; } // not needed + public Iterator iterator() { return null; } // not needed } - static class Fail extends AbstractQueue { - public boolean offer(Integer x) { + static class Fail extends AbstractQueue { + public boolean offer(Item x) { if (x == null) throw new NullPointerException(); return false; } - public Integer peek() { return null; } - public Integer poll() { return null; } + public Item peek() { return null; } + public Item poll() { return null; } public int size() { return 0; } - public Iterator iterator() { return null; } // not needed + public Iterator iterator() { return null; } // not needed } /** @@ -166,9 +166,9 @@ public void testAddAllSelf() { */ public void testAddAll2() { Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; + Item[] items = new Item[SIZE]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -179,11 +179,11 @@ public void testAddAll2() { */ public void testAddAll3() { Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + items[i] = itemFor(i); try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -193,11 +193,9 @@ public void testAddAll3() { */ public void testAddAll4() { Fail q = new Fail(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); + Item[] items = seqItems(SIZE); try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (IllegalStateException success) {} } diff --git a/test/jdk/java/util/concurrent/tck/ArrayBlockingQueueTest.java b/test/jdk/java/util/concurrent/tck/ArrayBlockingQueueTest.java index 0a783d70689..8f3483033bc 100644 --- a/test/jdk/java/util/concurrent/tck/ArrayBlockingQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/ArrayBlockingQueueTest.java @@ -64,7 +64,7 @@ public Collection emptyCollection() { boolean fair = randomBoolean(); return populatedQueue(0, SIZE, 2 * SIZE, fair); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -77,48 +77,48 @@ public Collection emptyCollection() { } public static class Fair extends BlockingQueueTest { - protected BlockingQueue emptyCollection() { + protected BlockingQueue emptyCollection() { return populatedQueue(0, SIZE, 2 * SIZE, true); } } public static class NonFair extends BlockingQueueTest { - protected BlockingQueue emptyCollection() { + protected BlockingQueue emptyCollection() { return populatedQueue(0, SIZE, 2 * SIZE, false); } } /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - static ArrayBlockingQueue populatedQueue(int n) { + static ArrayBlockingQueue populatedQueue(int n) { return populatedQueue(n, n, n, false); } /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1, with given capacity range and fairness. + * Items 0 ... n - 1, with given capacity range and fairness. */ - static ArrayBlockingQueue populatedQueue( + static ArrayBlockingQueue populatedQueue( int size, int minCapacity, int maxCapacity, boolean fair) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); int capacity = rnd.nextInt(minCapacity, maxCapacity + 1); - ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); assertTrue(q.isEmpty()); // shuffle circular array elements so they wrap { int n = rnd.nextInt(capacity); - for (int i = 0; i < n; i++) q.add(42); + for (int i = 0; i < n; i++) q.add(fortytwo); for (int i = 0; i < n; i++) q.remove(); } for (int i = 0; i < size; i++) - assertTrue(q.offer((Integer) i)); - assertEquals(size == 0, q.isEmpty()); - assertEquals(capacity - size, q.remainingCapacity()); - assertEquals(size, q.size()); + mustOffer(q, i); + mustEqual(size == 0, q.isEmpty()); + mustEqual(capacity - size, q.remainingCapacity()); + mustEqual(size, q.size()); if (size > 0) - assertEquals((Integer) 0, q.peek()); + mustEqual(0, q.peek()); return q; } @@ -126,7 +126,7 @@ static ArrayBlockingQueue populatedQueue( * A new queue has the indicated capacity */ public void testConstructor1() { - assertEquals(SIZE, new ArrayBlockingQueue(SIZE).remainingCapacity()); + mustEqual(SIZE, new ArrayBlockingQueue(SIZE).remainingCapacity()); } /** @@ -135,12 +135,12 @@ public void testConstructor1() { public void testConstructor_nonPositiveCapacity() { for (int i : new int[] { 0, -1, Integer.MIN_VALUE }) { try { - new ArrayBlockingQueue(i); + new ArrayBlockingQueue(i); shouldThrow(); } catch (IllegalArgumentException success) {} for (boolean fair : new boolean[] { true, false }) { try { - new ArrayBlockingQueue(i, fair); + new ArrayBlockingQueue(i, fair); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -152,7 +152,7 @@ public void testConstructor_nonPositiveCapacity() { */ public void testConstructor_nullCollection() { try { - new ArrayBlockingQueue(1, true, null); + new ArrayBlockingQueue(1, true, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -161,9 +161,9 @@ public void testConstructor_nullCollection() { * Initializing from Collection of null elements throws NPE */ public void testConstructor4() { - Collection elements = Arrays.asList(new Integer[SIZE]); + Collection elements = Arrays.asList(new Item[SIZE]); try { - new ArrayBlockingQueue(SIZE, false, elements); + new ArrayBlockingQueue(SIZE, false, elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -172,12 +172,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = i; - Collection elements = Arrays.asList(ints); + Item[] items = new Item[2]; items[0] = zero; + Collection elements = Arrays.asList(items); try { - new ArrayBlockingQueue(SIZE, false, elements); + new ArrayBlockingQueue(SIZE, false, elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -187,10 +185,10 @@ public void testConstructor5() { */ public void testConstructor_collectionTooLarge() { // just barely fits - succeeds - new ArrayBlockingQueue(SIZE, false, - Collections.nCopies(SIZE, "")); + new ArrayBlockingQueue(SIZE, false, + Collections.nCopies(SIZE, "")); try { - new ArrayBlockingQueue(SIZE - 1, false, + new ArrayBlockingQueue(SIZE - 1, false, Collections.nCopies(SIZE, "")); shouldThrow(); } catch (IllegalArgumentException success) {} @@ -200,27 +198,25 @@ public void testConstructor_collectionTooLarge() { * Queue contains all elements of collection used to initialize */ public void testConstructor7() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + Collection elements = Arrays.asList(items); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE, true, elements); for (int i = 0; i < SIZE; ++i) - ints[i] = i; - Collection elements = Arrays.asList(ints); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, true, elements); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * Queue transitions from empty to full when elements added */ public void testEmptyFull() { - BlockingQueue q = populatedQueue(0, 2, 2, false); + BlockingQueue q = populatedQueue(0, 2, 2, false); assertTrue(q.isEmpty()); - assertEquals(2, q.remainingCapacity()); + mustEqual(2, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); assertTrue(q.offer(two)); assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); assertFalse(q.offer(three)); } @@ -229,18 +225,18 @@ public void testEmptyFull() { */ public void testRemainingCapacity() { int size = ThreadLocalRandom.current().nextInt(1, SIZE); - BlockingQueue q = populatedQueue(size, size, 2 * size, false); + BlockingQueue q = populatedQueue(size, size, 2 * size, false); int spare = q.remainingCapacity(); int capacity = spare + size; for (int i = 0; i < size; i++) { - assertEquals(spare + i, q.remainingCapacity()); - assertEquals(capacity, q.size() + q.remainingCapacity()); - assertEquals(i, q.remove()); + mustEqual(spare + i, q.remainingCapacity()); + mustEqual(capacity, q.size() + q.remainingCapacity()); + mustEqual(i, q.remove()); } for (int i = 0; i < size; i++) { - assertEquals(capacity - i, q.remainingCapacity()); - assertEquals(capacity, q.size() + q.remainingCapacity()); - assertTrue(q.add(i)); + mustEqual(capacity - i, q.remainingCapacity()); + mustEqual(capacity, q.size() + q.remainingCapacity()); + mustAdd(q, i); } } @@ -248,7 +244,7 @@ public void testRemainingCapacity() { * Offer succeeds if not full; fails if full */ public void testOffer() { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(1); assertTrue(q.offer(zero)); assertFalse(q.offer(one)); } @@ -257,11 +253,11 @@ public void testOffer() { * add succeeds if not full; throws IllegalStateException if full */ public void testAdd() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - for (int i = 0; i < SIZE; i++) assertTrue(q.add((Integer) i)); - assertEquals(0, q.remainingCapacity()); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); + for (int i = 0; i < SIZE; i++) assertTrue(q.add(itemFor(i))); + mustEqual(0, q.remainingCapacity()); try { - q.add((Integer) SIZE); + q.add(itemFor(SIZE)); shouldThrow(); } catch (IllegalStateException success) {} } @@ -270,7 +266,7 @@ public void testAdd() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -282,12 +278,10 @@ public void testAddAllSelf() { * possibly adding some elements */ public void testAddAll3() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -297,15 +291,15 @@ public void testAddAll3() { */ public void testAddAll_insufficientSpace() { int size = ThreadLocalRandom.current().nextInt(1, SIZE); - ArrayBlockingQueue q = populatedQueue(0, size, size, false); + ArrayBlockingQueue q = populatedQueue(0, size, size, false); // Just fits: q.addAll(populatedQueue(size, size, 2 * size, false)); - assertEquals(0, q.remainingCapacity()); - assertEquals(size, q.size()); - assertEquals(0, q.peek()); + mustEqual(0, q.remainingCapacity()); + mustEqual(size, q.size()); + mustEqual(0, q.peek()); try { q = populatedQueue(0, size, size, false); - q.addAll(Collections.nCopies(size + 1, 42)); + q.addAll(Collections.nCopies(size + 1, fortytwo)); shouldThrow(); } catch (IllegalStateException success) {} } @@ -314,53 +308,51 @@ public void testAddAll_insufficientSpace() { * Queue contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * all elements successfully put are contained */ public void testPut() throws InterruptedException { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.put(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * put blocks interruptibly if full */ public void testBlockingPut() throws InterruptedException { - final ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) - q.put(i); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + q.put(itemFor(i)); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -370,8 +362,8 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); } /** @@ -379,66 +371,66 @@ public void realRun() throws InterruptedException { */ public void testPutWithTake() throws InterruptedException { final int capacity = 2; - final ArrayBlockingQueue q = new ArrayBlockingQueue(capacity); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < capacity; i++) - q.put(i); + q.put(itemFor(i)); pleaseTake.countDown(); - q.put(86); + q.put(eightysix); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); - assertEquals(0, q.take()); + mustEqual(0, q.remainingCapacity()); + mustEqual(0, q.take()); await(pleaseInterrupt); if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * timed offer times out if full and elements not taken */ public void testTimedOffer() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Object()); - q.put(new Object()); + q.put(one); + q.put(two); long startTime = System.nanoTime(); - assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offer(zero, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offer(new Object(), randomTimeout(), randomTimeUnit()); + q.offer(three, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.offer(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offer(four, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -454,9 +446,9 @@ public void realRun() throws InterruptedException { * take retrieves elements in FIFO order */ public void testTake() throws InterruptedException { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.take()); + mustEqual(i, q.take()); } } @@ -464,11 +456,11 @@ public void testTake() throws InterruptedException { * Take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final ArrayBlockingQueue q = populatedQueue(SIZE); + final ArrayBlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.take()); Thread.currentThread().interrupt(); try { @@ -495,9 +487,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -506,9 +498,9 @@ public void testPoll() { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll(0, MILLISECONDS)); + mustEqual(i, q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); checkEmpty(q); @@ -518,10 +510,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -535,12 +527,12 @@ public void testTimedPoll() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -568,10 +560,10 @@ public void realRun() throws InterruptedException { * peek returns next element, or null if empty */ public void testPeek() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -582,10 +574,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -597,9 +589,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -612,12 +604,12 @@ public void testRemove() { */ public void testContains() { int size = ThreadLocalRandom.current().nextInt(1, SIZE); - ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); + ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); assertFalse(q.contains(null)); for (int i = 0; i < size; ++i) { - assertTrue(q.contains(new Integer(i))); - assertEquals(i, q.poll()); - assertFalse(q.contains(new Integer(i))); + mustContain(q, i); + mustEqual(i, q.poll()); + mustNotContain(q, i); } } @@ -626,15 +618,15 @@ public void testContains() { */ public void testClear() { int size = ThreadLocalRandom.current().nextInt(1, 5); - ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); + ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); int capacity = size + q.remainingCapacity(); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(capacity, q.remainingCapacity()); + mustEqual(0, q.size()); + mustEqual(capacity, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); + mustContain(q, one); q.clear(); assertTrue(q.isEmpty()); } @@ -643,12 +635,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue p = new ArrayBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -657,8 +649,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -667,7 +659,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -677,45 +669,45 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = populatedQueue(i); + ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + Item x = p.remove(); + mustNotContain(q, x); } } } - void checkToArray(ArrayBlockingQueue q) { + void checkToArray(ArrayBlockingQueue q) { int size = q.size(); Object[] a1 = q.toArray(); - assertEquals(size, a1.length); - Integer[] a2 = q.toArray(new Integer[0]); - assertEquals(size, a2.length); - Integer[] a3 = q.toArray(new Integer[Math.max(0, size - 1)]); - assertEquals(size, a3.length); - Integer[] a4 = new Integer[size]; + mustEqual(size, a1.length); + Item[] a2 = q.toArray(new Item[0]); + mustEqual(size, a2.length); + Item[] a3 = q.toArray(new Item[Math.max(0, size - 1)]); + mustEqual(size, a3.length); + Item[] a4 = new Item[size]; assertSame(a4, q.toArray(a4)); - Integer[] a5 = new Integer[size + 1]; - Arrays.fill(a5, 42); + Item[] a5 = new Item[size + 1]; + Arrays.fill(a5, fortytwo); assertSame(a5, q.toArray(a5)); - Integer[] a6 = new Integer[size + 2]; - Arrays.fill(a6, 42); + Item[] a6 = new Item[size + 2]; + Arrays.fill(a6, fortytwo); assertSame(a6, q.toArray(a6)); Object[][] as = { a1, a2, a3, a4, a5, a6 }; for (Object[] a : as) { if (a.length > size) assertNull(a[size]); - if (a.length > size + 1) assertEquals(42, a[size + 1]); + if (a.length > size + 1) mustEqual(fortytwo, a[size + 1]); } - Iterator it = q.iterator(); - Integer s = q.peek(); + Iterator it = q.iterator(); + Item s = q.peek(); for (int i = 0; i < size; i++) { - Integer x = (Integer) it.next(); - assertEquals(s + i, (int) x); + Item x = (Item) it.next(); + mustEqual(s.value + i, x); for (Object[] a : as) - assertSame(a1[i], x); + mustEqual(a[i], x); } } @@ -726,29 +718,30 @@ public void testToArray() { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final int size = rnd.nextInt(6); final int capacity = Math.max(1, size + rnd.nextInt(size + 1)); - ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); for (int i = 0; i < size; i++) { checkToArray(q); - q.add(i); + mustAdd(q, i); } // Provoke wraparound int added = size * 2; for (int i = 0; i < added; i++) { checkToArray(q); - assertEquals((Integer) i, q.poll()); - q.add(size + i); + mustEqual(i, q.poll()); + q.add(new Item(size + i)); } for (int i = 0; i < size; i++) { checkToArray(q); - assertEquals((Integer) (added + i), q.poll()); + mustEqual((added + i), q.poll()); } } /** * toArray(incompatible array type) throws ArrayStoreException */ + @SuppressWarnings("CollectionToArraySafeParameter") public void testToArray_incompatibleArrayType() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -763,18 +756,18 @@ public void testToArray_incompatibleArrayType() { * iterator iterates through all elements */ public void testIterator() throws InterruptedException { - ArrayBlockingQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + ArrayBlockingQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); it = q.iterator(); for (i = 0; it.hasNext(); i++) - assertEquals(it.next(), q.take()); - assertEquals(i, SIZE); + mustEqual(it.next(), q.take()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -782,19 +775,19 @@ public void testIterator() throws InterruptedException { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new ArrayBlockingQueue(SIZE).iterator()); + assertIteratorExhausted(new ArrayBlockingQueue<>(SIZE).iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(two); q.add(one); q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); @@ -808,7 +801,7 @@ public void testIteratorRemove() { * iterator ordering is FIFO */ public void testIteratorOrdering() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); @@ -816,32 +809,32 @@ public void testIteratorOrdering() { assertEquals("queue should be full", 0, q.remainingCapacity()); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals(0, q.size()); + mustEqual(0, q.size()); } /** * toString contains toStrings of elements */ public void testToString() { - ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayBlockingQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -852,7 +845,7 @@ public void testToString() { * offer transfers elements across Executor tasks */ public void testOfferInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); q.add(one); q.add(two); final CheckedBarrier threadsStarted = new CheckedBarrier(2); @@ -863,13 +856,13 @@ public void realRun() throws InterruptedException { assertFalse(q.offer(three)); threadsStarted.await(); assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); }}); executor.execute(new CheckedRunnable() { public void realRun() throws InterruptedException { threadsStarted.await(); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); assertSame(one, q.take()); }}); } @@ -879,7 +872,7 @@ public void realRun() throws InterruptedException { * timed poll retrieves elements across Executor threads */ public void testPollInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -903,16 +896,16 @@ public void realRun() throws InterruptedException { * A deserialized/reserialized queue has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -921,42 +914,42 @@ public void testSerialization() throws Exception { * drainTo(c) empties queue into another collection c */ public void testDrainTo() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); + ArrayBlockingQueue q = populatedQueue(SIZE); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(SIZE, l.size()); + mustEqual(0, q.size()); + mustEqual(SIZE, l.size()); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); q.add(zero); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); + mustContain(q, zero); + mustContain(q, one); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); } /** * drainTo empties full queue, unblocking a waiting put. */ public void testDrainToWithActivePut() throws InterruptedException { - final ArrayBlockingQueue q = populatedQueue(SIZE); + final ArrayBlockingQueue q = populatedQueue(SIZE); Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Integer(SIZE + 1)); + q.put(new Item(SIZE + 1)); }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); t.join(); assertTrue(q.size() + l.size() >= SIZE); } @@ -965,17 +958,17 @@ public void realRun() throws InterruptedException { * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE * 2); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE * 2); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); + mustOffer(q, j); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(k, l.size()); - assertEquals(SIZE - k, q.size()); + mustEqual(k, l.size()); + mustEqual(SIZE - k, q.size()); for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); + mustEqual(l.get(j), j); do {} while (q.poll() != null); } } diff --git a/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java b/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java index 829a90c6727..eb606b0c781 100644 --- a/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java +++ b/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java @@ -52,23 +52,23 @@ public static Test suite() { */ public void testSpliterator_getComparator() { assertThrows(IllegalStateException.class, - () -> new ArrayDeque().spliterator().getComparator()); + () -> new ArrayDeque().spliterator().getComparator()); } /** * Spliterator characteristics are as advertised */ public void testSpliterator_characteristics() { - ArrayDeque q = new ArrayDeque(); - Spliterator s = q.spliterator(); + ArrayDeque q = new ArrayDeque<>(); + Spliterator s = q.spliterator(); int characteristics = s.characteristics(); int required = Spliterator.NONNULL | Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; - assertEquals(required, characteristics & required); + mustEqual(required, characteristics & required); assertTrue(s.hasCharacteristics(required)); - assertEquals(0, characteristics + mustEqual(0, characteristics & (Spliterator.CONCURRENT | Spliterator.DISTINCT | Spliterator.IMMUTABLE @@ -85,32 +85,32 @@ public void testHugeCapacity() { && Runtime.getRuntime().maxMemory() > 24L * (1 << 30))) return; - final Integer e = 42; + final Item e = fortytwo; final int maxArraySize = Integer.MAX_VALUE - 8; assertThrows(OutOfMemoryError.class, - () -> new ArrayDeque(Integer.MAX_VALUE)); + () -> new ArrayDeque(Integer.MAX_VALUE)); { - ArrayDeque q = new ArrayDeque(maxArraySize - 1); - assertEquals(0, q.size()); + ArrayDeque q = new ArrayDeque<>(maxArraySize - 1); + mustEqual(0, q.size()); assertTrue(q.isEmpty()); q = null; } { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.addAll(Collections.nCopies(maxArraySize - 3, e))); - assertEquals(e, q.peekFirst()); - assertEquals(e, q.peekLast()); - assertEquals(maxArraySize - 3, q.size()); - q.addFirst((Integer) 0); - q.addLast((Integer) 1); - assertEquals((Integer) 0, q.peekFirst()); - assertEquals((Integer) 1, q.peekLast()); - assertEquals(maxArraySize - 1, q.size()); + mustEqual(e, q.peekFirst()); + mustEqual(e, q.peekLast()); + mustEqual(maxArraySize - 3, q.size()); + q.addFirst(zero); + q.addLast(one); + mustEqual(zero, q.peekFirst()); + mustEqual(one, q.peekLast()); + mustEqual(maxArraySize - 1, q.size()); - ArrayDeque smallish = new ArrayDeque( + ArrayDeque smallish = new ArrayDeque<>( Collections.nCopies(Integer.MAX_VALUE - q.size() + 1, e)); assertThrows( IllegalStateException.class, diff --git a/test/jdk/java/util/concurrent/tck/ArrayDequeTest.java b/test/jdk/java/util/concurrent/tck/ArrayDequeTest.java index 88f70a50d9d..806cd6dc807 100644 --- a/test/jdk/java/util/concurrent/tck/ArrayDequeTest.java +++ b/test/jdk/java/util/concurrent/tck/ArrayDequeTest.java @@ -53,7 +53,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return ArrayDeque.class; } public Collection emptyCollection() { return populatedDeque(0); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return false; } } @@ -63,30 +63,30 @@ class Implementation implements CollectionImplementation { /** * Returns a new deque of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static ArrayDeque populatedDeque(int n) { + private static ArrayDeque populatedDeque(int n) { // Randomize various aspects of memory layout, including // capacity slop and wraparound. - final ArrayDeque q; + final ArrayDeque q; ThreadLocalRandom rnd = ThreadLocalRandom.current(); switch (rnd.nextInt(6)) { - case 0: q = new ArrayDeque(); break; - case 1: q = new ArrayDeque(0); break; - case 2: q = new ArrayDeque(1); break; - case 3: q = new ArrayDeque(Math.max(0, n - 1)); break; - case 4: q = new ArrayDeque(n); break; - case 5: q = new ArrayDeque(n + 1); break; + case 0: q = new ArrayDeque<>(); break; + case 1: q = new ArrayDeque<>(0); break; + case 2: q = new ArrayDeque<>(1); break; + case 3: q = new ArrayDeque<>(Math.max(0, n - 1)); break; + case 4: q = new ArrayDeque<>(n); break; + case 5: q = new ArrayDeque<>(n + 1); break; default: throw new AssertionError(); } switch (rnd.nextInt(3)) { case 0: - q.addFirst(42); - assertEquals((Integer) 42, q.removeLast()); + q.addFirst(fortytwo); + mustEqual(42, q.removeLast()); break; case 1: - q.addLast(42); - assertEquals((Integer) 42, q.removeFirst()); + q.addLast(fortytwo); + mustEqual(42, q.removeFirst()); break; case 2: /* do nothing */ break; default: throw new AssertionError(); @@ -94,15 +94,15 @@ private static ArrayDeque populatedDeque(int n) { assertTrue(q.isEmpty()); if (rnd.nextBoolean()) for (int i = 0; i < n; i++) - assertTrue(q.offerLast((Integer) i)); + assertTrue(q.offerLast(itemFor(i))); else for (int i = n; --i >= 0; ) - q.addFirst((Integer) i); - assertEquals(n, q.size()); + q.addFirst(itemFor(i)); + mustEqual(n, q.size()); if (n > 0) { assertFalse(q.isEmpty()); - assertEquals((Integer) 0, q.peekFirst()); - assertEquals((Integer) (n - 1), q.peekLast()); + mustEqual(0, q.peekFirst()); + mustEqual((n - 1), q.peekLast()); } return q; } @@ -111,7 +111,7 @@ private static ArrayDeque populatedDeque(int n) { * new deque is empty */ public void testConstructor1() { - assertEquals(0, new ArrayDeque().size()); + mustEqual(0, new ArrayDeque().size()); } /** @@ -119,7 +119,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new ArrayDeque((Collection)null); + new ArrayDeque((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -129,7 +129,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new ArrayDeque(Arrays.asList(new Integer[SIZE])); + new ArrayDeque(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -138,11 +138,9 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; items[0] = zero; try { - new ArrayDeque(Arrays.asList(ints)); + new ArrayDeque(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -151,23 +149,21 @@ public void testConstructor5() { * Deque contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + ArrayDeque q = new ArrayDeque<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayDeque q = new ArrayDeque(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + q.add(one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + q.add(two); q.removeFirst(); q.removeFirst(); assertTrue(q.isEmpty()); @@ -177,14 +173,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.removeFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -192,7 +188,7 @@ public void testSize() { * push(null) throws NPE */ public void testPushNull() { - ArrayDeque q = new ArrayDeque(1); + ArrayDeque q = new ArrayDeque<>(1); try { q.push(null); shouldThrow(); @@ -203,7 +199,7 @@ public void testPushNull() { * peekFirst() returns element inserted with push */ public void testPush() { - ArrayDeque q = populatedDeque(3); + ArrayDeque q = populatedDeque(3); q.pollLast(); q.push(four); assertSame(four, q.peekFirst()); @@ -213,9 +209,9 @@ public void testPush() { * pop() removes next element, or throws NSEE if empty */ public void testPop() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pop()); + mustEqual(i, q.pop()); } try { q.pop(); @@ -227,7 +223,7 @@ public void testPop() { * offer(null) throws NPE */ public void testOfferNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.offer(null); shouldThrow(); @@ -238,7 +234,7 @@ public void testOfferNull() { * offerFirst(null) throws NPE */ public void testOfferFirstNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.offerFirst(null); shouldThrow(); @@ -249,7 +245,7 @@ public void testOfferFirstNull() { * offerLast(null) throws NPE */ public void testOfferLastNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.offerLast(null); shouldThrow(); @@ -260,7 +256,7 @@ public void testOfferLastNull() { * offer(x) succeeds */ public void testOffer() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); assertSame(zero, q.peekFirst()); @@ -271,7 +267,7 @@ public void testOffer() { * offerFirst(x) succeeds */ public void testOfferFirst() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.offerFirst(zero)); assertTrue(q.offerFirst(one)); assertSame(one, q.peekFirst()); @@ -282,7 +278,7 @@ public void testOfferFirst() { * offerLast(x) succeeds */ public void testOfferLast() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.offerLast(zero)); assertTrue(q.offerLast(one)); assertSame(zero, q.peekFirst()); @@ -293,7 +289,7 @@ public void testOfferLast() { * add(null) throws NPE */ public void testAddNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.add(null); shouldThrow(); @@ -304,7 +300,7 @@ public void testAddNull() { * addFirst(null) throws NPE */ public void testAddFirstNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.addFirst(null); shouldThrow(); @@ -315,7 +311,7 @@ public void testAddFirstNull() { * addLast(null) throws NPE */ public void testAddLastNull() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.addLast(null); shouldThrow(); @@ -326,7 +322,7 @@ public void testAddLastNull() { * add(x) succeeds */ public void testAdd() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); assertTrue(q.add(zero)); assertTrue(q.add(one)); assertSame(zero, q.peekFirst()); @@ -337,7 +333,7 @@ public void testAdd() { * addFirst(x) succeeds */ public void testAddFirst() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); q.addFirst(zero); q.addFirst(one); assertSame(one, q.peekFirst()); @@ -348,7 +344,7 @@ public void testAddFirst() { * addLast(x) succeeds */ public void testAddLast() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); q.addLast(zero); q.addLast(one); assertSame(zero, q.peekFirst()); @@ -359,7 +355,7 @@ public void testAddLast() { * addAll(null) throws NPE */ public void testAddAll1() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { q.addAll(null); shouldThrow(); @@ -370,9 +366,9 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - ArrayDeque q = new ArrayDeque(); + ArrayDeque q = new ArrayDeque<>(); try { - q.addAll(Arrays.asList(new Integer[SIZE])); + q.addAll(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -382,12 +378,10 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - ArrayDeque q = new ArrayDeque(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + ArrayDeque q = new ArrayDeque<>(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -396,24 +390,22 @@ public void testAddAll3() { * Deque contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayDeque q = new ArrayDeque(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + ArrayDeque q = new ArrayDeque<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** * pollFirst() succeeds unless empty */ public void testPollFirst() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -422,9 +414,9 @@ public void testPollFirst() { * pollLast() succeeds unless empty */ public void testPollLast() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollLast()); } @@ -433,9 +425,9 @@ public void testPollLast() { * poll() succeeds unless empty */ public void testPoll() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -444,9 +436,9 @@ public void testPoll() { * remove() removes next element, or throws NSEE if empty */ public void testRemove() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -458,19 +450,19 @@ public void testRemove() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -479,10 +471,10 @@ public void testRemoveElement() { * peekFirst() returns next element, or null if empty */ public void testPeekFirst() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peekFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.peekFirst()); + mustEqual(i, q.pollFirst()); assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i)); } @@ -493,10 +485,10 @@ public void testPeekFirst() { * peek() returns next element, or null if empty */ public void testPeek() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -507,10 +499,10 @@ public void testPeek() { * peekLast() returns next element, or null if empty */ public void testPeekLast() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.peekLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.peekLast()); + mustEqual(i, q.pollLast()); assertTrue(q.peekLast() == null || !q.peekLast().equals(i)); } @@ -521,10 +513,10 @@ public void testPeekLast() { * element() returns first element, or throws NSEE if empty */ public void testElement() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -536,10 +528,10 @@ public void testElement() { * getFirst() returns first element, or throws NSEE if empty */ public void testFirstElement() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.getFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.getFirst()); + mustEqual(i, q.pollFirst()); } try { q.getFirst(); @@ -551,10 +543,10 @@ public void testFirstElement() { * getLast() returns last element, or throws NSEE if empty */ public void testLastElement() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.getLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.getLast()); + mustEqual(i, q.pollLast()); } try { q.getLast(); @@ -567,9 +559,9 @@ public void testLastElement() { * removeFirst() removes first element, or throws NSEE if empty */ public void testRemoveFirst() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.removeFirst()); + mustEqual(i, q.removeFirst()); } try { q.removeFirst(); @@ -582,9 +574,9 @@ public void testRemoveFirst() { * removeLast() removes last element, or throws NSEE if empty */ public void testRemoveLast() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.removeLast()); + mustEqual(i, q.removeLast()); } try { q.removeLast(); @@ -597,59 +589,59 @@ public void testRemoveLast() { * removeFirstOccurrence(x) removes x and returns true if present */ public void testRemoveFirstOccurrence() { - Deque q = populatedDeque(SIZE); + Deque q = populatedDeque(SIZE); assertFalse(q.removeFirstOccurrence(null)); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(i)); - assertFalse(q.contains(i)); + assertTrue(q.removeFirstOccurrence(itemFor(i))); + mustNotContain(q, i); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(i)); - assertFalse(q.removeFirstOccurrence(i + 1)); - assertFalse(q.contains(i)); - assertFalse(q.contains(i + 1)); + assertTrue(q.removeFirstOccurrence(itemFor(i))); + assertFalse(q.removeFirstOccurrence(itemFor(i + 1))); + mustNotContain(q, i); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); assertFalse(q.removeFirstOccurrence(null)); - assertFalse(q.removeFirstOccurrence(42)); - q = new ArrayDeque(); + assertFalse(q.removeFirstOccurrence(fortytwo)); + q = new ArrayDeque<>(); assertFalse(q.removeFirstOccurrence(null)); - assertFalse(q.removeFirstOccurrence(42)); + assertFalse(q.removeFirstOccurrence(fortytwo)); } /** * removeLastOccurrence(x) removes x and returns true if present */ public void testRemoveLastOccurrence() { - Deque q = populatedDeque(SIZE); + Deque q = populatedDeque(SIZE); assertFalse(q.removeLastOccurrence(null)); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(i)); - assertFalse(q.contains(i)); + assertTrue(q.removeLastOccurrence(itemFor(i))); + mustNotContain(q, i); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(i)); - assertFalse(q.removeLastOccurrence(i + 1)); - assertFalse(q.contains(i)); - assertFalse(q.contains(i + 1)); + assertTrue(q.removeLastOccurrence(itemFor(i))); + assertFalse(q.removeLastOccurrence(itemFor(i + 1))); + mustNotContain(q, i); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); assertFalse(q.removeLastOccurrence(null)); - assertFalse(q.removeLastOccurrence(42)); - q = new ArrayDeque(); + assertFalse(q.removeLastOccurrence(fortytwo)); + q = new ArrayDeque<>(); assertFalse(q.removeLastOccurrence(null)); - assertFalse(q.removeLastOccurrence(42)); + assertFalse(q.removeLastOccurrence(fortytwo)); } /** * contains(x) reports true when elements added but not yet removed */ public void testContains() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - assertEquals(i, q.pollFirst()); - assertFalse(q.contains(new Integer(i))); + mustContain(q, i); + mustEqual(i, q.pollFirst()); + mustNotContain(q, i); } } @@ -657,11 +649,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertTrue(q.add(new Integer(1))); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -671,12 +663,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - ArrayDeque q = populatedDeque(SIZE); - ArrayDeque p = new ArrayDeque(); + ArrayDeque q = populatedDeque(SIZE); + ArrayDeque p = new ArrayDeque<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - assertTrue(p.add(new Integer(i))); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -685,13 +677,13 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - ArrayDeque q = populatedDeque(SIZE); - ArrayDeque p = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); + ArrayDeque p = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); - assertEquals(changed, (i > 0)); + mustEqual(changed, (i > 0)); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.removeFirst(); } } @@ -701,44 +693,44 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - ArrayDeque q = populatedDeque(SIZE); - ArrayDeque p = populatedDeque(i); + ArrayDeque q = populatedDeque(SIZE); + ArrayDeque p = populatedDeque(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - assertFalse(q.contains(p.removeFirst())); + mustNotContain(q, p.removeFirst()); } } } - void checkToArray(ArrayDeque q) { + void checkToArray(ArrayDeque q) { int size = q.size(); Object[] a1 = q.toArray(); - assertEquals(size, a1.length); - Integer[] a2 = q.toArray(new Integer[0]); - assertEquals(size, a2.length); - Integer[] a3 = q.toArray(new Integer[Math.max(0, size - 1)]); - assertEquals(size, a3.length); - Integer[] a4 = new Integer[size]; + mustEqual(size, a1.length); + Item[] a2 = q.toArray(new Item[0]); + mustEqual(size, a2.length); + Item[] a3 = q.toArray(new Item[Math.max(0, size - 1)]); + mustEqual(size, a3.length); + Item[] a4 = new Item[size]; assertSame(a4, q.toArray(a4)); - Integer[] a5 = new Integer[size + 1]; - Arrays.fill(a5, 42); + Item[] a5 = new Item[size + 1]; + Arrays.fill(a5, fortytwo); assertSame(a5, q.toArray(a5)); - Integer[] a6 = new Integer[size + 2]; - Arrays.fill(a6, 42); + Item[] a6 = new Item[size + 2]; + Arrays.fill(a6, fortytwo); assertSame(a6, q.toArray(a6)); Object[][] as = { a1, a2, a3, a4, a5, a6 }; for (Object[] a : as) { if (a.length > size) assertNull(a[size]); - if (a.length > size + 1) assertEquals(42, a[size + 1]); + if (a.length > size + 1) mustEqual(fortytwo, a[size + 1]); } - Iterator it = q.iterator(); - Integer s = q.peekFirst(); + Iterator it = q.iterator(); + Item s = q.peekFirst(); for (int i = 0; i < size; i++) { - Integer x = (Integer) it.next(); - assertEquals(s + i, (int) x); + Item x = (Item) it.next(); + mustEqual(s.value + i, x); for (Object[] a : as) - assertSame(a1[i], x); + assertSame(a[i], x); } } @@ -747,21 +739,21 @@ void checkToArray(ArrayDeque q) { */ public void testToArray() { final int size = ThreadLocalRandom.current().nextInt(10); - ArrayDeque q = new ArrayDeque<>(size); + ArrayDeque q = new ArrayDeque<>(size); for (int i = 0; i < size; i++) { checkToArray(q); - q.addLast(i); + q.addLast(itemFor(i)); } // Provoke wraparound int added = size * 2; for (int i = 0; i < added; i++) { checkToArray(q); - assertEquals((Integer) i, q.poll()); - q.addLast(size + i); + mustEqual(i, q.poll()); + q.addLast(itemFor(size + i)); } for (int i = 0; i < size; i++) { checkToArray(q); - assertEquals((Integer) (added + i), q.poll()); + mustEqual((added + i), q.poll()); } } @@ -769,8 +761,8 @@ public void testToArray() { * toArray(null) throws NullPointerException */ public void testToArray_NullArg() { - ArrayDeque l = new ArrayDeque(); - l.add(new Object()); + ArrayDeque l = new ArrayDeque<>(); + l.add(zero); try { l.toArray((Object[])null); shouldThrow(); @@ -780,9 +772,10 @@ public void testToArray_NullArg() { /** * toArray(incompatible array type) throws ArrayStoreException */ + @SuppressWarnings("CollectionToArraySafeParameter") public void testToArray_incompatibleArrayType() { - ArrayDeque l = new ArrayDeque(); - l.add(new Integer(5)); + ArrayDeque l = new ArrayDeque<>(); + l.add(five); try { l.toArray(new String[10]); shouldThrow(); @@ -797,12 +790,12 @@ public void testToArray_incompatibleArrayType() { * Iterator iterates through all elements */ public void testIterator() { - ArrayDeque q = populatedDeque(SIZE); - Iterator it = q.iterator(); + ArrayDeque q = populatedDeque(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -810,7 +803,7 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - Deque c = new ArrayDeque(); + Deque c = new ArrayDeque<>(); assertIteratorExhausted(c.iterator()); assertIteratorExhausted(c.descendingIterator()); } @@ -819,39 +812,39 @@ public void testEmptyIterator() { * Iterator ordering is FIFO */ public void testIteratorOrdering() { - final ArrayDeque q = new ArrayDeque(); + final ArrayDeque q = new ArrayDeque<>(); q.add(one); q.add(two); q.add(three); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * iterator.remove() removes current element */ public void testIteratorRemove() { - final ArrayDeque q = new ArrayDeque(); + final ArrayDeque q = new ArrayDeque<>(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = 1; j <= max; ++j) - q.add(new Integer(j)); - Iterator it = q.iterator(); + mustAdd(q, j); + Iterator it = q.iterator(); for (int j = 1; j <= split; ++j) - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); - assertEquals(it.next(), new Integer(split + 1)); + mustEqual(it.next(), split + 1); for (int j = 1; j <= split; ++j) - q.remove(new Integer(j)); + q.remove(itemFor(j)); it = q.iterator(); for (int j = split + 1; j <= max; ++j) { - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); } assertFalse(it.hasNext()); @@ -863,14 +856,14 @@ public void testIteratorRemove() { * Descending iterator iterates through all elements */ public void testDescendingIterator() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); int i = 0; - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertFalse(it.hasNext()); try { it.next(); @@ -882,17 +875,17 @@ public void testDescendingIterator() { * Descending iterator ordering is reverse FIFO */ public void testDescendingIteratorOrdering() { - final ArrayDeque q = new ArrayDeque(); + final ArrayDeque q = new ArrayDeque<>(); for (int iters = 0; iters < 100; ++iters) { - q.add(new Integer(3)); - q.add(new Integer(2)); - q.add(new Integer(1)); + q.add(three); + q.add(two); + q.add(one); int k = 0; - for (Iterator it = q.descendingIterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.descendingIterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); q.remove(); q.remove(); q.remove(); @@ -903,23 +896,23 @@ public void testDescendingIteratorOrdering() { * descendingIterator.remove() removes current element */ public void testDescendingIteratorRemove() { - final ArrayDeque q = new ArrayDeque(); + final ArrayDeque q = new ArrayDeque<>(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = max; j >= 1; --j) - q.add(new Integer(j)); - Iterator it = q.descendingIterator(); + q.add(itemFor(j)); + Iterator it = q.descendingIterator(); for (int j = 1; j <= split; ++j) - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), itemFor(j)); it.remove(); - assertEquals(it.next(), new Integer(split + 1)); + mustEqual(it.next(), itemFor(split + 1)); for (int j = 1; j <= split; ++j) - q.remove(new Integer(j)); + q.remove(itemFor(j)); it = q.descendingIterator(); for (int j = split + 1; j <= max; ++j) { - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); } assertFalse(it.hasNext()); @@ -931,7 +924,7 @@ public void testDescendingIteratorRemove() { * toString() contains toStrings of elements */ public void testToString() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -942,17 +935,17 @@ public void testToString() { * A deserialized/reserialized deque has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedDeque(SIZE); - Queue y = serialClone(x); + Queue x = populatedDeque(SIZE); + Queue y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(Arrays.toString(x.toArray()), Arrays.toString(y.toArray())); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(Arrays.toString(x.toArray()), Arrays.toString(y.toArray())); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -961,16 +954,16 @@ public void testSerialization() throws Exception { * A cloned deque has same elements in same order */ public void testClone() throws Exception { - ArrayDeque x = populatedDeque(SIZE); - ArrayDeque y = x.clone(); + ArrayDeque x = populatedDeque(SIZE); + ArrayDeque y = x.clone(); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -980,7 +973,7 @@ public void testClone() throws Exception { */ public void testNeverContainsNull() { Deque[] qs = { - new ArrayDeque(), + new ArrayDeque<>(), populatedDeque(2), }; diff --git a/test/jdk/java/util/concurrent/tck/ArrayListTest.java b/test/jdk/java/util/concurrent/tck/ArrayListTest.java index 203c04c6ea9..c56981116e1 100644 --- a/test/jdk/java/util/concurrent/tck/ArrayListTest.java +++ b/test/jdk/java/util/concurrent/tck/ArrayListTest.java @@ -47,7 +47,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return ArrayList.class; } public List emptyCollection() { return new ArrayList(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return true; } } @@ -57,7 +57,7 @@ public List emptyCollection() { } } return newTestSuite( - // ArrayListTest.class, + ArrayListTest.class, CollectionTest.testSuite(new Implementation()), CollectionTest.testSuite(new SubListImplementation())); } @@ -66,21 +66,22 @@ public List emptyCollection() { * A cloned list equals original */ public void testClone() throws Exception { - ArrayList x = new ArrayList<>(); - x.add(1); - x.add(2); - x.add(3); - ArrayList y = (ArrayList) x.clone(); + ArrayList x = new ArrayList<>(); + x.add(one); + x.add(two); + x.add(three); + @SuppressWarnings("unchecked") + ArrayList y = (ArrayList) x.clone(); assertNotSame(y, x); - assertEquals(x, y); - assertEquals(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(0), y.remove(0)); + mustEqual(x.remove(0), y.remove(0)); } assertTrue(y.isEmpty()); } diff --git a/test/jdk/java/util/concurrent/tck/Atomic8Test.java b/test/jdk/java/util/concurrent/tck/Atomic8Test.java index 0b3253992ed..c2a7029fde8 100644 --- a/test/jdk/java/util/concurrent/tck/Atomic8Test.java +++ b/test/jdk/java/util/concurrent/tck/Atomic8Test.java @@ -59,16 +59,16 @@ public static Test suite() { static long addLong17(long x) { return x + 17; } static int addInt17(int x) { return x + 17; } - static Integer addInteger17(Integer x) { - return x.intValue() + 17; + static Item addItem17(Item x) { + return new Item(x.intValue() + 17); } - static Integer sumInteger(Integer x, Integer y) { - return x.intValue() + y.intValue(); + static Item sumItem(Item x, Item y) { + return new Item(x.intValue() + y.intValue()); } volatile long aLongField; volatile int anIntField; - volatile Integer anIntegerField; + volatile Item anItemField; AtomicLongFieldUpdater aLongFieldUpdater() { return AtomicLongFieldUpdater.newUpdater @@ -80,9 +80,9 @@ AtomicIntegerFieldUpdater anIntFieldUpdater() { (Atomic8Test.class, "anIntField"); } - AtomicReferenceFieldUpdater anIntegerFieldUpdater() { + AtomicReferenceFieldUpdater anItemFieldUpdater() { return AtomicReferenceFieldUpdater.newUpdater - (Atomic8Test.class, Integer.class, "anIntegerField"); + (Atomic8Test.class, Item.class, "anItemField"); } /** @@ -91,9 +91,9 @@ AtomicReferenceFieldUpdater anIntegerFieldUpdater() { */ public void testLongGetAndUpdate() { AtomicLong a = new AtomicLong(1L); - assertEquals(1L, a.getAndUpdate(Atomic8Test::addLong17)); - assertEquals(18L, a.getAndUpdate(Atomic8Test::addLong17)); - assertEquals(35L, a.get()); + mustEqual(1L, a.getAndUpdate(Atomic8Test::addLong17)); + mustEqual(18L, a.getAndUpdate(Atomic8Test::addLong17)); + mustEqual(35L, a.get()); } /** @@ -102,8 +102,8 @@ public void testLongGetAndUpdate() { */ public void testLongUpdateAndGet() { AtomicLong a = new AtomicLong(1L); - assertEquals(18L, a.updateAndGet(Atomic8Test::addLong17)); - assertEquals(35L, a.updateAndGet(Atomic8Test::addLong17)); + mustEqual(18L, a.updateAndGet(Atomic8Test::addLong17)); + mustEqual(35L, a.updateAndGet(Atomic8Test::addLong17)); } /** @@ -112,9 +112,9 @@ public void testLongUpdateAndGet() { */ public void testLongGetAndAccumulate() { AtomicLong a = new AtomicLong(1L); - assertEquals(1L, a.getAndAccumulate(2L, Long::sum)); - assertEquals(3L, a.getAndAccumulate(3L, Long::sum)); - assertEquals(6L, a.get()); + mustEqual(1L, a.getAndAccumulate(2L, Long::sum)); + mustEqual(3L, a.getAndAccumulate(3L, Long::sum)); + mustEqual(6L, a.get()); } /** @@ -123,9 +123,9 @@ public void testLongGetAndAccumulate() { */ public void testLongAccumulateAndGet() { AtomicLong a = new AtomicLong(1L); - assertEquals(7L, a.accumulateAndGet(6L, Long::sum)); - assertEquals(10L, a.accumulateAndGet(3L, Long::sum)); - assertEquals(10L, a.get()); + mustEqual(7L, a.accumulateAndGet(6L, Long::sum)); + mustEqual(10L, a.accumulateAndGet(3L, Long::sum)); + mustEqual(10L, a.get()); } /** @@ -134,9 +134,9 @@ public void testLongAccumulateAndGet() { */ public void testIntGetAndUpdate() { AtomicInteger a = new AtomicInteger(1); - assertEquals(1, a.getAndUpdate(Atomic8Test::addInt17)); - assertEquals(18, a.getAndUpdate(Atomic8Test::addInt17)); - assertEquals(35, a.get()); + mustEqual(1, a.getAndUpdate(Atomic8Test::addInt17)); + mustEqual(18, a.getAndUpdate(Atomic8Test::addInt17)); + mustEqual(35, a.get()); } /** @@ -145,9 +145,9 @@ public void testIntGetAndUpdate() { */ public void testIntUpdateAndGet() { AtomicInteger a = new AtomicInteger(1); - assertEquals(18, a.updateAndGet(Atomic8Test::addInt17)); - assertEquals(35, a.updateAndGet(Atomic8Test::addInt17)); - assertEquals(35, a.get()); + mustEqual(18, a.updateAndGet(Atomic8Test::addInt17)); + mustEqual(35, a.updateAndGet(Atomic8Test::addInt17)); + mustEqual(35, a.get()); } /** @@ -156,9 +156,9 @@ public void testIntUpdateAndGet() { */ public void testIntGetAndAccumulate() { AtomicInteger a = new AtomicInteger(1); - assertEquals(1, a.getAndAccumulate(2, Integer::sum)); - assertEquals(3, a.getAndAccumulate(3, Integer::sum)); - assertEquals(6, a.get()); + mustEqual(1, a.getAndAccumulate(2, Integer::sum)); + mustEqual(3, a.getAndAccumulate(3, Integer::sum)); + mustEqual(6, a.get()); } /** @@ -167,9 +167,9 @@ public void testIntGetAndAccumulate() { */ public void testIntAccumulateAndGet() { AtomicInteger a = new AtomicInteger(1); - assertEquals(7, a.accumulateAndGet(6, Integer::sum)); - assertEquals(10, a.accumulateAndGet(3, Integer::sum)); - assertEquals(10, a.get()); + mustEqual(7, a.accumulateAndGet(6, Integer::sum)); + mustEqual(10, a.accumulateAndGet(3, Integer::sum)); + mustEqual(10, a.get()); } /** @@ -177,10 +177,10 @@ public void testIntAccumulateAndGet() { * result of supplied function */ public void testReferenceGetAndUpdate() { - AtomicReference a = new AtomicReference<>(one); - assertEquals((Integer) 1, a.getAndUpdate(Atomic8Test::addInteger17)); - assertEquals((Integer) 18, a.getAndUpdate(Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.get()); + AtomicReference a = new AtomicReference<>(one); + mustEqual(1, a.getAndUpdate(Atomic8Test::addItem17)); + mustEqual(18, a.getAndUpdate(Atomic8Test::addItem17)); + mustEqual(35, a.get()); } /** @@ -188,10 +188,10 @@ public void testReferenceGetAndUpdate() { * returns result. */ public void testReferenceUpdateAndGet() { - AtomicReference a = new AtomicReference<>(one); - assertEquals((Integer) 18, a.updateAndGet(Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.updateAndGet(Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.get()); + AtomicReference a = new AtomicReference<>(one); + mustEqual(18, a.updateAndGet(Atomic8Test::addItem17)); + mustEqual(35, a.updateAndGet(Atomic8Test::addItem17)); + mustEqual(35, a.get()); } /** @@ -199,10 +199,10 @@ public void testReferenceUpdateAndGet() { * with supplied function. */ public void testReferenceGetAndAccumulate() { - AtomicReference a = new AtomicReference<>(one); - assertEquals((Integer) 1, a.getAndAccumulate(2, Atomic8Test::sumInteger)); - assertEquals((Integer) 3, a.getAndAccumulate(3, Atomic8Test::sumInteger)); - assertEquals((Integer) 6, a.get()); + AtomicReference a = new AtomicReference<>(one); + mustEqual( 1, a.getAndAccumulate(two, Atomic8Test::sumItem)); + mustEqual( 3, a.getAndAccumulate(three, Atomic8Test::sumItem)); + mustEqual( 6, a.get()); } /** @@ -210,10 +210,10 @@ public void testReferenceGetAndAccumulate() { * returns result. */ public void testReferenceAccumulateAndGet() { - AtomicReference a = new AtomicReference<>(one); - assertEquals((Integer) 7, a.accumulateAndGet(6, Atomic8Test::sumInteger)); - assertEquals((Integer) 10, a.accumulateAndGet(3, Atomic8Test::sumInteger)); - assertEquals((Integer) 10, a.get()); + AtomicReference a = new AtomicReference<>(one); + mustEqual( 7, a.accumulateAndGet(six, Atomic8Test::sumItem)); + mustEqual( 10, a.accumulateAndGet(three, Atomic8Test::sumItem)); + mustEqual( 10, a.get()); } /** @@ -223,9 +223,9 @@ public void testReferenceAccumulateAndGet() { public void testLongArrayGetAndUpdate() { AtomicLongArray a = new AtomicLongArray(1); a.set(0, 1); - assertEquals(1L, a.getAndUpdate(0, Atomic8Test::addLong17)); - assertEquals(18L, a.getAndUpdate(0, Atomic8Test::addLong17)); - assertEquals(35L, a.get(0)); + mustEqual(1L, a.getAndUpdate(0, Atomic8Test::addLong17)); + mustEqual(18L, a.getAndUpdate(0, Atomic8Test::addLong17)); + mustEqual(35L, a.get(0)); } /** @@ -235,9 +235,9 @@ public void testLongArrayGetAndUpdate() { public void testLongArrayUpdateAndGet() { AtomicLongArray a = new AtomicLongArray(1); a.set(0, 1); - assertEquals(18L, a.updateAndGet(0, Atomic8Test::addLong17)); - assertEquals(35L, a.updateAndGet(0, Atomic8Test::addLong17)); - assertEquals(35L, a.get(0)); + mustEqual(18L, a.updateAndGet(0, Atomic8Test::addLong17)); + mustEqual(35L, a.updateAndGet(0, Atomic8Test::addLong17)); + mustEqual(35L, a.get(0)); } /** @@ -247,9 +247,9 @@ public void testLongArrayUpdateAndGet() { public void testLongArrayGetAndAccumulate() { AtomicLongArray a = new AtomicLongArray(1); a.set(0, 1); - assertEquals(1L, a.getAndAccumulate(0, 2L, Long::sum)); - assertEquals(3L, a.getAndAccumulate(0, 3L, Long::sum)); - assertEquals(6L, a.get(0)); + mustEqual(1L, a.getAndAccumulate(0, 2L, Long::sum)); + mustEqual(3L, a.getAndAccumulate(0, 3L, Long::sum)); + mustEqual(6L, a.get(0)); } /** @@ -259,9 +259,9 @@ public void testLongArrayGetAndAccumulate() { public void testLongArrayAccumulateAndGet() { AtomicLongArray a = new AtomicLongArray(1); a.set(0, 1); - assertEquals(7L, a.accumulateAndGet(0, 6L, Long::sum)); - assertEquals(10L, a.accumulateAndGet(0, 3L, Long::sum)); - assertEquals(10L, a.get(0)); + mustEqual(7L, a.accumulateAndGet(0, 6L, Long::sum)); + mustEqual(10L, a.accumulateAndGet(0, 3L, Long::sum)); + mustEqual(10L, a.get(0)); } /** @@ -271,9 +271,9 @@ public void testLongArrayAccumulateAndGet() { public void testIntArrayGetAndUpdate() { AtomicIntegerArray a = new AtomicIntegerArray(1); a.set(0, 1); - assertEquals(1, a.getAndUpdate(0, Atomic8Test::addInt17)); - assertEquals(18, a.getAndUpdate(0, Atomic8Test::addInt17)); - assertEquals(35, a.get(0)); + mustEqual(1, a.getAndUpdate(0, Atomic8Test::addInt17)); + mustEqual(18, a.getAndUpdate(0, Atomic8Test::addInt17)); + mustEqual(35, a.get(0)); } /** @@ -283,9 +283,9 @@ public void testIntArrayGetAndUpdate() { public void testIntArrayUpdateAndGet() { AtomicIntegerArray a = new AtomicIntegerArray(1); a.set(0, 1); - assertEquals(18, a.updateAndGet(0, Atomic8Test::addInt17)); - assertEquals(35, a.updateAndGet(0, Atomic8Test::addInt17)); - assertEquals(35, a.get(0)); + mustEqual(18, a.updateAndGet(0, Atomic8Test::addInt17)); + mustEqual(35, a.updateAndGet(0, Atomic8Test::addInt17)); + mustEqual(35, a.get(0)); } /** @@ -295,9 +295,9 @@ public void testIntArrayUpdateAndGet() { public void testIntArrayGetAndAccumulate() { AtomicIntegerArray a = new AtomicIntegerArray(1); a.set(0, 1); - assertEquals(1, a.getAndAccumulate(0, 2, Integer::sum)); - assertEquals(3, a.getAndAccumulate(0, 3, Integer::sum)); - assertEquals(6, a.get(0)); + mustEqual(1, a.getAndAccumulate(0, 2, Integer::sum)); + mustEqual(3, a.getAndAccumulate(0, 3, Integer::sum)); + mustEqual(6, a.get(0)); } /** @@ -307,8 +307,8 @@ public void testIntArrayGetAndAccumulate() { public void testIntArrayAccumulateAndGet() { AtomicIntegerArray a = new AtomicIntegerArray(1); a.set(0, 1); - assertEquals(7, a.accumulateAndGet(0, 6, Integer::sum)); - assertEquals(10, a.accumulateAndGet(0, 3, Integer::sum)); + mustEqual(7, a.accumulateAndGet(0, 6, Integer::sum)); + mustEqual(10, a.accumulateAndGet(0, 3, Integer::sum)); } /** @@ -316,11 +316,11 @@ public void testIntArrayAccumulateAndGet() { * result of supplied function */ public void testReferenceArrayGetAndUpdate() { - AtomicReferenceArray a = new AtomicReferenceArray<>(1); + AtomicReferenceArray a = new AtomicReferenceArray<>(1); a.set(0, one); - assertEquals((Integer) 1, a.getAndUpdate(0, Atomic8Test::addInteger17)); - assertEquals((Integer) 18, a.getAndUpdate(0, Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.get(0)); + mustEqual( 1, a.getAndUpdate(0, Atomic8Test::addItem17)); + mustEqual( 18, a.getAndUpdate(0, Atomic8Test::addItem17)); + mustEqual( 35, a.get(0)); } /** @@ -328,10 +328,10 @@ public void testReferenceArrayGetAndUpdate() { * returns result. */ public void testReferenceArrayUpdateAndGet() { - AtomicReferenceArray a = new AtomicReferenceArray<>(1); + AtomicReferenceArray a = new AtomicReferenceArray<>(1); a.set(0, one); - assertEquals((Integer) 18, a.updateAndGet(0, Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.updateAndGet(0, Atomic8Test::addInteger17)); + mustEqual( 18, a.updateAndGet(0, Atomic8Test::addItem17)); + mustEqual( 35, a.updateAndGet(0, Atomic8Test::addItem17)); } /** @@ -339,11 +339,11 @@ public void testReferenceArrayUpdateAndGet() { * with supplied function. */ public void testReferenceArrayGetAndAccumulate() { - AtomicReferenceArray a = new AtomicReferenceArray<>(1); + AtomicReferenceArray a = new AtomicReferenceArray<>(1); a.set(0, one); - assertEquals((Integer) 1, a.getAndAccumulate(0, 2, Atomic8Test::sumInteger)); - assertEquals((Integer) 3, a.getAndAccumulate(0, 3, Atomic8Test::sumInteger)); - assertEquals((Integer) 6, a.get(0)); + mustEqual( 1, a.getAndAccumulate(0, two, Atomic8Test::sumItem)); + mustEqual( 3, a.getAndAccumulate(0, three, Atomic8Test::sumItem)); + mustEqual( 6, a.get(0)); } /** @@ -351,10 +351,10 @@ public void testReferenceArrayGetAndAccumulate() { * returns result. */ public void testReferenceArrayAccumulateAndGet() { - AtomicReferenceArray a = new AtomicReferenceArray<>(1); + AtomicReferenceArray a = new AtomicReferenceArray<>(1); a.set(0, one); - assertEquals((Integer) 7, a.accumulateAndGet(0, 6, Atomic8Test::sumInteger)); - assertEquals((Integer) 10, a.accumulateAndGet(0, 3, Atomic8Test::sumInteger)); + mustEqual( 7, a.accumulateAndGet(0, six, Atomic8Test::sumItem)); + mustEqual( 10, a.accumulateAndGet(0, three, Atomic8Test::sumItem)); } /** @@ -362,12 +362,12 @@ public void testReferenceArrayAccumulateAndGet() { * result of supplied function */ public void testLongFieldUpdaterGetAndUpdate() { - AtomicLongFieldUpdater a = aLongFieldUpdater(); - a.set(this, 1); - assertEquals(1L, a.getAndUpdate(this, Atomic8Test::addLong17)); - assertEquals(18L, a.getAndUpdate(this, Atomic8Test::addLong17)); - assertEquals(35L, a.get(this)); - assertEquals(35L, aLongField); + AtomicLongFieldUpdater a = aLongFieldUpdater(); + a.set(this, 1L); + mustEqual(1L, a.getAndUpdate(this, Atomic8Test::addLong17)); + mustEqual(18L, a.getAndUpdate(this, Atomic8Test::addLong17)); + mustEqual(35L, a.get(this)); + mustEqual(35L, aLongField); } /** @@ -375,12 +375,12 @@ public void testLongFieldUpdaterGetAndUpdate() { * returns result. */ public void testLongFieldUpdaterUpdateAndGet() { - AtomicLongFieldUpdater a = aLongFieldUpdater(); - a.set(this, 1); - assertEquals(18L, a.updateAndGet(this, Atomic8Test::addLong17)); - assertEquals(35L, a.updateAndGet(this, Atomic8Test::addLong17)); - assertEquals(35L, a.get(this)); - assertEquals(35L, aLongField); + AtomicLongFieldUpdater a = aLongFieldUpdater(); + a.set(this, 1L); + mustEqual(18L, a.updateAndGet(this, Atomic8Test::addLong17)); + mustEqual(35L, a.updateAndGet(this, Atomic8Test::addLong17)); + mustEqual(35L, a.get(this)); + mustEqual(35L, aLongField); } /** @@ -388,12 +388,12 @@ public void testLongFieldUpdaterUpdateAndGet() { * and updates with supplied function. */ public void testLongFieldUpdaterGetAndAccumulate() { - AtomicLongFieldUpdater a = aLongFieldUpdater(); - a.set(this, 1); - assertEquals(1L, a.getAndAccumulate(this, 2L, Long::sum)); - assertEquals(3L, a.getAndAccumulate(this, 3L, Long::sum)); - assertEquals(6L, a.get(this)); - assertEquals(6L, aLongField); + AtomicLongFieldUpdater a = aLongFieldUpdater(); + a.set(this, 1L); + mustEqual(1L, a.getAndAccumulate(this, 2L, Long::sum)); + mustEqual(3L, a.getAndAccumulate(this, 3L, Long::sum)); + mustEqual(6L, a.get(this)); + mustEqual(6L, aLongField); } /** @@ -401,12 +401,12 @@ public void testLongFieldUpdaterGetAndAccumulate() { * function and returns result. */ public void testLongFieldUpdaterAccumulateAndGet() { - AtomicLongFieldUpdater a = aLongFieldUpdater(); - a.set(this, 1); - assertEquals(7L, a.accumulateAndGet(this, 6L, Long::sum)); - assertEquals(10L, a.accumulateAndGet(this, 3L, Long::sum)); - assertEquals(10L, a.get(this)); - assertEquals(10L, aLongField); + AtomicLongFieldUpdater a = aLongFieldUpdater(); + a.set(this, 1L); + mustEqual(7L, a.accumulateAndGet(this, 6L, Long::sum)); + mustEqual(10L, a.accumulateAndGet(this, 3L, Long::sum)); + mustEqual(10L, a.get(this)); + mustEqual(10L, aLongField); } /** @@ -414,12 +414,12 @@ public void testLongFieldUpdaterAccumulateAndGet() { * result of supplied function */ public void testIntegerFieldUpdaterGetAndUpdate() { - AtomicIntegerFieldUpdater a = anIntFieldUpdater(); + AtomicIntegerFieldUpdater a = anIntFieldUpdater(); a.set(this, 1); - assertEquals(1, a.getAndUpdate(this, Atomic8Test::addInt17)); - assertEquals(18, a.getAndUpdate(this, Atomic8Test::addInt17)); - assertEquals(35, a.get(this)); - assertEquals(35, anIntField); + mustEqual(1, a.getAndUpdate(this, Atomic8Test::addInt17)); + mustEqual(18, a.getAndUpdate(this, Atomic8Test::addInt17)); + mustEqual(35, a.get(this)); + mustEqual(35, anIntField); } /** @@ -427,12 +427,12 @@ public void testIntegerFieldUpdaterGetAndUpdate() { * returns result. */ public void testIntegerFieldUpdaterUpdateAndGet() { - AtomicIntegerFieldUpdater a = anIntFieldUpdater(); + AtomicIntegerFieldUpdater a = anIntFieldUpdater(); a.set(this, 1); - assertEquals(18, a.updateAndGet(this, Atomic8Test::addInt17)); - assertEquals(35, a.updateAndGet(this, Atomic8Test::addInt17)); - assertEquals(35, a.get(this)); - assertEquals(35, anIntField); + mustEqual(18, a.updateAndGet(this, Atomic8Test::addInt17)); + mustEqual(35, a.updateAndGet(this, Atomic8Test::addInt17)); + mustEqual(35, a.get(this)); + mustEqual(35, anIntField); } /** @@ -440,12 +440,12 @@ public void testIntegerFieldUpdaterUpdateAndGet() { * and updates with supplied function. */ public void testIntegerFieldUpdaterGetAndAccumulate() { - AtomicIntegerFieldUpdater a = anIntFieldUpdater(); + AtomicIntegerFieldUpdater a = anIntFieldUpdater(); a.set(this, 1); - assertEquals(1, a.getAndAccumulate(this, 2, Integer::sum)); - assertEquals(3, a.getAndAccumulate(this, 3, Integer::sum)); - assertEquals(6, a.get(this)); - assertEquals(6, anIntField); + mustEqual(1, a.getAndAccumulate(this, 2, Integer::sum)); + mustEqual(3, a.getAndAccumulate(this, 3, Integer::sum)); + mustEqual(6, a.get(this)); + mustEqual(6, anIntField); } /** @@ -453,12 +453,12 @@ public void testIntegerFieldUpdaterGetAndAccumulate() { * function and returns result. */ public void testIntegerFieldUpdaterAccumulateAndGet() { - AtomicIntegerFieldUpdater a = anIntFieldUpdater(); + AtomicIntegerFieldUpdater a = anIntFieldUpdater(); a.set(this, 1); - assertEquals(7, a.accumulateAndGet(this, 6, Integer::sum)); - assertEquals(10, a.accumulateAndGet(this, 3, Integer::sum)); - assertEquals(10, a.get(this)); - assertEquals(10, anIntField); + mustEqual(7, a.accumulateAndGet(this, 6, Integer::sum)); + mustEqual(10, a.accumulateAndGet(this, 3, Integer::sum)); + mustEqual(10, a.get(this)); + mustEqual(10, anIntField); } /** @@ -466,12 +466,12 @@ public void testIntegerFieldUpdaterAccumulateAndGet() { * and updates result of supplied function */ public void testReferenceFieldUpdaterGetAndUpdate() { - AtomicReferenceFieldUpdater a = anIntegerFieldUpdater(); + AtomicReferenceFieldUpdater a = anItemFieldUpdater(); a.set(this, one); - assertEquals((Integer) 1, a.getAndUpdate(this, Atomic8Test::addInteger17)); - assertEquals((Integer) 18, a.getAndUpdate(this, Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.get(this)); - assertEquals((Integer) 35, anIntegerField); + mustEqual( 1, a.getAndUpdate(this, Atomic8Test::addItem17)); + mustEqual( 18, a.getAndUpdate(this, Atomic8Test::addItem17)); + mustEqual( 35, a.get(this)); + mustEqual( 35, anItemField); } /** @@ -479,12 +479,12 @@ public void testReferenceFieldUpdaterGetAndUpdate() { * function and returns result. */ public void testReferenceFieldUpdaterUpdateAndGet() { - AtomicReferenceFieldUpdater a = anIntegerFieldUpdater(); + AtomicReferenceFieldUpdater a = anItemFieldUpdater(); a.set(this, one); - assertEquals((Integer) 18, a.updateAndGet(this, Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.updateAndGet(this, Atomic8Test::addInteger17)); - assertEquals((Integer) 35, a.get(this)); - assertEquals((Integer) 35, anIntegerField); + mustEqual( 18, a.updateAndGet(this, Atomic8Test::addItem17)); + mustEqual( 35, a.updateAndGet(this, Atomic8Test::addItem17)); + mustEqual( 35, a.get(this)); + mustEqual( 35, anItemField); } /** @@ -492,12 +492,12 @@ public void testReferenceFieldUpdaterUpdateAndGet() { * with supplied function. */ public void testReferenceFieldUpdaterGetAndAccumulate() { - AtomicReferenceFieldUpdater a = anIntegerFieldUpdater(); + AtomicReferenceFieldUpdater a = anItemFieldUpdater(); a.set(this, one); - assertEquals((Integer) 1, a.getAndAccumulate(this, 2, Atomic8Test::sumInteger)); - assertEquals((Integer) 3, a.getAndAccumulate(this, 3, Atomic8Test::sumInteger)); - assertEquals((Integer) 6, a.get(this)); - assertEquals((Integer) 6, anIntegerField); + mustEqual( 1, a.getAndAccumulate(this, two, Atomic8Test::sumItem)); + mustEqual( 3, a.getAndAccumulate(this, three, Atomic8Test::sumItem)); + mustEqual( 6, a.get(this)); + mustEqual( 6, anItemField); } /** @@ -505,18 +505,19 @@ public void testReferenceFieldUpdaterGetAndAccumulate() { * supplied function and returns result. */ public void testReferenceFieldUpdaterAccumulateAndGet() { - AtomicReferenceFieldUpdater a = anIntegerFieldUpdater(); + AtomicReferenceFieldUpdater a = anItemFieldUpdater(); a.set(this, one); - assertEquals((Integer) 7, a.accumulateAndGet(this, 6, Atomic8Test::sumInteger)); - assertEquals((Integer) 10, a.accumulateAndGet(this, 3, Atomic8Test::sumInteger)); - assertEquals((Integer) 10, a.get(this)); - assertEquals((Integer) 10, anIntegerField); + mustEqual( 7, a.accumulateAndGet(this, six, Atomic8Test::sumItem)); + mustEqual( 10, a.accumulateAndGet(this, three, Atomic8Test::sumItem)); + mustEqual( 10, a.get(this)); + mustEqual( 10, anItemField); } /** * All Atomic getAndUpdate methods throw NullPointerException on * null function argument */ + @SuppressWarnings("unchecked") public void testGetAndUpdateNPE() { assertThrows( NullPointerException.class, @@ -528,12 +529,13 @@ public void testGetAndUpdateNPE() { () -> new AtomicReferenceArray(1).getAndUpdate(0, null), () -> aLongFieldUpdater().getAndUpdate(this, null), () -> anIntFieldUpdater().getAndUpdate(this, null), - () -> anIntegerFieldUpdater().getAndUpdate(this, null)); + () -> anItemFieldUpdater().getAndUpdate(this, null)); } /** * All Atomic updateAndGet methods throw NullPointerException on null function argument */ + @SuppressWarnings("unchecked") public void testUpdateAndGetNPE() { assertThrows( NullPointerException.class, @@ -545,13 +547,14 @@ public void testUpdateAndGetNPE() { () -> new AtomicReferenceArray(1).updateAndGet(0, null), () -> aLongFieldUpdater().updateAndGet(this, null), () -> anIntFieldUpdater().updateAndGet(this, null), - () -> anIntegerFieldUpdater().updateAndGet(this, null)); + () -> anItemFieldUpdater().updateAndGet(this, null)); } /** * All Atomic getAndAccumulate methods throw NullPointerException * on null function argument */ + @SuppressWarnings("unchecked") public void testGetAndAccumulateNPE() { assertThrows( NullPointerException.class, @@ -563,13 +566,14 @@ public void testGetAndAccumulateNPE() { () -> new AtomicReferenceArray(1).getAndAccumulate(0, one, null), () -> aLongFieldUpdater().getAndAccumulate(this, 1L, null), () -> anIntFieldUpdater().getAndAccumulate(this, 1, null), - () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null)); + () -> anItemFieldUpdater().getAndAccumulate(this, one, null)); } /** * All Atomic accumulateAndGet methods throw NullPointerException * on null function argument */ + @SuppressWarnings("unchecked") public void testAccumulateAndGetNPE() { assertThrows( NullPointerException.class, @@ -581,7 +585,7 @@ public void testAccumulateAndGetNPE() { () -> new AtomicReferenceArray(1).accumulateAndGet(0, one, null), () -> aLongFieldUpdater().accumulateAndGet(this, 1L, null), () -> anIntFieldUpdater().accumulateAndGet(this, 1, null), - () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null)); + () -> anItemFieldUpdater().accumulateAndGet(this, one, null)); } /** @@ -589,11 +593,12 @@ public void testAccumulateAndGetNPE() { * instances of the class passed to the newUpdater call will * result in a ClassCastException being thrown. */ + @SuppressWarnings("unchecked") public void testFieldUpdaters_ClassCastException() { // Use raw types to allow passing wrong object type, provoking CCE final AtomicLongFieldUpdater longUpdater = aLongFieldUpdater(); final AtomicIntegerFieldUpdater intUpdater = anIntFieldUpdater(); - final AtomicReferenceFieldUpdater refUpdater = anIntegerFieldUpdater(); + final AtomicReferenceFieldUpdater refUpdater = anItemFieldUpdater(); for (Object x : new Object[]{ new Object(), null }) { assertThrows( ClassCastException.class, @@ -603,7 +608,7 @@ public void testFieldUpdaters_ClassCastException() { () -> longUpdater.set(x, 17L), () -> intUpdater.set(x, 17), - () -> refUpdater.set(x, (Integer) 17), + () -> refUpdater.set(x, new Item(17)), () -> longUpdater.addAndGet(x, 17L), () -> intUpdater.addAndGet(x, 17), @@ -614,7 +619,7 @@ public void testFieldUpdaters_ClassCastException() { () -> longUpdater.compareAndSet(x, 17L, 42L), () -> intUpdater.compareAndSet(x, 17, 42), - () -> refUpdater.compareAndSet(x, (Integer) 17, (Integer) 42)); + () -> refUpdater.compareAndSet(x, 17, fortytwo)); } } diff --git a/test/jdk/java/util/concurrent/tck/AtomicBooleanTest.java b/test/jdk/java/util/concurrent/tck/AtomicBooleanTest.java index 05a196ca724..f434a10de44 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicBooleanTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicBooleanTest.java @@ -122,6 +122,7 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicBoolean ai = new AtomicBoolean(true); do {} while (!ai.weakCompareAndSet(true, false)); diff --git a/test/jdk/java/util/concurrent/tck/AtomicIntegerArrayTest.java b/test/jdk/java/util/concurrent/tck/AtomicIntegerArrayTest.java index cdcf0061667..843db239de9 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicIntegerArrayTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicIntegerArrayTest.java @@ -82,6 +82,7 @@ public void testConstructor2() { /** * get and set for out of bound indices throw IndexOutOfBoundsException */ + @SuppressWarnings("deprecation") public void testIndexing() { AtomicIntegerArray aa = new AtomicIntegerArray(SIZE); for (int index : new int[] { -1, SIZE }) { @@ -187,6 +188,7 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicIntegerArray aa = new AtomicIntegerArray(SIZE); for (int i = 0; i < SIZE; i++) { diff --git a/test/jdk/java/util/concurrent/tck/AtomicIntegerTest.java b/test/jdk/java/util/concurrent/tck/AtomicIntegerTest.java index 6f3546038bc..96ff1d298b2 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicIntegerTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicIntegerTest.java @@ -127,6 +127,7 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicInteger ai = new AtomicInteger(1); do {} while (!ai.weakCompareAndSet(1, 2)); diff --git a/test/jdk/java/util/concurrent/tck/AtomicLongArrayTest.java b/test/jdk/java/util/concurrent/tck/AtomicLongArrayTest.java index 72d0e0677ab..dd494c250ba 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicLongArrayTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicLongArrayTest.java @@ -81,6 +81,7 @@ public void testConstructor2() { /** * get and set for out of bound indices throw IndexOutOfBoundsException */ + @SuppressWarnings("deprecation") public void testIndexing() { AtomicLongArray aa = new AtomicLongArray(SIZE); for (int index : new int[] { -1, SIZE }) { @@ -186,6 +187,7 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicLongArray aa = new AtomicLongArray(SIZE); for (int i = 0; i < SIZE; i++) { diff --git a/test/jdk/java/util/concurrent/tck/AtomicLongTest.java b/test/jdk/java/util/concurrent/tck/AtomicLongTest.java index c41a861ce09..d1f2d1a8113 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicLongTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicLongTest.java @@ -129,6 +129,7 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicLong ai = new AtomicLong(1); do {} while (!ai.weakCompareAndSet(1, 2)); diff --git a/test/jdk/java/util/concurrent/tck/AtomicMarkableReferenceTest.java b/test/jdk/java/util/concurrent/tck/AtomicMarkableReferenceTest.java index b1c77c468d2..c1614d4d36f 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicMarkableReferenceTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicMarkableReferenceTest.java @@ -50,10 +50,10 @@ public static Test suite() { * constructor initializes to given reference and mark */ public void testConstructor() { - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); assertSame(one, ai.getReference()); assertFalse(ai.isMarked()); - AtomicMarkableReference a2 = new AtomicMarkableReference(null, true); + AtomicMarkableReference a2 = new AtomicMarkableReference<>(null, true); assertNull(a2.getReference()); assertTrue(a2.isMarked()); } @@ -63,7 +63,7 @@ public void testConstructor() { */ public void testGetSet() { boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); assertSame(one, ai.getReference()); assertFalse(ai.isMarked()); assertSame(one, ai.get(mark)); @@ -85,7 +85,7 @@ public void testGetSet() { */ public void testAttemptMark() { boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); assertFalse(ai.isMarked()); assertTrue(ai.attemptMark(one, true)); assertTrue(ai.isMarked()); @@ -99,7 +99,7 @@ public void testAttemptMark() { */ public void testCompareAndSet() { boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); assertSame(one, ai.get(mark)); assertFalse(ai.isMarked()); assertFalse(mark[0]); @@ -108,12 +108,12 @@ public void testCompareAndSet() { assertSame(two, ai.get(mark)); assertFalse(mark[0]); - assertTrue(ai.compareAndSet(two, m3, false, true)); - assertSame(m3, ai.get(mark)); + assertTrue(ai.compareAndSet(two, minusThree, false, true)); + assertSame(minusThree, ai.get(mark)); assertTrue(mark[0]); - assertFalse(ai.compareAndSet(two, m3, true, true)); - assertSame(m3, ai.get(mark)); + assertFalse(ai.compareAndSet(two, minusThree, true, true)); + assertSame(minusThree, ai.get(mark)); assertTrue(mark[0]); } @@ -122,7 +122,7 @@ public void testCompareAndSet() { * to succeed */ public void testCompareAndSetInMultipleThreads() throws Exception { - final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + final AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(two, three, false, false)) @@ -142,7 +142,7 @@ public void realRun() { * to succeed */ public void testCompareAndSetInMultipleThreads2() throws Exception { - final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + final AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(one, one, true, false)) @@ -163,7 +163,7 @@ public void realRun() { */ public void testWeakCompareAndSet() { boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); + AtomicMarkableReference ai = new AtomicMarkableReference<>(one, false); assertSame(one, ai.get(mark)); assertFalse(ai.isMarked()); assertFalse(mark[0]); @@ -172,8 +172,8 @@ public void testWeakCompareAndSet() { assertSame(two, ai.get(mark)); assertFalse(mark[0]); - do {} while (!ai.weakCompareAndSet(two, m3, false, true)); - assertSame(m3, ai.get(mark)); + do {} while (!ai.weakCompareAndSet(two, minusThree, false, true)); + assertSame(minusThree, ai.get(mark)); assertTrue(mark[0]); } diff --git a/test/jdk/java/util/concurrent/tck/AtomicReference9Test.java b/test/jdk/java/util/concurrent/tck/AtomicReference9Test.java index f864209b952..d78ae3ac9fe 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicReference9Test.java +++ b/test/jdk/java/util/concurrent/tck/AtomicReference9Test.java @@ -48,72 +48,72 @@ public static Test suite() { * getPlain returns the last value set */ public void testGetPlainSet() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.getPlain()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.getPlain()); ai.set(two); - assertEquals(two, ai.getPlain()); - ai.set(m3); - assertEquals(m3, ai.getPlain()); + mustEqual(two, ai.getPlain()); + ai.set(minusThree); + mustEqual(minusThree, ai.getPlain()); } /** * getOpaque returns the last value set */ public void testGetOpaqueSet() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.getOpaque()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.getOpaque()); ai.set(two); - assertEquals(two, ai.getOpaque()); - ai.set(m3); - assertEquals(m3, ai.getOpaque()); + mustEqual(two, ai.getOpaque()); + ai.set(minusThree); + mustEqual(minusThree, ai.getOpaque()); } /** * getAcquire returns the last value set */ public void testGetAcquireSet() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.getAcquire()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.getAcquire()); ai.set(two); - assertEquals(two, ai.getAcquire()); - ai.set(m3); - assertEquals(m3, ai.getAcquire()); + mustEqual(two, ai.getAcquire()); + ai.set(minusThree); + mustEqual(minusThree, ai.getAcquire()); } /** * get returns the last value setPlain */ public void testGetSetPlain() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.get()); ai.setPlain(two); - assertEquals(two, ai.get()); - ai.setPlain(m3); - assertEquals(m3, ai.get()); + mustEqual(two, ai.get()); + ai.setPlain(minusThree); + mustEqual(minusThree, ai.get()); } /** * get returns the last value setOpaque */ public void testGetSetOpaque() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.get()); ai.setOpaque(two); - assertEquals(two, ai.get()); - ai.setOpaque(m3); - assertEquals(m3, ai.get()); + mustEqual(two, ai.get()); + ai.setOpaque(minusThree); + mustEqual(minusThree, ai.get()); } /** * get returns the last value setRelease */ public void testGetSetRelease() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.get()); ai.setRelease(two); - assertEquals(two, ai.get()); - ai.setRelease(m3); - assertEquals(m3, ai.get()); + mustEqual(two, ai.get()); + ai.setRelease(minusThree); + mustEqual(minusThree, ai.get()); } /** @@ -121,14 +121,14 @@ public void testGetSetRelease() { * expected else fails */ public void testCompareAndExchange() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.compareAndExchange(one, two)); - assertEquals(two, ai.compareAndExchange(two, m4)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchange(m5, seven)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchange(m4, seven)); - assertEquals(seven, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.compareAndExchange(one, two)); + mustEqual(two, ai.compareAndExchange(two, minusFour)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchange(minusFive, seven)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchange(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -136,14 +136,14 @@ public void testCompareAndExchange() { * expected else fails */ public void testCompareAndExchangeAcquire() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.compareAndExchangeAcquire(one, two)); - assertEquals(two, ai.compareAndExchangeAcquire(two, m4)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchangeAcquire(m5, seven)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchangeAcquire(m4, seven)); - assertEquals(seven, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.compareAndExchangeAcquire(one, two)); + mustEqual(two, ai.compareAndExchangeAcquire(two, minusFour)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchangeAcquire(minusFive, seven)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchangeAcquire(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -151,14 +151,14 @@ public void testCompareAndExchangeAcquire() { * expected else fails */ public void testCompareAndExchangeRelease() { - AtomicReference ai = new AtomicReference<>(one); - assertEquals(one, ai.compareAndExchangeRelease(one, two)); - assertEquals(two, ai.compareAndExchangeRelease(two, m4)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchangeRelease(m5, seven)); - assertEquals(m4, ai.get()); - assertEquals(m4, ai.compareAndExchangeRelease(m4, seven)); - assertEquals(seven, ai.get()); + AtomicReference ai = new AtomicReference<>(one); + mustEqual(one, ai.compareAndExchangeRelease(one, two)); + mustEqual(two, ai.compareAndExchangeRelease(two, minusFour)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchangeRelease(minusFive, seven)); + mustEqual(minusFour, ai.get()); + mustEqual(minusFour, ai.compareAndExchangeRelease(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -166,12 +166,12 @@ public void testCompareAndExchangeRelease() { * to expected */ public void testWeakCompareAndSetPlain() { - AtomicReference ai = new AtomicReference<>(one); + AtomicReference ai = new AtomicReference<>(one); do {} while (!ai.weakCompareAndSetPlain(one, two)); - do {} while (!ai.weakCompareAndSetPlain(two, m4)); - assertEquals(m4, ai.get()); - do {} while (!ai.weakCompareAndSetPlain(m4, seven)); - assertEquals(seven, ai.get()); + do {} while (!ai.weakCompareAndSetPlain(two, minusFour)); + mustEqual(minusFour, ai.get()); + do {} while (!ai.weakCompareAndSetPlain(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -179,12 +179,12 @@ public void testWeakCompareAndSetPlain() { * to expected */ public void testWeakCompareAndSetVolatile() { - AtomicReference ai = new AtomicReference<>(one); + AtomicReference ai = new AtomicReference<>(one); do {} while (!ai.weakCompareAndSetVolatile(one, two)); - do {} while (!ai.weakCompareAndSetVolatile(two, m4)); - assertEquals(m4, ai.get()); - do {} while (!ai.weakCompareAndSetVolatile(m4, seven)); - assertEquals(seven, ai.get()); + do {} while (!ai.weakCompareAndSetVolatile(two, minusFour)); + mustEqual(minusFour, ai.get()); + do {} while (!ai.weakCompareAndSetVolatile(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -192,12 +192,12 @@ public void testWeakCompareAndSetVolatile() { * to expected */ public void testWeakCompareAndSetAcquire() { - AtomicReference ai = new AtomicReference<>(one); + AtomicReference ai = new AtomicReference<>(one); do {} while (!ai.weakCompareAndSetAcquire(one, two)); - do {} while (!ai.weakCompareAndSetAcquire(two, m4)); - assertEquals(m4, ai.get()); - do {} while (!ai.weakCompareAndSetAcquire(m4, seven)); - assertEquals(seven, ai.get()); + do {} while (!ai.weakCompareAndSetAcquire(two, minusFour)); + mustEqual(minusFour, ai.get()); + do {} while (!ai.weakCompareAndSetAcquire(minusFour, seven)); + mustEqual(seven, ai.get()); } /** @@ -205,12 +205,12 @@ public void testWeakCompareAndSetAcquire() { * to expected */ public void testWeakCompareAndSetRelease() { - AtomicReference ai = new AtomicReference<>(one); + AtomicReference ai = new AtomicReference<>(one); do {} while (!ai.weakCompareAndSetRelease(one, two)); - do {} while (!ai.weakCompareAndSetRelease(two, m4)); - assertEquals(m4, ai.get()); - do {} while (!ai.weakCompareAndSetRelease(m4, seven)); - assertEquals(seven, ai.get()); + do {} while (!ai.weakCompareAndSetRelease(two, minusFour)); + mustEqual(minusFour, ai.get()); + do {} while (!ai.weakCompareAndSetRelease(minusFour, seven)); + mustEqual(seven, ai.get()); } } diff --git a/test/jdk/java/util/concurrent/tck/AtomicReferenceArray9Test.java b/test/jdk/java/util/concurrent/tck/AtomicReferenceArray9Test.java index 689e6e04098..50054b89832 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicReferenceArray9Test.java +++ b/test/jdk/java/util/concurrent/tck/AtomicReferenceArray9Test.java @@ -73,14 +73,14 @@ public void testIndexing() { * getPlain returns the last value set */ public void testGetPlainSet() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.getPlain(i)); aa.set(i, two); assertEquals(two, aa.getPlain(i)); - aa.set(i, m3); - assertEquals(m3, aa.getPlain(i)); + aa.set(i, minusThree); + assertEquals(minusThree, aa.getPlain(i)); } } @@ -88,14 +88,14 @@ public void testGetPlainSet() { * getOpaque returns the last value set */ public void testGetOpaqueSet() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.getOpaque(i)); aa.set(i, two); assertEquals(two, aa.getOpaque(i)); - aa.set(i, m3); - assertEquals(m3, aa.getOpaque(i)); + aa.set(i, minusThree); + assertEquals(minusThree, aa.getOpaque(i)); } } @@ -103,14 +103,14 @@ public void testGetOpaqueSet() { * getAcquire returns the last value set */ public void testGetAcquireSet() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.getAcquire(i)); aa.set(i, two); assertEquals(two, aa.getAcquire(i)); - aa.set(i, m3); - assertEquals(m3, aa.getAcquire(i)); + aa.set(i, minusThree); + assertEquals(minusThree, aa.getAcquire(i)); } } @@ -118,14 +118,14 @@ public void testGetAcquireSet() { * get returns the last value setPlain */ public void testGetSetPlain() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.setPlain(i, one); assertEquals(one, aa.get(i)); aa.setPlain(i, two); assertEquals(two, aa.get(i)); - aa.setPlain(i, m3); - assertEquals(m3, aa.get(i)); + aa.setPlain(i, minusThree); + assertEquals(minusThree, aa.get(i)); } } @@ -133,14 +133,14 @@ public void testGetSetPlain() { * get returns the last value setOpaque */ public void testGetSetOpaque() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.setOpaque(i, one); assertEquals(one, aa.get(i)); aa.setOpaque(i, two); assertEquals(two, aa.get(i)); - aa.setOpaque(i, m3); - assertEquals(m3, aa.get(i)); + aa.setOpaque(i, minusThree); + assertEquals(minusThree, aa.get(i)); } } @@ -148,14 +148,14 @@ public void testGetSetOpaque() { * get returns the last value setRelease */ public void testGetSetRelease() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.setRelease(i, one); assertEquals(one, aa.get(i)); aa.setRelease(i, two); assertEquals(two, aa.get(i)); - aa.setRelease(i, m3); - assertEquals(m3, aa.get(i)); + aa.setRelease(i, minusThree); + assertEquals(minusThree, aa.get(i)); } } @@ -164,15 +164,15 @@ public void testGetSetRelease() { * expected else fails */ public void testCompareAndExchange() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.compareAndExchange(i, one, two)); - assertEquals(two, aa.compareAndExchange(i, two, m4)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchange(i,m5, seven)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchange(i, m4, seven)); + assertEquals(two, aa.compareAndExchange(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchange(i,minusFive, seven)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchange(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -182,15 +182,15 @@ public void testCompareAndExchange() { * expected else fails */ public void testCompareAndExchangeAcquire() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.compareAndExchangeAcquire(i, one, two)); - assertEquals(two, aa.compareAndExchangeAcquire(i, two, m4)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchangeAcquire(i,m5, seven)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchangeAcquire(i, m4, seven)); + assertEquals(two, aa.compareAndExchangeAcquire(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchangeAcquire(i,minusFive, seven)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchangeAcquire(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -200,15 +200,15 @@ public void testCompareAndExchangeAcquire() { * expected else fails */ public void testCompareAndExchangeRelease() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertEquals(one, aa.compareAndExchangeRelease(i, one, two)); - assertEquals(two, aa.compareAndExchangeRelease(i, two, m4)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchangeRelease(i,m5, seven)); - assertEquals(m4, aa.get(i)); - assertEquals(m4, aa.compareAndExchangeRelease(i, m4, seven)); + assertEquals(two, aa.compareAndExchangeRelease(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchangeRelease(i,minusFive, seven)); + assertEquals(minusFour, aa.get(i)); + assertEquals(minusFour, aa.compareAndExchangeRelease(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -218,13 +218,13 @@ public void testCompareAndExchangeRelease() { * to expected */ public void testWeakCompareAndSetPlain() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); do {} while (!aa.weakCompareAndSetPlain(i, one, two)); - do {} while (!aa.weakCompareAndSetPlain(i, two, m4)); - assertEquals(m4, aa.get(i)); - do {} while (!aa.weakCompareAndSetPlain(i, m4, seven)); + do {} while (!aa.weakCompareAndSetPlain(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + do {} while (!aa.weakCompareAndSetPlain(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -234,13 +234,13 @@ public void testWeakCompareAndSetPlain() { * to expected */ public void testWeakCompareAndSetVolatile() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); do {} while (!aa.weakCompareAndSetVolatile(i, one, two)); - do {} while (!aa.weakCompareAndSetVolatile(i, two, m4)); - assertEquals(m4, aa.get(i)); - do {} while (!aa.weakCompareAndSetVolatile(i, m4, seven)); + do {} while (!aa.weakCompareAndSetVolatile(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + do {} while (!aa.weakCompareAndSetVolatile(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -250,13 +250,13 @@ public void testWeakCompareAndSetVolatile() { * to expected */ public void testWeakCompareAndSetAcquire() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); do {} while (!aa.weakCompareAndSetAcquire(i, one, two)); - do {} while (!aa.weakCompareAndSetAcquire(i, two, m4)); - assertEquals(m4, aa.get(i)); - do {} while (!aa.weakCompareAndSetAcquire(i, m4, seven)); + do {} while (!aa.weakCompareAndSetAcquire(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + do {} while (!aa.weakCompareAndSetAcquire(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } @@ -266,13 +266,13 @@ public void testWeakCompareAndSetAcquire() { * to expected */ public void testWeakCompareAndSetRelease() { - AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); do {} while (!aa.weakCompareAndSetRelease(i, one, two)); - do {} while (!aa.weakCompareAndSetRelease(i, two, m4)); - assertEquals(m4, aa.get(i)); - do {} while (!aa.weakCompareAndSetRelease(i, m4, seven)); + do {} while (!aa.weakCompareAndSetRelease(i, two, minusFour)); + assertEquals(minusFour, aa.get(i)); + do {} while (!aa.weakCompareAndSetRelease(i, minusFour, seven)); assertEquals(seven, aa.get(i)); } } diff --git a/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java b/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java index 80e442f3866..686a57271cf 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java @@ -72,8 +72,8 @@ public void testConstructor2NPE() { * constructor with array is of same size and has all elements */ public void testConstructor2() { - Integer[] a = { two, one, three, four, seven }; - AtomicReferenceArray aa = new AtomicReferenceArray<>(a); + Item[] a = { two, one, three, four, seven }; + AtomicReferenceArray aa = new AtomicReferenceArray<>(a); assertEquals(a.length, aa.length()); for (int i = 0; i < a.length; i++) assertEquals(a[i], aa.get(i)); @@ -83,7 +83,7 @@ public void testConstructor2() { * Initialize AtomicReferenceArray with SubClass[] */ public void testConstructorSubClassArray() { - Integer[] a = { two, one, three, four, seven }; + Item[] a = { two, one, three, four, seven }; AtomicReferenceArray aa = new AtomicReferenceArray<>(a); assertEquals(a.length, aa.length()); for (int i = 0; i < a.length; i++) { @@ -97,6 +97,7 @@ public void testConstructorSubClassArray() { /** * get and set for out of bound indices throw IndexOutOfBoundsException */ + @SuppressWarnings("deprecation") public void testIndexing() { AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int index : new int[] { -1, SIZE }) { @@ -127,14 +128,14 @@ public void testIndexing() { * get returns the last value set at index */ public void testGetSet() { - AtomicReferenceArray aa = new AtomicReferenceArray(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertSame(one, aa.get(i)); aa.set(i, two); assertSame(two, aa.get(i)); - aa.set(i, m3); - assertSame(m3, aa.get(i)); + aa.set(i, minusThree); + assertSame(minusThree, aa.get(i)); } } @@ -142,14 +143,14 @@ public void testGetSet() { * get returns the last value lazySet at index by same thread */ public void testGetLazySet() { - AtomicReferenceArray aa = new AtomicReferenceArray(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.lazySet(i, one); assertSame(one, aa.get(i)); aa.lazySet(i, two); assertSame(two, aa.get(i)); - aa.lazySet(i, m3); - assertSame(m3, aa.get(i)); + aa.lazySet(i, minusThree); + assertSame(minusThree, aa.get(i)); } } @@ -157,15 +158,15 @@ public void testGetLazySet() { * compareAndSet succeeds in changing value if equal to expected else fails */ public void testCompareAndSet() { - AtomicReferenceArray aa = new AtomicReferenceArray(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertTrue(aa.compareAndSet(i, one, two)); - assertTrue(aa.compareAndSet(i, two, m4)); - assertSame(m4, aa.get(i)); - assertFalse(aa.compareAndSet(i, m5, seven)); - assertSame(m4, aa.get(i)); - assertTrue(aa.compareAndSet(i, m4, seven)); + assertTrue(aa.compareAndSet(i, two, minusFour)); + assertSame(minusFour, aa.get(i)); + assertFalse(aa.compareAndSet(i, minusFive, seven)); + assertSame(minusFour, aa.get(i)); + assertTrue(aa.compareAndSet(i, minusFour, seven)); assertSame(seven, aa.get(i)); } } @@ -175,7 +176,7 @@ public void testCompareAndSet() { * to succeed */ public void testCompareAndSetInMultipleThreads() throws InterruptedException { - final AtomicReferenceArray a = new AtomicReferenceArray(1); + final AtomicReferenceArray a = new AtomicReferenceArray<>(1); a.set(0, one); Thread t = new Thread(new CheckedRunnable() { public void realRun() { @@ -194,14 +195,15 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { - AtomicReferenceArray aa = new AtomicReferenceArray(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); do {} while (!aa.weakCompareAndSet(i, one, two)); - do {} while (!aa.weakCompareAndSet(i, two, m4)); - assertSame(m4, aa.get(i)); - do {} while (!aa.weakCompareAndSet(i, m4, seven)); + do {} while (!aa.weakCompareAndSet(i, two, minusFour)); + assertSame(minusFour, aa.get(i)); + do {} while (!aa.weakCompareAndSet(i, minusFour, seven)); assertSame(seven, aa.get(i)); } } @@ -210,12 +212,12 @@ public void testWeakCompareAndSet() { * getAndSet returns previous value and sets to given value at given index */ public void testGetAndSet() { - AtomicReferenceArray aa = new AtomicReferenceArray(SIZE); + AtomicReferenceArray aa = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { aa.set(i, one); assertSame(one, aa.getAndSet(i, zero)); - assertSame(zero, aa.getAndSet(i, m10)); - assertSame(m10, aa.getAndSet(i, one)); + assertSame(zero, aa.getAndSet(i, minusTen)); + assertSame(minusTen, aa.getAndSet(i, one)); } } @@ -223,11 +225,11 @@ public void testGetAndSet() { * a deserialized/reserialized array holds same values in same order */ public void testSerialization() throws Exception { - AtomicReferenceArray x = new AtomicReferenceArray(SIZE); + AtomicReferenceArray x = new AtomicReferenceArray<>(SIZE); for (int i = 0; i < SIZE; i++) { - x.set(i, new Integer(-i)); + x.set(i, minusOne); } - AtomicReferenceArray y = serialClone(x); + AtomicReferenceArray y = serialClone(x); assertNotSame(x, y); assertEquals(x.length(), y.length()); for (int i = 0; i < SIZE; i++) { @@ -239,8 +241,8 @@ public void testSerialization() throws Exception { * toString returns current value. */ public void testToString() { - Integer[] a = { two, one, three, four, seven }; - AtomicReferenceArray aa = new AtomicReferenceArray<>(a); + Item[] a = { two, one, three, four, seven }; + AtomicReferenceArray aa = new AtomicReferenceArray<>(a); assertEquals(Arrays.toString(a), aa.toString()); } diff --git a/test/jdk/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java b/test/jdk/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java index 3c1eb4a5f94..6df68c4c634 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java @@ -39,11 +39,11 @@ import junit.framework.TestSuite; public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { - volatile Integer x = null; - protected volatile Integer protectedField; - private volatile Integer privateField; + volatile Item x = null; + protected volatile Item protectedField; + private volatile Item privateField; Object z; - Integer w; + Item w; volatile int i; public static void main(String[] args) { @@ -53,9 +53,9 @@ public static Test suite() { return new TestSuite(AtomicReferenceFieldUpdaterTest.class); } - static AtomicReferenceFieldUpdater updaterFor(String fieldName) { + static AtomicReferenceFieldUpdater updaterFor(String fieldName) { return AtomicReferenceFieldUpdater.newUpdater - (AtomicReferenceFieldUpdaterTest.class, Integer.class, fieldName); + (AtomicReferenceFieldUpdaterTest.class, Item.class, fieldName); } /** @@ -121,43 +121,43 @@ public void testUnrelatedClassAccess() { * get returns the last value set or assigned */ public void testGetSet() { - AtomicReferenceFieldUpdater a; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.get(this)); a.set(this, two); assertSame(two, a.get(this)); - a.set(this, m3); - assertSame(m3, a.get(this)); + a.set(this, minusThree); + assertSame(minusThree, a.get(this)); } /** * get returns the last value lazySet by same thread */ public void testGetLazySet() { - AtomicReferenceFieldUpdater a; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.get(this)); a.lazySet(this, two); assertSame(two, a.get(this)); - a.lazySet(this, m3); - assertSame(m3, a.get(this)); + a.lazySet(this, minusThree); + assertSame(minusThree, a.get(this)); } /** * compareAndSet succeeds in changing value if same as expected else fails */ public void testCompareAndSet() { - AtomicReferenceFieldUpdater a; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertTrue(a.compareAndSet(this, one, two)); - assertTrue(a.compareAndSet(this, two, m4)); - assertSame(m4, a.get(this)); - assertFalse(a.compareAndSet(this, m5, seven)); + assertTrue(a.compareAndSet(this, two, minusFour)); + assertSame(minusFour, a.get(this)); + assertFalse(a.compareAndSet(this, minusFive, seven)); assertNotSame(seven, a.get(this)); - assertTrue(a.compareAndSet(this, m4, seven)); + assertTrue(a.compareAndSet(this, minusFour, seven)); assertSame(seven, a.get(this)); } @@ -176,7 +176,7 @@ public void testCompareAndSetProtectedInSubclass() { */ public void testCompareAndSetInMultipleThreads() throws Exception { x = one; - final AtomicReferenceFieldUpdater a; + final AtomicReferenceFieldUpdater a; a = updaterFor("x"); Thread t = new Thread(new CheckedRunnable() { @@ -196,13 +196,13 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when same as expected */ public void testWeakCompareAndSet() { - AtomicReferenceFieldUpdater a; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; do {} while (!a.weakCompareAndSet(this, one, two)); - do {} while (!a.weakCompareAndSet(this, two, m4)); - assertSame(m4, a.get(this)); - do {} while (!a.weakCompareAndSet(this, m4, seven)); + do {} while (!a.weakCompareAndSet(this, two, minusFour)); + assertSame(minusFour, a.get(this)); + do {} while (!a.weakCompareAndSet(this, minusFour, seven)); assertSame(seven, a.get(this)); } @@ -210,12 +210,12 @@ public void testWeakCompareAndSet() { * getAndSet returns previous value and sets to given value */ public void testGetAndSet() { - AtomicReferenceFieldUpdater a; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.getAndSet(this, zero)); - assertSame(zero, a.getAndSet(this, m10)); - assertSame(m10, a.getAndSet(this, 1)); + assertSame(zero, a.getAndSet(this, minusTen)); + assertSame(minusTen, a.getAndSet(this, one)); } } diff --git a/test/jdk/java/util/concurrent/tck/AtomicReferenceTest.java b/test/jdk/java/util/concurrent/tck/AtomicReferenceTest.java index f46bd786c8f..43f013ac83b 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicReferenceTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicReferenceTest.java @@ -50,7 +50,7 @@ public static Test suite() { * constructor initializes to given value */ public void testConstructor() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); assertSame(one, ai.get()); } @@ -58,7 +58,7 @@ public void testConstructor() { * default constructed initializes to null */ public void testConstructor2() { - AtomicReference ai = new AtomicReference(); + AtomicReference ai = new AtomicReference<>(); assertNull(ai.get()); } @@ -66,37 +66,37 @@ public void testConstructor2() { * get returns the last value set */ public void testGetSet() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); assertSame(one, ai.get()); ai.set(two); assertSame(two, ai.get()); - ai.set(m3); - assertSame(m3, ai.get()); + ai.set(minusThree); + assertSame(minusThree, ai.get()); } /** * get returns the last value lazySet in same thread */ public void testGetLazySet() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); assertSame(one, ai.get()); ai.lazySet(two); assertSame(two, ai.get()); - ai.lazySet(m3); - assertSame(m3, ai.get()); + ai.lazySet(minusThree); + assertSame(minusThree, ai.get()); } /** * compareAndSet succeeds in changing value if equal to expected else fails */ public void testCompareAndSet() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); assertTrue(ai.compareAndSet(one, two)); - assertTrue(ai.compareAndSet(two, m4)); - assertSame(m4, ai.get()); - assertFalse(ai.compareAndSet(m5, seven)); - assertSame(m4, ai.get()); - assertTrue(ai.compareAndSet(m4, seven)); + assertTrue(ai.compareAndSet(two, minusFour)); + assertSame(minusFour, ai.get()); + assertFalse(ai.compareAndSet(minusFive, seven)); + assertSame(minusFour, ai.get()); + assertTrue(ai.compareAndSet(minusFour, seven)); assertSame(seven, ai.get()); } @@ -105,7 +105,7 @@ public void testCompareAndSet() { * to succeed */ public void testCompareAndSetInMultipleThreads() throws Exception { - final AtomicReference ai = new AtomicReference(one); + final AtomicReference ai = new AtomicReference<>(one); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(two, three)) @@ -123,12 +123,13 @@ public void realRun() { * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); do {} while (!ai.weakCompareAndSet(one, two)); - do {} while (!ai.weakCompareAndSet(two, m4)); - assertSame(m4, ai.get()); - do {} while (!ai.weakCompareAndSet(m4, seven)); + do {} while (!ai.weakCompareAndSet(two, minusFour)); + assertSame(minusFour, ai.get()); + do {} while (!ai.weakCompareAndSet(minusFour, seven)); assertSame(seven, ai.get()); } @@ -136,21 +137,21 @@ public void testWeakCompareAndSet() { * getAndSet returns previous value and sets to given value */ public void testGetAndSet() { - AtomicReference ai = new AtomicReference(one); + AtomicReference ai = new AtomicReference<>(one); assertSame(one, ai.getAndSet(zero)); - assertSame(zero, ai.getAndSet(m10)); - assertSame(m10, ai.getAndSet(one)); + assertSame(zero, ai.getAndSet(minusTen)); + assertSame(minusTen, ai.getAndSet(one)); } /** * a deserialized/reserialized atomic holds same value */ public void testSerialization() throws Exception { - AtomicReference x = new AtomicReference(); - AtomicReference y = serialClone(x); + AtomicReference x = new AtomicReference<>(); + AtomicReference y = serialClone(x); assertNotSame(x, y); x.set(one); - AtomicReference z = serialClone(x); + AtomicReference z = serialClone(x); assertNotSame(y, z); assertEquals(one, x.get()); assertNull(y.get()); @@ -161,7 +162,7 @@ public void testSerialization() throws Exception { * toString returns current value. */ public void testToString() { - AtomicReference ai = new AtomicReference<>(one); + AtomicReference ai = new AtomicReference<>(one); assertEquals(one.toString(), ai.toString()); ai.set(two); assertEquals(two.toString(), ai.toString()); diff --git a/test/jdk/java/util/concurrent/tck/AtomicStampedReferenceTest.java b/test/jdk/java/util/concurrent/tck/AtomicStampedReferenceTest.java index 1a352130d3e..bd78ee53b86 100644 --- a/test/jdk/java/util/concurrent/tck/AtomicStampedReferenceTest.java +++ b/test/jdk/java/util/concurrent/tck/AtomicStampedReferenceTest.java @@ -50,10 +50,10 @@ public static Test suite() { * constructor initializes to given reference and stamp */ public void testConstructor() { - AtomicStampedReference ai = new AtomicStampedReference(one, 0); + AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); assertSame(one, ai.getReference()); assertEquals(0, ai.getStamp()); - AtomicStampedReference a2 = new AtomicStampedReference(null, 1); + AtomicStampedReference a2 = new AtomicStampedReference<>(null, 1); assertNull(a2.getReference()); assertEquals(1, a2.getStamp()); } @@ -63,7 +63,7 @@ public void testConstructor() { */ public void testGetSet() { int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); + AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); assertSame(one, ai.getReference()); assertEquals(0, ai.getStamp()); assertSame(one, ai.get(mark)); @@ -85,7 +85,7 @@ public void testGetSet() { */ public void testAttemptStamp() { int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); + AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); assertEquals(0, ai.getStamp()); assertTrue(ai.attemptStamp(one, 1)); assertEquals(1, ai.getStamp()); @@ -99,7 +99,7 @@ public void testAttemptStamp() { */ public void testCompareAndSet() { int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); + AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); assertSame(one, ai.get(mark)); assertEquals(0, ai.getStamp()); assertEquals(0, mark[0]); @@ -108,12 +108,12 @@ public void testCompareAndSet() { assertSame(two, ai.get(mark)); assertEquals(0, mark[0]); - assertTrue(ai.compareAndSet(two, m3, 0, 1)); - assertSame(m3, ai.get(mark)); + assertTrue(ai.compareAndSet(two, minusThree, 0, 1)); + assertSame(minusThree, ai.get(mark)); assertEquals(1, mark[0]); - assertFalse(ai.compareAndSet(two, m3, 1, 1)); - assertSame(m3, ai.get(mark)); + assertFalse(ai.compareAndSet(two, minusThree, 1, 1)); + assertSame(minusThree, ai.get(mark)); assertEquals(1, mark[0]); } @@ -122,7 +122,7 @@ public void testCompareAndSet() { * to succeed */ public void testCompareAndSetInMultipleThreads() throws Exception { - final AtomicStampedReference ai = new AtomicStampedReference(one, 0); + final AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(two, three, 0, 0)) @@ -142,7 +142,7 @@ public void realRun() { * to succeed */ public void testCompareAndSetInMultipleThreads2() throws Exception { - final AtomicStampedReference ai = new AtomicStampedReference(one, 0); + final AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(one, one, 1, 2)) @@ -163,7 +163,7 @@ public void realRun() { */ public void testWeakCompareAndSet() { int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); + AtomicStampedReference ai = new AtomicStampedReference<>(one, 0); assertSame(one, ai.get(mark)); assertEquals(0, ai.getStamp()); assertEquals(0, mark[0]); @@ -172,8 +172,8 @@ public void testWeakCompareAndSet() { assertSame(two, ai.get(mark)); assertEquals(0, mark[0]); - do {} while (!ai.weakCompareAndSet(two, m3, 0, 1)); - assertSame(m3, ai.get(mark)); + do {} while (!ai.weakCompareAndSet(two, minusThree, 0, 1)); + assertSame(minusThree, ai.get(mark)); assertEquals(1, mark[0]); } diff --git a/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java b/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java index f1d042cd703..101b583ccab 100644 --- a/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java @@ -79,7 +79,7 @@ public Test testSuite() { * Override for collections with unusual element types. */ protected Object makeElement(int i) { - return Integer.valueOf(i); + return JSR166TestCase.itemFor(i); } //---------------------------------------------------------------- @@ -148,7 +148,7 @@ public void testAddAllNull() throws InterruptedException { */ public void testAddAllNullElements() { final Collection q = emptyCollection(); - final Collection elements = Arrays.asList(new Integer[SIZE]); + final Collection elements = Arrays.asList(new Item[SIZE]); try { q.addAll(elements); shouldThrow(); @@ -223,13 +223,14 @@ public void testDrainToNonPositiveMaxElements() { } if (q.remainingCapacity() > 0) { // Not SynchronousQueue, that is - Object one = makeElement(1); - q.add(one); - for (int n : ns) - assertEquals(0, q.drainTo(sink, n)); - assertEquals(1, q.size()); - assertSame(one, q.poll()); - assertTrue(sink.isEmpty()); + Object e = makeElement(1); + if (q.add(e)) { + for (int n : ns) + assertEquals(0, q.drainTo(sink, n)); + assertEquals(1, q.size()); + assertEquals(e, q.poll()); + assertTrue(sink.isEmpty()); + } } } @@ -376,8 +377,8 @@ public void testRemoveElement() { q.add(elts[i] = makeElement(i)); for (int i = 1; i < size; i += 2) { for (int pass = 0; pass < 2; pass++) { - assertEquals((pass == 0), q.contains(elts[i])); - assertEquals((pass == 0), q.remove(elts[i])); + mustEqual((pass == 0), q.contains(elts[i])); + mustEqual((pass == 0), q.remove(elts[i])); assertFalse(q.contains(elts[i])); assertTrue(q.contains(elts[i - 1])); if (i < size - 1) diff --git a/test/jdk/java/util/concurrent/tck/Collection8Test.java b/test/jdk/java/util/concurrent/tck/Collection8Test.java index 807ff490367..20a89552c7b 100644 --- a/test/jdk/java/util/concurrent/tck/Collection8Test.java +++ b/test/jdk/java/util/concurrent/tck/Collection8Test.java @@ -120,28 +120,28 @@ public void testEmptyMeansEmpty() throws Throwable { void emptyMeansEmpty(Collection c) throws InterruptedException { assertTrue(c.isEmpty()); - assertEquals(0, c.size()); - assertEquals("[]", c.toString()); + mustEqual(0, c.size()); + mustEqual("[]", c.toString()); if (c instanceof List) { List x = (List) c; - assertEquals(1, x.hashCode()); - assertEquals(x, Collections.emptyList()); - assertEquals(Collections.emptyList(), x); - assertEquals(-1, x.indexOf(impl.makeElement(86))); - assertEquals(-1, x.lastIndexOf(impl.makeElement(99))); + mustEqual(1, x.hashCode()); + mustEqual(x, Collections.emptyList()); + mustEqual(Collections.emptyList(), x); + mustEqual(-1, x.indexOf(impl.makeElement(86))); + mustEqual(-1, x.lastIndexOf(impl.makeElement(99))); assertThrows( IndexOutOfBoundsException.class, () -> x.get(0), () -> x.set(0, impl.makeElement(42))); } else if (c instanceof Set) { - assertEquals(0, c.hashCode()); - assertEquals(c, Collections.emptySet()); - assertEquals(Collections.emptySet(), c); + mustEqual(0, c.hashCode()); + mustEqual(c, Collections.emptySet()); + mustEqual(Collections.emptySet(), c); } { Object[] a = c.toArray(); - assertEquals(0, a.length); + mustEqual(0, a.length); assertSame(Object[].class, a.getClass()); } { @@ -149,15 +149,15 @@ else if (c instanceof Set) { assertSame(a, c.toArray(a)); } { - Integer[] a = new Integer[0]; + Item[] a = new Item[0]; assertSame(a, c.toArray(a)); } { - Integer[] a = { 1, 2, 3}; + Item[] a = { one, two, three}; assertSame(a, c.toArray(a)); assertNull(a[0]); - assertSame(2, a[1]); - assertSame(3, a[2]); + mustEqual(2, a[1]); + mustEqual(3, a[2]); } assertIteratorExhausted(c.iterator()); Consumer alwaysThrows = e -> { throw new AssertionError(); }; @@ -166,7 +166,7 @@ else if (c instanceof Set) { c.spliterator().forEachRemaining(alwaysThrows); assertFalse(c.spliterator().tryAdvance(alwaysThrows)); if (c.spliterator().hasCharacteristics(Spliterator.SIZED)) - assertEquals(0, c.spliterator().estimateSize()); + mustEqual(0, c.spliterator().estimateSize()); assertFalse(c.contains(bomb())); assertFalse(c.remove(bomb())); if (c instanceof Queue) { @@ -198,12 +198,13 @@ else if (c instanceof Set) { public void testNullPointerExceptions() throws InterruptedException { Collection c = impl.emptyCollection(); + Collection nullCollection = null; assertThrows( NullPointerException.class, - () -> c.addAll(null), - () -> c.containsAll(null), - () -> c.retainAll(null), - () -> c.removeAll(null), + () -> c.addAll(nullCollection), + () -> c.containsAll(nullCollection), + () -> c.retainAll(nullCollection), + () -> c.removeAll(nullCollection), () -> c.removeIf(null), () -> c.forEach(null), () -> c.iterator().forEachRemaining(null), @@ -319,14 +320,14 @@ public void testRemoveIf() { try { boolean modified = c.removeIf(randomPredicate); assertNull(threwAt.get()); - assertEquals(modified, accepts.size() > 0); - assertEquals(modified, rejects.size() != n); - assertEquals(accepts.size() + rejects.size(), n); + mustEqual(modified, accepts.size() > 0); + mustEqual(modified, rejects.size() != n); + mustEqual(accepts.size() + rejects.size(), n); if (ordered) { - assertEquals(rejects, + mustEqual(rejects, Arrays.asList(c.toArray())); } else { - assertEquals(new HashSet(rejects), + mustEqual(new HashSet(rejects), new HashSet(Arrays.asList(c.toArray()))); } } catch (ArithmeticException ok) { @@ -350,7 +351,7 @@ public void testRemoveIf() { assertTrue(c.containsAll(survivors)); assertTrue(survivors.containsAll(rejects)); if (threwAt.get() == null) { - assertEquals(n - accepts.size(), c.size()); + mustEqual(n - accepts.size(), c.size()); for (Object x : accepts) assertFalse(c.contains(x)); } else { // Two acceptable behaviors: entire removeIf call is one @@ -440,7 +441,6 @@ public void testRandomElementRemovalDuringTraversal() { if (rnd.nextBoolean()) assertTrue(it.hasNext()); it.next(); } - Consumer alwaysThrows = e -> { throw new AssertionError(); }; // TODO: many more removal methods if (rnd.nextBoolean()) { for (Iterator z = c.iterator(); z.hasNext(); ) { @@ -514,24 +514,24 @@ public void testTraversalEquivalence() { if (c instanceof List || c instanceof Deque) assertTrue(ordered); HashSet cset = new HashSet(c); - assertEquals(cset, new HashSet(parallelStreamForEached)); + mustEqual(cset, new HashSet(parallelStreamForEached)); if (ordered) { - assertEquals(iterated, iteratedForEachRemaining); - assertEquals(iterated, tryAdvanced); - assertEquals(iterated, spliterated); - assertEquals(iterated, splitonced); - assertEquals(iterated, forEached); - assertEquals(iterated, streamForEached); - assertEquals(iterated, removeIfed); + mustEqual(iterated, iteratedForEachRemaining); + mustEqual(iterated, tryAdvanced); + mustEqual(iterated, spliterated); + mustEqual(iterated, splitonced); + mustEqual(iterated, forEached); + mustEqual(iterated, streamForEached); + mustEqual(iterated, removeIfed); } else { - assertEquals(cset, new HashSet(iterated)); - assertEquals(cset, new HashSet(iteratedForEachRemaining)); - assertEquals(cset, new HashSet(tryAdvanced)); - assertEquals(cset, new HashSet(spliterated)); - assertEquals(cset, new HashSet(splitonced)); - assertEquals(cset, new HashSet(forEached)); - assertEquals(cset, new HashSet(streamForEached)); - assertEquals(cset, new HashSet(removeIfed)); + mustEqual(cset, new HashSet(iterated)); + mustEqual(cset, new HashSet(iteratedForEachRemaining)); + mustEqual(cset, new HashSet(tryAdvanced)); + mustEqual(cset, new HashSet(spliterated)); + mustEqual(cset, new HashSet(splitonced)); + mustEqual(cset, new HashSet(forEached)); + mustEqual(cset, new HashSet(streamForEached)); + mustEqual(cset, new HashSet(removeIfed)); } if (c instanceof Deque) { Deque d = (Deque) c; @@ -543,8 +543,8 @@ public void testTraversalEquivalence() { e -> descendingForEachRemaining.add(e)); Collections.reverse(descending); Collections.reverse(descendingForEachRemaining); - assertEquals(iterated, descending); - assertEquals(iterated, descendingForEachRemaining); + mustEqual(iterated, descending); + mustEqual(iterated, descendingForEachRemaining); } } @@ -582,7 +582,7 @@ public void testForEachRemainingConsistentWithDefaultImplementation() { r2 = ConcurrentModificationException.class; assertFalse(impl.isConcurrent()); } - assertEquals(r1, r2); + mustEqual(r1, r2); } /** @@ -604,9 +604,9 @@ public void testRemoveAfterForEachRemaining() { Iterator it = c.iterator(); if (ordered) { if (rnd.nextBoolean()) assertTrue(it.hasNext()); - assertEquals(impl.makeElement(0), it.next()); + mustEqual(impl.makeElement(0), it.next()); if (rnd.nextBoolean()) assertTrue(it.hasNext()); - assertEquals(impl.makeElement(1), it.next()); + mustEqual(impl.makeElement(1), it.next()); } else { if (rnd.nextBoolean()) assertTrue(it.hasNext()); assertTrue(copy.contains(it.next())); @@ -626,7 +626,7 @@ public void testRemoveAfterForEachRemaining() { catch (UnsupportedOperationException ok) { break testCollection; } - assertEquals(n - 1, c.size()); + mustEqual(n - 1, c.size()); if (ordered) { for (int i = 0; i < n - 1; i++) assertTrue(c.contains(impl.makeElement(i))); @@ -642,13 +642,13 @@ public void testRemoveAfterForEachRemaining() { for (int i = 0; i < n; i++) d.add(impl.makeElement(i)); Iterator it = d.descendingIterator(); assertTrue(it.hasNext()); - assertEquals(impl.makeElement(n - 1), it.next()); + mustEqual(impl.makeElement(n - 1), it.next()); assertTrue(it.hasNext()); - assertEquals(impl.makeElement(n - 2), it.next()); + mustEqual(impl.makeElement(n - 2), it.next()); it.forEachRemaining(e -> assertTrue(c.contains(e))); if (testImplementationDetails) { it.remove(); - assertEquals(n - 1, d.size()); + mustEqual(n - 1, d.size()); for (int i = 1; i < n; i++) assertTrue(d.contains(impl.makeElement(i))); assertFalse(d.contains(impl.makeElement(0))); @@ -661,7 +661,6 @@ public void testRemoveAfterForEachRemaining() { */ public void testStreamForEach() throws Throwable { final Collection c = impl.emptyCollection(); - final AtomicLong count = new AtomicLong(0L); final Object x = impl.makeElement(1); final Object y = impl.makeElement(2); final ArrayList found = new ArrayList(); @@ -671,12 +670,12 @@ public void testStreamForEach() throws Throwable { assertTrue(c.add(x)); c.stream().forEach(spy); - assertEquals(Collections.singletonList(x), found); + mustEqual(Collections.singletonList(x), found); found.clear(); assertTrue(c.add(y)); c.stream().forEach(spy); - assertEquals(2, found.size()); + mustEqual(2, found.size()); assertTrue(found.contains(x)); assertTrue(found.contains(y)); found.clear(); @@ -719,7 +718,6 @@ public void testStreamForEachConcurrentStressTest() throws Throwable { */ public void testForEach() throws Throwable { final Collection c = impl.emptyCollection(); - final AtomicLong count = new AtomicLong(0L); final Object x = impl.makeElement(1); final Object y = impl.makeElement(2); final ArrayList found = new ArrayList(); @@ -729,12 +727,12 @@ public void testForEach() throws Throwable { assertTrue(c.add(x)); c.forEach(spy); - assertEquals(Collections.singletonList(x), found); + mustEqual(Collections.singletonList(x), found); found.clear(); assertTrue(c.add(y)); c.forEach(spy); - assertEquals(2, found.size()); + mustEqual(2, found.size()); assertTrue(found.contains(x)); assertTrue(found.contains(y)); found.clear(); @@ -908,7 +906,7 @@ public void testLateBindingStyle() { c.add(one); split.forEachRemaining( e -> { assertSame(e, one); count.getAndIncrement(); }); - assertEquals(1L, count.get()); + mustEqual(1L, count.get()); assertFalse(split.tryAdvance(e -> { throw new AssertionError(); })); assertTrue(c.contains(one)); } @@ -935,7 +933,7 @@ public void testCollectionCopies() throws Exception { Collection c = impl.emptyCollection(); for (int n = rnd.nextInt(4); n--> 0; ) c.add(impl.makeElement(rnd.nextInt())); - assertEquals(c, c); + mustEqual(c, c); if (c instanceof List) assertCollectionsEquals(c, new ArrayList(c)); else if (c instanceof Set) @@ -971,11 +969,11 @@ public void DISABLED_testReplaceAllIsNotStructuralModification() { int size = list.size(), half = size / 2; Iterator it = list.iterator(); for (int i = 0; i < half; i++) - assertEquals(it.next(), copy.get(i)); + mustEqual(it.next(), copy.get(i)); list.replaceAll(n -> n); // ConcurrentModificationException must not be thrown here. for (int i = half; i < size; i++) - assertEquals(it.next(), copy.get(i)); + mustEqual(it.next(), copy.get(i)); } // public void testCollection8DebugFail() { diff --git a/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java b/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java index 2f940855e63..10e035df51f 100644 --- a/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java +++ b/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java @@ -104,14 +104,14 @@ void checkIncomplete(CompletableFuture f) { void checkCompletedNormally(CompletableFuture f, T expectedValue) { checkTimedGet(f, expectedValue); - assertEquals(expectedValue, f.join()); - assertEquals(expectedValue, f.getNow(null)); + mustEqual(expectedValue, f.join()); + mustEqual(expectedValue, f.getNow(null)); T result = null; try { result = f.get(); } catch (Throwable fail) { threadUnexpectedException(fail); } - assertEquals(expectedValue, result); + mustEqual(expectedValue, result); assertTrue(f.isDone()); assertFalse(f.isCancelled()); @@ -235,7 +235,7 @@ void checkCancelled(CompletableFuture f) { * by methods isDone, isCancelled, and getNow */ public void testConstructor() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); checkIncomplete(f); } @@ -244,9 +244,9 @@ public void testConstructor() { * isCancelled, join, get, and getNow */ public void testComplete() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); checkIncomplete(f); assertTrue(f.complete(v1)); assertFalse(f.complete(v1)); @@ -258,7 +258,7 @@ public void testComplete() { * methods isDone, isCancelled, join, get, and getNow */ public void testCompleteExceptionally() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); CFException ex = new CFException(); checkIncomplete(f); f.completeExceptionally(ex); @@ -272,7 +272,7 @@ public void testCompleteExceptionally() { public void testCancel() { for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); checkIncomplete(f); assertTrue(f.cancel(mayInterruptIfRunning)); assertTrue(f.cancel(mayInterruptIfRunning)); @@ -284,7 +284,7 @@ public void testCancel() { * obtrudeValue forces completion with given value */ public void testObtrudeValue() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); checkIncomplete(f); assertTrue(f.complete(one)); checkCompletedNormally(f, one); @@ -307,10 +307,10 @@ public void testObtrudeValue() { * obtrudeException forces completion with given exception */ public void testObtrudeException() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { CFException ex; - CompletableFuture f; + CompletableFuture f; f = new CompletableFuture<>(); assertTrue(f.complete(v1)); @@ -342,22 +342,22 @@ public void testObtrudeException() { */ public void testGetNumberOfDependents() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - assertEquals(0, f.getNumberOfDependents()); + CompletableFuture f = new CompletableFuture<>(); + mustEqual(0, f.getNumberOfDependents()); final CompletableFuture g = m.thenRun(f, new Noop(m)); - assertEquals(1, f.getNumberOfDependents()); - assertEquals(0, g.getNumberOfDependents()); + mustEqual(1, f.getNumberOfDependents()); + mustEqual(0, g.getNumberOfDependents()); final CompletableFuture h = m.thenRun(f, new Noop(m)); - assertEquals(2, f.getNumberOfDependents()); - assertEquals(0, h.getNumberOfDependents()); + mustEqual(2, f.getNumberOfDependents()); + mustEqual(0, h.getNumberOfDependents()); assertTrue(f.complete(v1)); checkCompletedNormally(g, null); checkCompletedNormally(h, null); - assertEquals(0, f.getNumberOfDependents()); - assertEquals(0, g.getNumberOfDependents()); - assertEquals(0, h.getNumberOfDependents()); + mustEqual(0, f.getNumberOfDependents()); + mustEqual(0, g.getNumberOfDependents()); + mustEqual(0, h.getNumberOfDependents()); }} /** @@ -367,7 +367,7 @@ public void testToString_incomplete() { CompletableFuture f = new CompletableFuture<>(); assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]")); if (testImplementationDetails) - assertEquals(identityString(f) + "[Not completed]", + mustEqual(identityString(f) + "[Not completed]", f.toString()); } @@ -376,7 +376,7 @@ public void testToString_normal() { assertTrue(f.complete("foo")); assertTrue(f.toString().matches(".*\\[.*Completed normally.*\\]")); if (testImplementationDetails) - assertEquals(identityString(f) + "[Completed normally]", + mustEqual(identityString(f) + "[Completed normally]", f.toString()); } @@ -414,55 +414,55 @@ abstract static class CheckedAction { CheckedAction(ExecutionMode m) { this.m = m; } void invoked() { m.checkExecutionMode(); - assertEquals(0, invocationCount++); + mustEqual(0, invocationCount++); } - void assertNotInvoked() { assertEquals(0, invocationCount); } - void assertInvoked() { assertEquals(1, invocationCount); } + void assertNotInvoked() { mustEqual(0, invocationCount); } + void assertInvoked() { mustEqual(1, invocationCount); } } - abstract static class CheckedIntegerAction extends CheckedAction { - Integer value; - CheckedIntegerAction(ExecutionMode m) { super(m); } - void assertValue(Integer expected) { + abstract static class CheckedItemAction extends CheckedAction { + Item value; + CheckedItemAction(ExecutionMode m) { super(m); } + void assertValue(Item expected) { assertInvoked(); - assertEquals(expected, value); + mustEqual(expected, value); } } - static class IntegerSupplier extends CheckedAction - implements Supplier + static class ItemSupplier extends CheckedAction + implements Supplier { - final Integer value; - IntegerSupplier(ExecutionMode m, Integer value) { + final Item value; + ItemSupplier(ExecutionMode m, Item value) { super(m); this.value = value; } - public Integer get() { + public Item get() { invoked(); return value; } } // A function that handles and produces null values as well. - static Integer inc(Integer x) { - return (x == null) ? null : x + 1; + static Item inc(Item x) { + return (x == null) ? null : new Item(x.value + 1); } - static class NoopConsumer extends CheckedIntegerAction - implements Consumer + static class NoopConsumer extends CheckedItemAction + implements Consumer { NoopConsumer(ExecutionMode m) { super(m); } - public void accept(Integer x) { + public void accept(Item x) { invoked(); value = x; } } - static class IncFunction extends CheckedIntegerAction - implements Function + static class IncFunction extends CheckedItemAction + implements Function { IncFunction(ExecutionMode m) { super(m); } - public Integer apply(Integer x) { + public Item apply(Item x) { invoked(); return value = inc(x); } @@ -470,27 +470,27 @@ public Integer apply(Integer x) { // Choose non-commutative actions for better coverage // A non-commutative function that handles and produces null values as well. - static Integer subtract(Integer x, Integer y) { + static Item subtract(Item x, Item y) { return (x == null && y == null) ? null : - ((x == null) ? 42 : x.intValue()) - - ((y == null) ? 99 : y.intValue()); + new Item(((x == null) ? 42 : x.value) + - ((y == null) ? 99 : y.value)); } - static class SubtractAction extends CheckedIntegerAction - implements BiConsumer + static class SubtractAction extends CheckedItemAction + implements BiConsumer { SubtractAction(ExecutionMode m) { super(m); } - public void accept(Integer x, Integer y) { + public void accept(Item x, Item y) { invoked(); value = subtract(x, y); } } - static class SubtractFunction extends CheckedIntegerAction - implements BiFunction + static class SubtractFunction extends CheckedItemAction + implements BiFunction { SubtractFunction(ExecutionMode m) { super(m); } - public Integer apply(Integer x, Integer y) { + public Item apply(Item x, Item y) { invoked(); return value = subtract(x, y); } @@ -504,58 +504,58 @@ public void run() { } static class FailingSupplier extends CheckedAction - implements Supplier + implements Supplier { final CFException ex; FailingSupplier(ExecutionMode m) { super(m); ex = new CFException(); } - public Integer get() { + public Item get() { invoked(); throw ex; } } - static class FailingConsumer extends CheckedIntegerAction - implements Consumer + static class FailingConsumer extends CheckedItemAction + implements Consumer { final CFException ex; FailingConsumer(ExecutionMode m) { super(m); ex = new CFException(); } - public void accept(Integer x) { + public void accept(Item x) { invoked(); value = x; throw ex; } } - static class FailingBiConsumer extends CheckedIntegerAction - implements BiConsumer + static class FailingBiConsumer extends CheckedItemAction + implements BiConsumer { final CFException ex; FailingBiConsumer(ExecutionMode m) { super(m); ex = new CFException(); } - public void accept(Integer x, Integer y) { + public void accept(Item x, Item y) { invoked(); value = subtract(x, y); throw ex; } } - static class FailingFunction extends CheckedIntegerAction - implements Function + static class FailingFunction extends CheckedItemAction + implements Function { final CFException ex; FailingFunction(ExecutionMode m) { super(m); ex = new CFException(); } - public Integer apply(Integer x) { + public Item apply(Item x) { invoked(); value = x; throw ex; } } - static class FailingBiFunction extends CheckedIntegerAction - implements BiFunction + static class FailingBiFunction extends CheckedItemAction + implements BiFunction { final CFException ex; FailingBiFunction(ExecutionMode m) { super(m); ex = new CFException(); } - public Integer apply(Integer x, Integer y) { + public Item apply(Item x, Item y) { invoked(); value = subtract(x, y); throw ex; @@ -571,11 +571,11 @@ public void run() { } } - static class CompletableFutureInc extends CheckedIntegerAction - implements Function> + static class CompletableFutureInc extends CheckedItemAction + implements Function> { CompletableFutureInc(ExecutionMode m) { super(m); } - public CompletableFuture apply(Integer x) { + public CompletableFuture apply(Item x) { invoked(); value = x; return CompletableFuture.completedFuture(inc(x)); @@ -583,32 +583,32 @@ public CompletableFuture apply(Integer x) { } static class FailingExceptionalCompletableFutureFunction extends CheckedAction - implements Function> + implements Function> { final CFException ex; FailingExceptionalCompletableFutureFunction(ExecutionMode m) { super(m); ex = new CFException(); } - public CompletableFuture apply(Throwable x) { + public CompletableFuture apply(Throwable x) { invoked(); throw ex; } } static class ExceptionalCompletableFutureFunction extends CheckedAction - implements Function> { - final Integer value = 3; + implements Function> { + final Item value = three; ExceptionalCompletableFutureFunction(ExecutionMode m) { super(m); } - public CompletionStage apply(Throwable x) { + public CompletionStage apply(Throwable x) { invoked(); return CompletableFuture.completedFuture(value); } } - static class FailingCompletableFutureFunction extends CheckedIntegerAction - implements Function> + static class FailingCompletableFutureFunction extends CheckedItemAction + implements Function> { final CFException ex; FailingCompletableFutureFunction(ExecutionMode m) { super(m); ex = new CFException(); } - public CompletableFuture apply(Integer x) { + public CompletableFuture apply(Item x) { invoked(); value = x; throw ex; @@ -730,7 +730,7 @@ public CompletableFuture supplyAsync(Supplier a) { }, ASYNC { public void checkExecutionMode() { - assertEquals(defaultExecutorIsCommonPool, + mustEqual(defaultExecutorIsCommonPool, (ForkJoinPool.commonPool() == ForkJoinTask.getPool())); } public CompletableFuture runAsync(Runnable a) { @@ -951,12 +951,12 @@ public CompletableFuture supplyAsync(Supplier a) { public void testExceptionally_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.exceptionally + final CompletableFuture g = m.exceptionally (f, (Throwable t) -> { ran.getAndIncrement(); throw new AssertionError("should not be called"); @@ -965,7 +965,7 @@ public void testExceptionally_normalCompletion() { checkCompletedNormally(g, v1); checkCompletedNormally(f, v1); - assertEquals(0, ran.get()); + mustEqual(0, ran.get()); }} /** @@ -975,13 +975,13 @@ public void testExceptionally_normalCompletion() { public void testExceptionally_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.exceptionally + final CompletableFuture g = m.exceptionally (f, (Throwable t) -> { m.checkExecutionMode(); assertSame(t, ex); @@ -991,7 +991,7 @@ public void testExceptionally_exceptionalCompletion() { if (createIncomplete) f.completeExceptionally(ex); checkCompletedNormally(g, v1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1005,9 +1005,9 @@ public void testExceptionally_exceptionalCompletionActionFailed() { final AtomicInteger ran = new AtomicInteger(0); final CFException ex1 = new CFException(); final CFException ex2 = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex1); - final CompletableFuture g = m.exceptionally + final CompletableFuture g = m.exceptionally (f, (Throwable t) -> { m.checkExecutionMode(); assertSame(t, ex1); @@ -1018,7 +1018,7 @@ public void testExceptionally_exceptionalCompletionActionFailed() { checkCompletedWithWrappedException(g, ex2); checkCompletedExceptionally(f, ex1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1028,14 +1028,14 @@ public void testExceptionally_exceptionalCompletionActionFailed() { public void testWhenComplete_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.whenComplete + final CompletableFuture g = m.whenComplete (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertSame(result, v1); assertNull(t); @@ -1045,7 +1045,7 @@ public void testWhenComplete_normalCompletion() { checkCompletedNormally(g, v1); checkCompletedNormally(f, v1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1058,11 +1058,11 @@ public void testWhenComplete_exceptionalCompletion() { { final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.whenComplete + final CompletableFuture g = m.whenComplete (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertNull(result); assertSame(t, ex); @@ -1072,7 +1072,7 @@ public void testWhenComplete_exceptionalCompletion() { checkCompletedWithWrappedException(g, ex); checkCompletedExceptionally(f, ex); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1085,11 +1085,11 @@ public void testWhenComplete_sourceCancelled() { for (boolean createIncomplete : new boolean[] { true, false }) { final AtomicInteger ran = new AtomicInteger(0); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); - final CompletableFuture g = m.whenComplete + final CompletableFuture g = m.whenComplete (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertNull(result); assertTrue(t instanceof CancellationException); @@ -1099,7 +1099,7 @@ public void testWhenComplete_sourceCancelled() { checkCompletedWithWrappedCancellationException(g); checkCancelled(f); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1109,15 +1109,15 @@ public void testWhenComplete_sourceCancelled() { public void testWhenComplete_sourceCompletedNormallyActionFailed() { for (boolean createIncomplete : new boolean[] { true, false }) for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.whenComplete + final CompletableFuture g = m.whenComplete (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertSame(result, v1); assertNull(t); @@ -1128,7 +1128,7 @@ public void testWhenComplete_sourceCompletedNormallyActionFailed() { checkCompletedWithWrappedException(g, ex); checkCompletedNormally(f, v1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1143,12 +1143,12 @@ public void testWhenComplete_sourceFailedActionFailed() { final AtomicInteger ran = new AtomicInteger(0); final CFException ex1 = new CFException(); final CFException ex2 = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex1); - final CompletableFuture g = m.whenComplete + final CompletableFuture g = m.whenComplete (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertSame(t, ex1); assertNull(result); @@ -1160,10 +1160,10 @@ public void testWhenComplete_sourceFailedActionFailed() { checkCompletedWithWrappedException(g, ex1); checkCompletedExceptionally(f, ex1); if (testImplementationDetails) { - assertEquals(1, ex1.getSuppressed().length); + mustEqual(1, ex1.getSuppressed().length); assertSame(ex2, ex1.getSuppressed()[0]); } - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1173,14 +1173,14 @@ public void testWhenComplete_sourceFailedActionFailed() { public void testHandle_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final AtomicInteger ran = new AtomicInteger(0); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.handle + final CompletableFuture g = m.handle (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertSame(result, v1); assertNull(t); @@ -1191,7 +1191,7 @@ public void testHandle_normalCompletion() { checkCompletedNormally(g, inc(v1)); checkCompletedNormally(f, v1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1201,15 +1201,15 @@ public void testHandle_normalCompletion() { public void testHandle_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.handle + final CompletableFuture g = m.handle (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertNull(result); assertSame(t, ex); @@ -1220,7 +1220,7 @@ public void testHandle_exceptionalCompletion() { checkCompletedNormally(g, v1); checkCompletedExceptionally(f, ex); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1231,14 +1231,14 @@ public void testHandle_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final AtomicInteger ran = new AtomicInteger(0); if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); - final CompletableFuture g = m.handle + final CompletableFuture g = m.handle (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertNull(result); assertTrue(t instanceof CancellationException); @@ -1249,7 +1249,7 @@ public void testHandle_sourceCancelled() { checkCompletedNormally(g, v1); checkCancelled(f); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1259,15 +1259,15 @@ public void testHandle_sourceCancelled() { public void testHandle_sourceCompletedNormallyActionFailed() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.handle + final CompletableFuture g = m.handle (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertSame(result, v1); assertNull(t); @@ -1278,7 +1278,7 @@ public void testHandle_sourceCompletedNormallyActionFailed() { checkCompletedWithWrappedException(g, ex); checkCompletedNormally(f, v1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1293,12 +1293,12 @@ public void testHandle_sourceFailedActionFailed() { final AtomicInteger ran = new AtomicInteger(0); final CFException ex1 = new CFException(); final CFException ex2 = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex1); - final CompletableFuture g = m.handle + final CompletableFuture g = m.handle (f, - (Integer result, Throwable t) -> { + (Item result, Throwable t) -> { m.checkExecutionMode(); assertNull(result); assertSame(ex1, t); @@ -1309,7 +1309,7 @@ public void testHandle_sourceFailedActionFailed() { checkCompletedWithWrappedException(g, ex2); checkCompletedExceptionally(f, ex1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -1355,7 +1355,7 @@ public void testRunAsync_rejectingExecutor() { assertSame(e.ex, t); } - assertEquals(1, e.count.get()); + mustEqual(1, e.count.get()); } /** @@ -1367,10 +1367,10 @@ public void testSupplyAsync_normalCompletion() { ExecutionMode.EXECUTOR, }; for (ExecutionMode m : executionModes) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final IntegerSupplier r = new IntegerSupplier(m, v1); - final CompletableFuture f = m.supplyAsync(r); + final ItemSupplier r = new ItemSupplier(m, v1); + final CompletableFuture f = m.supplyAsync(r); assertSame(v1, f.join()); checkCompletedNormally(f, v1); r.assertInvoked(); @@ -1387,7 +1387,7 @@ public void testSupplyAsync_exceptionalCompletion() { for (ExecutionMode m : executionModes) { FailingSupplier r = new FailingSupplier(m); - CompletableFuture f = m.supplyAsync(r); + CompletableFuture f = m.supplyAsync(r); checkCompletedWithWrappedException(f, r.ex); r.assertInvoked(); }} @@ -1402,7 +1402,7 @@ public void testSupplyAsync_rejectingExecutor() { assertSame(e.ex, t); } - assertEquals(1, e.count.get()); + mustEqual(1, e.count.get()); } // seq completion methods @@ -1412,9 +1412,9 @@ public void testSupplyAsync_rejectingExecutor() { */ public void testThenRun_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -1447,7 +1447,7 @@ public void testThenRun_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -1479,7 +1479,7 @@ public void testThenRun_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -1509,9 +1509,9 @@ public void testThenRun_sourceCancelled() { */ public void testThenRun_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingRunnable[] rs = new FailingRunnable[6]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingRunnable(m); @@ -1537,19 +1537,19 @@ public void testThenRun_actionFailed() { */ public void testThenApply_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[4]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.thenApply(f, rs[0]); - final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); + final CompletableFuture h0 = m.thenApply(f, rs[0]); + final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); checkIncomplete(h0); checkIncomplete(h1); assertTrue(f.complete(v1)); - final CompletableFuture h2 = m.thenApply(f, rs[2]); - final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); + final CompletableFuture h2 = m.thenApply(f, rs[2]); + final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); checkCompletedNormally(h0, inc(v1)); checkCompletedNormally(h1, inc(v1)); @@ -1567,15 +1567,15 @@ public void testThenApply_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[4]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.thenApply(f, rs[0]); - final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); + final CompletableFuture h0 = m.thenApply(f, rs[0]); + final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); assertTrue(f.completeExceptionally(ex)); - final CompletableFuture h2 = m.thenApply(f, rs[2]); - final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); + final CompletableFuture h2 = m.thenApply(f, rs[2]); + final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); checkCompletedWithWrappedException(h0, ex); checkCompletedWithWrappedException(h1, ex); @@ -1592,15 +1592,15 @@ public void testThenApply_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[4]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.thenApply(f, rs[0]); - final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); + final CompletableFuture h0 = m.thenApply(f, rs[0]); + final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); assertTrue(f.cancel(mayInterruptIfRunning)); - final CompletableFuture h2 = m.thenApply(f, rs[2]); - final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); + final CompletableFuture h2 = m.thenApply(f, rs[2]); + final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); checkCompletedWithWrappedCancellationException(h0); checkCompletedWithWrappedCancellationException(h1); @@ -1615,17 +1615,17 @@ public void testThenApply_sourceCancelled() { */ public void testThenApply_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingFunction[] rs = new FailingFunction[4]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m); - final CompletableFuture h0 = m.thenApply(f, rs[0]); - final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); + final CompletableFuture h0 = m.thenApply(f, rs[0]); + final CompletableFuture h1 = m.applyToEither(f, f, rs[1]); assertTrue(f.complete(v1)); - final CompletableFuture h2 = m.thenApply(f, rs[2]); - final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); + final CompletableFuture h2 = m.thenApply(f, rs[2]); + final CompletableFuture h3 = m.applyToEither(f, f, rs[3]); checkCompletedWithWrappedException(h0, rs[0].ex); checkCompletedWithWrappedException(h1, rs[1].ex); @@ -1639,9 +1639,9 @@ public void testThenApply_actionFailed() { */ public void testThenAccept_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final NoopConsumer[] rs = new NoopConsumer[4]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -1669,7 +1669,7 @@ public void testThenAccept_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final NoopConsumer[] rs = new NoopConsumer[4]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -1694,7 +1694,7 @@ public void testThenAccept_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final NoopConsumer[] rs = new NoopConsumer[4]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -1717,9 +1717,9 @@ public void testThenAccept_sourceCancelled() { */ public void testThenAccept_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingConsumer[] rs = new FailingConsumer[4]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingConsumer(m); @@ -1743,24 +1743,24 @@ public void testThenAccept_actionFailed() { public void testThenCombine_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final SubtractFunction[] rs = new SubtractFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new SubtractFunction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; - final CompletableFuture h0 = m.thenCombine(f, g, rs[0]); - final CompletableFuture h1 = m.thenCombine(fst, fst, rs[1]); + final CompletableFuture h0 = m.thenCombine(f, g, rs[0]); + final CompletableFuture h1 = m.thenCombine(fst, fst, rs[1]); assertTrue(fst.complete(w1)); - final CompletableFuture h2 = m.thenCombine(f, g, rs[2]); - final CompletableFuture h3 = m.thenCombine(fst, fst, rs[3]); + final CompletableFuture h2 = m.thenCombine(f, g, rs[2]); + final CompletableFuture h3 = m.thenCombine(fst, fst, rs[3]); checkIncomplete(h0); rs[0].assertNotInvoked(); checkIncomplete(h2); rs[2].assertNotInvoked(); checkCompletedNormally(h1, subtract(w1, w1)); @@ -1768,7 +1768,7 @@ public void testThenCombine_normalCompletion() { rs[1].assertValue(subtract(w1, w1)); rs[3].assertValue(subtract(w1, w1)); assertTrue(snd.complete(w2)); - final CompletableFuture h4 = m.thenCombine(f, g, rs[4]); + final CompletableFuture h4 = m.thenCombine(f, g, rs[4]); checkCompletedNormally(h0, subtract(v1, v2)); checkCompletedNormally(h2, subtract(v1, v2)); @@ -1789,17 +1789,17 @@ public void testThenCombine_exceptionalCompletion() throws Throwable { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final SubtractFunction r1 = new SubtractFunction(m); final SubtractFunction r2 = new SubtractFunction(m); final SubtractFunction r3 = new SubtractFunction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.completeExceptionally(ex) : () -> fst.complete(v1); @@ -1807,13 +1807,13 @@ public void testThenCombine_exceptionalCompletion() throws Throwable { () -> snd.complete(v1) : () -> snd.completeExceptionally(ex); - final CompletableFuture h1 = m.thenCombine(f, g, r1); + final CompletableFuture h1 = m.thenCombine(f, g, r1); assertTrue(complete1.call()); - final CompletableFuture h2 = m.thenCombine(f, g, r2); + final CompletableFuture h2 = m.thenCombine(f, g, r2); checkIncomplete(h1); checkIncomplete(h2); assertTrue(complete2.call()); - final CompletableFuture h3 = m.thenCombine(f, g, r3); + final CompletableFuture h3 = m.thenCombine(f, g, r3); checkCompletedWithWrappedException(h1, ex); checkCompletedWithWrappedException(h2, ex); @@ -1833,16 +1833,16 @@ public void testThenCombine_sourceCancelled() throws Throwable { for (boolean mayInterruptIfRunning : new boolean[] { true, false }) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final SubtractFunction r1 = new SubtractFunction(m); final SubtractFunction r2 = new SubtractFunction(m); final SubtractFunction r3 = new SubtractFunction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.cancel(mayInterruptIfRunning) : () -> fst.complete(v1); @@ -1850,13 +1850,13 @@ public void testThenCombine_sourceCancelled() throws Throwable { () -> snd.complete(v1) : () -> snd.cancel(mayInterruptIfRunning); - final CompletableFuture h1 = m.thenCombine(f, g, r1); + final CompletableFuture h1 = m.thenCombine(f, g, r1); assertTrue(complete1.call()); - final CompletableFuture h2 = m.thenCombine(f, g, r2); + final CompletableFuture h2 = m.thenCombine(f, g, r2); checkIncomplete(h1); checkIncomplete(h2); assertTrue(complete2.call()); - final CompletableFuture h3 = m.thenCombine(f, g, r3); + final CompletableFuture h3 = m.thenCombine(f, g, r3); checkCompletedWithWrappedCancellationException(h1); checkCompletedWithWrappedCancellationException(h2); @@ -1874,25 +1874,25 @@ public void testThenCombine_sourceCancelled() throws Throwable { public void testThenCombine_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingBiFunction r1 = new FailingBiFunction(m); final FailingBiFunction r2 = new FailingBiFunction(m); final FailingBiFunction r3 = new FailingBiFunction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; - final CompletableFuture h1 = m.thenCombine(f, g, r1); + final CompletableFuture h1 = m.thenCombine(f, g, r1); assertTrue(fst.complete(w1)); - final CompletableFuture h2 = m.thenCombine(f, g, r2); + final CompletableFuture h2 = m.thenCombine(f, g, r2); assertTrue(snd.complete(w2)); - final CompletableFuture h3 = m.thenCombine(f, g, r3); + final CompletableFuture h3 = m.thenCombine(f, g, r3); checkCompletedWithWrappedException(h1, r1.ex); checkCompletedWithWrappedException(h2, r2.ex); @@ -1911,19 +1911,19 @@ public void testThenCombine_actionFailed() { public void testThenAcceptBoth_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final SubtractAction r1 = new SubtractAction(m); final SubtractAction r2 = new SubtractAction(m); final SubtractAction r3 = new SubtractAction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; final CompletableFuture h1 = m.thenAcceptBoth(f, g, r1); assertTrue(fst.complete(w1)); @@ -1953,17 +1953,17 @@ public void testThenAcceptBoth_exceptionalCompletion() throws Throwable { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final SubtractAction r1 = new SubtractAction(m); final SubtractAction r2 = new SubtractAction(m); final SubtractAction r3 = new SubtractAction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.completeExceptionally(ex) : () -> fst.complete(v1); @@ -1997,16 +1997,16 @@ public void testThenAcceptBoth_sourceCancelled() throws Throwable { for (boolean mayInterruptIfRunning : new boolean[] { true, false }) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final SubtractAction r1 = new SubtractAction(m); final SubtractAction r2 = new SubtractAction(m); final SubtractAction r3 = new SubtractAction(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.cancel(mayInterruptIfRunning) : () -> fst.complete(v1); @@ -2038,19 +2038,19 @@ public void testThenAcceptBoth_sourceCancelled() throws Throwable { public void testThenAcceptBoth_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingBiConsumer r1 = new FailingBiConsumer(m); final FailingBiConsumer r2 = new FailingBiConsumer(m); final FailingBiConsumer r3 = new FailingBiConsumer(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; final CompletableFuture h1 = m.thenAcceptBoth(f, g, r1); assertTrue(fst.complete(w1)); @@ -2075,19 +2075,19 @@ public void testThenAcceptBoth_actionFailed() { public void testRunAfterBoth_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final Noop r1 = new Noop(m); final Noop r2 = new Noop(m); final Noop r3 = new Noop(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; final CompletableFuture h1 = m.runAfterBoth(f, g, r1); assertTrue(fst.complete(w1)); @@ -2117,17 +2117,17 @@ public void testRunAfterBoth_exceptionalCompletion() throws Throwable { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final Noop r1 = new Noop(m); final Noop r2 = new Noop(m); final Noop r3 = new Noop(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.completeExceptionally(ex) : () -> fst.complete(v1); @@ -2161,16 +2161,16 @@ public void testRunAfterBoth_sourceCancelled() throws Throwable { for (boolean mayInterruptIfRunning : new boolean[] { true, false }) for (boolean fFirst : new boolean[] { true, false }) for (boolean failFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final Noop r1 = new Noop(m); final Noop r2 = new Noop(m); final Noop r3 = new Noop(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; final Callable complete1 = failFirst ? () -> fst.cancel(mayInterruptIfRunning) : () -> fst.complete(v1); @@ -2202,19 +2202,19 @@ public void testRunAfterBoth_sourceCancelled() throws Throwable { public void testRunAfterBoth_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingRunnable r1 = new FailingRunnable(m); final FailingRunnable r2 = new FailingRunnable(m); final FailingRunnable r3 = new FailingRunnable(m); - final CompletableFuture fst = fFirst ? f : g; - final CompletableFuture snd = !fFirst ? f : g; - final Integer w1 = fFirst ? v1 : v2; - final Integer w2 = !fFirst ? v1 : v2; + final CompletableFuture fst = fFirst ? f : g; + final CompletableFuture snd = !fFirst ? f : g; + final Item w1 = fFirst ? v1 : v2; + final Item w2 = !fFirst ? v1 : v2; final CompletableFuture h1 = m.runAfterBoth(f, g, r1); assertTrue(fst.complete(w1)); @@ -2238,16 +2238,16 @@ public void testRunAfterBoth_actionFailed() { */ public void testApplyToEither_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); checkIncomplete(h0); checkIncomplete(h1); rs[0].assertNotInvoked(); @@ -2255,15 +2255,15 @@ public void testApplyToEither_normalCompletion() { f.complete(v1); checkCompletedNormally(h0, inc(v1)); checkCompletedNormally(h1, inc(v1)); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); checkCompletedNormally(h2, inc(v1)); checkCompletedNormally(h3, inc(v1)); g.complete(v2); // unspecified behavior - both source completions available - final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); - final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); + final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); + final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); rs[4].assertValue(h4.join()); rs[5].assertValue(h5.join()); assertTrue(Objects.equals(inc(v1), h4.join()) || @@ -2286,16 +2286,16 @@ public void testApplyToEither_normalCompletion() { */ public void testApplyToEither_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final IncFunction[] rs = new IncFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); checkIncomplete(h0); checkIncomplete(h1); rs[0].assertNotInvoked(); @@ -2303,24 +2303,24 @@ public void testApplyToEither_exceptionalCompletion() { f.completeExceptionally(ex); checkCompletedWithWrappedException(h0, ex); checkCompletedWithWrappedException(h1, ex); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); checkCompletedWithWrappedException(h2, ex); checkCompletedWithWrappedException(h3, ex); g.complete(v1); // unspecified behavior - both source completions available - final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); - final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); + final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); + final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); try { - assertEquals(inc(v1), h4.join()); + mustEqual(inc(v1), h4.join()); rs[4].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h4, ex); rs[4].assertNotInvoked(); } try { - assertEquals(inc(v1), h5.join()); + mustEqual(inc(v1), h5.join()); rs[5].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h5, ex); @@ -2340,45 +2340,45 @@ public void testApplyToEither_exceptionalCompletion() { public void testApplyToEither_exceptionalCompletion2() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final IncFunction[] rs = new IncFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); assertTrue(fFirst ? f.complete(v1) : g.completeExceptionally(ex)); assertTrue(!fFirst ? f.complete(v1) : g.completeExceptionally(ex)); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); // unspecified behavior - both source completions available try { - assertEquals(inc(v1), h0.join()); + mustEqual(inc(v1), h0.join()); rs[0].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h0, ex); rs[0].assertNotInvoked(); } try { - assertEquals(inc(v1), h1.join()); + mustEqual(inc(v1), h1.join()); rs[1].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h1, ex); rs[1].assertNotInvoked(); } try { - assertEquals(inc(v1), h2.join()); + mustEqual(inc(v1), h2.join()); rs[2].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h2, ex); rs[2].assertNotInvoked(); } try { - assertEquals(inc(v1), h3.join()); + mustEqual(inc(v1), h3.join()); rs[3].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedException(h3, ex); @@ -2395,15 +2395,15 @@ public void testApplyToEither_exceptionalCompletion2() { public void testApplyToEither_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); checkIncomplete(h0); checkIncomplete(h1); rs[0].assertNotInvoked(); @@ -2411,24 +2411,24 @@ public void testApplyToEither_sourceCancelled() { f.cancel(mayInterruptIfRunning); checkCompletedWithWrappedCancellationException(h0); checkCompletedWithWrappedCancellationException(h1); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); checkCompletedWithWrappedCancellationException(h2); checkCompletedWithWrappedCancellationException(h3); g.complete(v1); // unspecified behavior - both source completions available - final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); - final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); + final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); + final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); try { - assertEquals(inc(v1), h4.join()); + mustEqual(inc(v1), h4.join()); rs[4].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h4); rs[4].assertNotInvoked(); } try { - assertEquals(inc(v1), h5.join()); + mustEqual(inc(v1), h5.join()); rs[5].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h5); @@ -2448,44 +2448,44 @@ public void testApplyToEither_sourceCancelled2() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final IncFunction[] rs = new IncFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); assertTrue(fFirst ? f.complete(v1) : g.cancel(mayInterruptIfRunning)); assertTrue(!fFirst ? f.complete(v1) : g.cancel(mayInterruptIfRunning)); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); // unspecified behavior - both source completions available try { - assertEquals(inc(v1), h0.join()); + mustEqual(inc(v1), h0.join()); rs[0].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h0); rs[0].assertNotInvoked(); } try { - assertEquals(inc(v1), h1.join()); + mustEqual(inc(v1), h1.join()); rs[1].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h1); rs[1].assertNotInvoked(); } try { - assertEquals(inc(v1), h2.join()); + mustEqual(inc(v1), h2.join()); rs[2].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h2); rs[2].assertNotInvoked(); } try { - assertEquals(inc(v1), h3.join()); + mustEqual(inc(v1), h3.join()); rs[3].assertValue(inc(v1)); } catch (CompletionException ok) { checkCompletedWithWrappedCancellationException(h3); @@ -2501,19 +2501,19 @@ public void testApplyToEither_sourceCancelled2() { */ public void testApplyToEither_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingFunction[] rs = new FailingFunction[6]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m); - final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); - final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); + final CompletableFuture h0 = m.applyToEither(f, g, rs[0]); + final CompletableFuture h1 = m.applyToEither(g, f, rs[1]); f.complete(v1); - final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); - final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); + final CompletableFuture h2 = m.applyToEither(f, g, rs[2]); + final CompletableFuture h3 = m.applyToEither(g, f, rs[3]); checkCompletedWithWrappedException(h0, rs[0].ex); checkCompletedWithWrappedException(h1, rs[1].ex); checkCompletedWithWrappedException(h2, rs[2].ex); @@ -2523,8 +2523,8 @@ public void testApplyToEither_actionFailed() { g.complete(v2); // unspecified behavior - both source completions available - final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); - final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); + final CompletableFuture h4 = m.applyToEither(f, g, rs[4]); + final CompletableFuture h5 = m.applyToEither(g, f, rs[5]); checkCompletedWithWrappedException(h4, rs[4].ex); assertTrue(Objects.equals(v1, rs[4].value) || @@ -2543,11 +2543,11 @@ public void testApplyToEither_actionFailed() { */ public void testAcceptEither_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final NoopConsumer[] rs = new NoopConsumer[6]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -2595,10 +2595,10 @@ public void testAcceptEither_normalCompletion() { */ public void testAcceptEither_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final NoopConsumer[] rs = new NoopConsumer[6]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -2650,10 +2650,10 @@ public void testAcceptEither_exceptionalCompletion() { public void testAcceptEither_exceptionalCompletion2() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final NoopConsumer[] rs = new NoopConsumer[6]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -2705,10 +2705,10 @@ public void testAcceptEither_exceptionalCompletion2() { public void testAcceptEither_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final NoopConsumer[] rs = new NoopConsumer[6]; for (int i = 0; i < rs.length; i++) rs[i] = new NoopConsumer(m); @@ -2760,11 +2760,11 @@ public void testAcceptEither_sourceCancelled() { */ public void testAcceptEither_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingConsumer[] rs = new FailingConsumer[6]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingConsumer(m); @@ -2802,12 +2802,12 @@ public void testAcceptEither_actionFailed() { */ public void testRunAfterEither_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) for (boolean pushNop : new boolean[] { true, false }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -2855,10 +2855,10 @@ public void testRunAfterEither_normalCompletion() { */ public void testRunAfterEither_exceptionalCompletion() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -2910,10 +2910,10 @@ public void testRunAfterEither_exceptionalCompletion() { public void testRunAfterEither_exceptionalCompletion2() { for (ExecutionMode m : ExecutionMode.values()) for (boolean fFirst : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final CFException ex = new CFException(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -2965,10 +2965,10 @@ public void testRunAfterEither_exceptionalCompletion2() { public void testRunAfterEither_sourceCancelled() { for (ExecutionMode m : ExecutionMode.values()) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final Noop[] rs = new Noop[6]; for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m); @@ -3020,11 +3020,11 @@ public void testRunAfterEither_sourceCancelled() { */ public void testRunAfterEither_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) - for (Integer v1 : new Integer[] { 1, null }) - for (Integer v2 : new Integer[] { 2, null }) + for (Item v1 : new Item[] { one, null }) + for (Item v2 : new Item[] { two, null }) { - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); final FailingRunnable[] rs = new FailingRunnable[6]; for (int i = 0; i < rs.length; i++) rs[i] = new FailingRunnable(m); @@ -3055,12 +3055,12 @@ public void testRunAfterEither_actionFailed() { public void testThenCompose_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final CompletableFutureInc r = new CompletableFutureInc(m); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.thenCompose(f, r); + final CompletableFuture g = m.thenCompose(f, r); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedNormally(g, inc(v1)); @@ -3078,9 +3078,9 @@ public void testThenCompose_exceptionalCompletion() { { final CFException ex = new CFException(); final CompletableFutureInc r = new CompletableFutureInc(m); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.thenCompose(f, r); + final CompletableFuture g = m.thenCompose(f, r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedWithWrappedException(g, ex); @@ -3094,13 +3094,13 @@ public void testThenCompose_exceptionalCompletion() { public void testThenCompose_actionFailed() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingCompletableFutureFunction r = new FailingCompletableFutureFunction(m); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.thenCompose(f, r); + final CompletableFuture g = m.thenCompose(f, r); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedWithWrappedException(g, r.ex); @@ -3115,10 +3115,10 @@ public void testThenCompose_sourceCancelled() { for (boolean createIncomplete : new boolean[] { true, false }) for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final CompletableFutureInc r = new CompletableFutureInc(m); if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); - final CompletableFuture g = m.thenCompose(f, r); + final CompletableFuture g = m.thenCompose(f, r); if (createIncomplete) { checkIncomplete(g); assertTrue(f.cancel(mayInterruptIfRunning)); @@ -3134,12 +3134,12 @@ public void testThenCompose_sourceCancelled() { public void testThenCompose_actionReturnsFailingFuture() { for (ExecutionMode m : ExecutionMode.values()) for (int order = 0; order < 6; order++) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); - final CompletableFuture h; + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture h; // Test all permutations of orders switch (order) { case 0: @@ -3187,13 +3187,13 @@ public void testThenCompose_actionReturnsFailingFuture() { public void testExceptionallyCompose_normalCompletion() { for (ExecutionMode m : ExecutionMode.values()) for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(m); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletableFuture g = m.exceptionallyCompose(f, r); + final CompletableFuture g = m.exceptionallyCompose(f, r); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedNormally(f, v1); @@ -3212,9 +3212,9 @@ public void testExceptionallyCompose_exceptionalCompletion() { final CFException ex = new CFException(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(m); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.exceptionallyCompose(f, r); + final CompletableFuture g = m.exceptionallyCompose(f, r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -3230,11 +3230,11 @@ public void testExceptionallyCompose_actionFailed() { for (boolean createIncomplete : new boolean[] { true, false }) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingExceptionalCompletableFutureFunction r = new FailingExceptionalCompletableFutureFunction(m); if (!createIncomplete) f.completeExceptionally(ex); - final CompletableFuture g = m.exceptionallyCompose(f, r); + final CompletableFuture g = m.exceptionallyCompose(f, r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -3252,9 +3252,9 @@ public void testExceptionallyCompose_actionReturnsFailingFuture() { { final CFException ex0 = new CFException(); final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); - final CompletableFuture g = new CompletableFuture<>(); - final CompletableFuture h; + final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture g = new CompletableFuture<>(); + final CompletableFuture h; // Test all permutations of orders switch (order) { case 0: @@ -3312,8 +3312,9 @@ public void testAllOf_empty() throws Exception { */ public void testAllOf_normal() throws Exception { for (int k = 1; k < 10; k++) { - CompletableFuture[] fs - = (CompletableFuture[]) new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs + = (CompletableFuture[]) new CompletableFuture[k]; for (int i = 0; i < k; i++) fs[i] = new CompletableFuture<>(); CompletableFuture f = CompletableFuture.allOf(fs); @@ -3329,8 +3330,9 @@ public void testAllOf_normal() throws Exception { public void testAllOf_normal_backwards() throws Exception { for (int k = 1; k < 10; k++) { - CompletableFuture[] fs - = (CompletableFuture[]) new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs + = (CompletableFuture[]) new CompletableFuture[k]; for (int i = 0; i < k; i++) fs[i] = new CompletableFuture<>(); CompletableFuture f = CompletableFuture.allOf(fs); @@ -3346,18 +3348,20 @@ public void testAllOf_normal_backwards() throws Exception { public void testAllOf_exceptional() throws Exception { for (int k = 1; k < 10; k++) { - CompletableFuture[] fs - = (CompletableFuture[]) new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs + = (CompletableFuture[]) new CompletableFuture[k]; CFException ex = new CFException(); for (int i = 0; i < k; i++) fs[i] = new CompletableFuture<>(); CompletableFuture f = CompletableFuture.allOf(fs); for (int i = 0; i < k; i++) { + Item I = itemFor(i); checkIncomplete(f); checkIncomplete(CompletableFuture.allOf(fs)); if (i != k / 2) { - fs[i].complete(i); - checkCompletedNormally(fs[i], i); + fs[i].complete(I); + checkCompletedNormally(fs[i], I); } else { fs[i].completeExceptionally(ex); checkCompletedExceptionally(fs[i], ex); @@ -3372,7 +3376,7 @@ public void testAllOf_exceptional() throws Exception { * anyOf(no component futures) returns an incomplete future */ public void testAnyOf_empty() throws Exception { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { CompletableFuture f = CompletableFuture.anyOf(); checkIncomplete(f); @@ -3387,31 +3391,35 @@ public void testAnyOf_empty() throws Exception { */ public void testAnyOf_normal() throws Exception { for (int k = 0; k < 10; k++) { - CompletableFuture[] fs = new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs = + (CompletableFuture[])new CompletableFuture[k]; for (int i = 0; i < k; i++) fs[i] = new CompletableFuture<>(); CompletableFuture f = CompletableFuture.anyOf(fs); checkIncomplete(f); for (int i = 0; i < k; i++) { - fs[i].complete(i); - checkCompletedNormally(f, 0); - int x = (int) CompletableFuture.anyOf(fs).join(); - assertTrue(0 <= x && x <= i); + fs[i].complete(itemFor(i)); + checkCompletedNormally(f, zero); + Item x = (Item)CompletableFuture.anyOf(fs).join(); + assertTrue(0 <= x.value && x.value <= i); } } } public void testAnyOf_normal_backwards() throws Exception { for (int k = 0; k < 10; k++) { - CompletableFuture[] fs = new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs = + (CompletableFuture[])new CompletableFuture[k]; for (int i = 0; i < k; i++) fs[i] = new CompletableFuture<>(); CompletableFuture f = CompletableFuture.anyOf(fs); checkIncomplete(f); for (int i = k - 1; i >= 0; i--) { - fs[i].complete(i); - checkCompletedNormally(f, k - 1); - int x = (int) CompletableFuture.anyOf(fs).join(); - assertTrue(i <= x && x <= k - 1); + fs[i].complete(itemFor(i)); + checkCompletedNormally(f, itemFor(k - 1)); + Item x = (Item)CompletableFuture.anyOf(fs).join(); + assertTrue(i <= x.value && x.value <= k - 1); } } } @@ -3421,7 +3429,9 @@ public void testAnyOf_normal_backwards() throws Exception { */ public void testAnyOf_exceptional() throws Exception { for (int k = 0; k < 10; k++) { - CompletableFuture[] fs = new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs = + (CompletableFuture[])new CompletableFuture[k]; CFException[] exs = new CFException[k]; for (int i = 0; i < k; i++) { fs[i] = new CompletableFuture<>(); @@ -3439,7 +3449,9 @@ public void testAnyOf_exceptional() throws Exception { public void testAnyOf_exceptional_backwards() throws Exception { for (int k = 0; k < 10; k++) { - CompletableFuture[] fs = new CompletableFuture[k]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs = + (CompletableFuture[])new CompletableFuture[k]; CFException[] exs = new CFException[k]; for (int i = 0; i < k; i++) { fs[i] = new CompletableFuture<>(); @@ -3460,9 +3472,9 @@ public void testAnyOf_exceptional_backwards() throws Exception { */ @SuppressWarnings("FutureReturnValueIgnored") public void testNPE() { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture g = new CompletableFuture<>(); - CompletableFuture nullFuture = (CompletableFuture)null; + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture g = new CompletableFuture<>(); + CompletableFuture nullFuture = (CompletableFuture)null; ThreadExecutor exec = new ThreadExecutor(); assertThrows( @@ -3470,7 +3482,7 @@ public void testNPE() { () -> CompletableFuture.supplyAsync(null), () -> CompletableFuture.supplyAsync(null, exec), - () -> CompletableFuture.supplyAsync(new IntegerSupplier(ExecutionMode.SYNC, 42), null), + () -> CompletableFuture.supplyAsync(new ItemSupplier(ExecutionMode.SYNC, fortytwo), null), () -> CompletableFuture.runAsync(null), () -> CompletableFuture.runAsync(null, exec), @@ -3567,32 +3579,32 @@ public void testNPE() { () -> CompletableFuture.delayedExecutor(1L, null), () -> f.orTimeout(1L, null), - () -> f.completeOnTimeout(42, 1L, null), + () -> f.completeOnTimeout(fortytwo, 1L, null), () -> CompletableFuture.failedFuture(null), () -> CompletableFuture.failedStage(null)); - assertEquals(0, exec.count.get()); + mustEqual(0, exec.count.get()); } /** * Test submissions to an executor that rejects all tasks. */ public void testRejectingExecutor() { - for (Integer v : new Integer[] { 1, null }) + for (Item v : new Item[] { one, null }) { final CountingRejectingExecutor e = new CountingRejectingExecutor(); - final CompletableFuture complete = CompletableFuture.completedFuture(v); - final CompletableFuture incomplete = new CompletableFuture<>(); + final CompletableFuture complete = CompletableFuture.completedFuture(v); + final CompletableFuture incomplete = new CompletableFuture<>(); List> futures = new ArrayList<>(); - List> srcs = new ArrayList<>(); + List> srcs = new ArrayList<>(); srcs.add(complete); srcs.add(incomplete); - for (CompletableFuture src : srcs) { + for (CompletableFuture src : srcs) { List> fs = new ArrayList<>(); fs.add(src.thenRunAsync(() -> {}, e)); fs.add(src.thenAcceptAsync(z -> {}, e)); @@ -3658,7 +3670,7 @@ public void testRejectingExecutor() { for (CompletableFuture future : futures) checkCompletedWithWrappedException(future, e.ex); - assertEquals(futures.size(), e.count.get()); + mustEqual(futures.size(), e.count.get()); }} /** @@ -3667,12 +3679,12 @@ public void testRejectingExecutor() { * explicitly completed. */ public void testRejectingExecutorNeverInvoked() { - for (Integer v : new Integer[] { 1, null }) + for (Item v : new Item[] { one, null }) { final CountingRejectingExecutor e = new CountingRejectingExecutor(); - final CompletableFuture complete = CompletableFuture.completedFuture(v); - final CompletableFuture incomplete = new CompletableFuture<>(); + final CompletableFuture complete = CompletableFuture.completedFuture(v); + final CompletableFuture incomplete = new CompletableFuture<>(); List> fs = new ArrayList<>(); fs.add(incomplete.thenRunAsync(() -> {}, e)); @@ -3711,14 +3723,14 @@ public void testRejectingExecutorNeverInvoked() { for (CompletableFuture future : fs) checkCompletedNormally(future, null); - assertEquals(0, e.count.get()); + mustEqual(0, e.count.get()); }} /** * toCompletableFuture returns this CompletableFuture. */ public void testToCompletableFuture() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); assertSame(f, f.toCompletableFuture()); } @@ -3728,10 +3740,10 @@ public void testToCompletableFuture() { * newIncompleteFuture returns an incomplete CompletableFuture */ public void testNewIncompleteFuture() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture g = f.newIncompleteFuture(); + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture g = f.newIncompleteFuture(); checkIncomplete(f); checkIncomplete(g); f.complete(v1); @@ -3748,9 +3760,9 @@ public void testNewIncompleteFuture() { public void testCompletedStage() { AtomicInteger x = new AtomicInteger(0); AtomicReference r = new AtomicReference<>(); - CompletionStage f = CompletableFuture.completedStage(1); - f.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v);}); - assertEquals(x.get(), 1); + CompletionStage f = CompletableFuture.completedStage(one); + f.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v.value);}); + mustEqual(x.get(), 1); assertNull(r.get()); } @@ -3759,7 +3771,7 @@ public void testCompletedStage() { * it supports more than one thread. */ public void testDefaultExecutor() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); Executor e = f.defaultExecutor(); Executor c = ForkJoinPool.commonPool(); if (ForkJoinPool.getCommonPoolParallelism() > 1) @@ -3774,31 +3786,21 @@ public void testDefaultExecutor() { */ public void testFailedFuture() { CFException ex = new CFException(); - CompletableFuture f = CompletableFuture.failedFuture(ex); + CompletableFuture f = CompletableFuture.failedFuture(ex); checkCompletedExceptionally(f, ex); } - /** - * failedFuture(null) throws NPE - */ - public void testFailedFuture_null() { - try { - CompletableFuture f = CompletableFuture.failedFuture(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - /** * copy returns a CompletableFuture that is completed normally, * with the same value, when source is. */ public void testCopy_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - CompletableFuture g = f.copy(); + CompletableFuture g = f.copy(); if (createIncomplete) { checkIncomplete(f); checkIncomplete(g); @@ -3816,9 +3818,9 @@ public void testCopy_exceptionalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) { CFException ex = new CFException(); - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) f.completeExceptionally(ex); - CompletableFuture g = f.copy(); + CompletableFuture g = f.copy(); if (createIncomplete) { checkIncomplete(f); checkIncomplete(g); @@ -3832,8 +3834,8 @@ public void testCopy_exceptionalCompletion() { * Completion of a copy does not complete its source. */ public void testCopy_oneWayPropagation() { - CompletableFuture f = new CompletableFuture<>(); - assertTrue(f.copy().complete(1)); + CompletableFuture f = new CompletableFuture<>(); + assertTrue(f.copy().complete(one)); assertTrue(f.copy().complete(null)); assertTrue(f.copy().cancel(true)); assertTrue(f.copy().cancel(false)); @@ -3846,15 +3848,15 @@ public void testCopy_oneWayPropagation() { * completed normally, with the same value, when source is. */ public void testMinimalCompletionStage() { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage g = f.minimalCompletionStage(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage g = f.minimalCompletionStage(); AtomicInteger x = new AtomicInteger(0); AtomicReference r = new AtomicReference<>(); checkIncomplete(f); - g.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v);}); - f.complete(1); - checkCompletedNormally(f, 1); - assertEquals(x.get(), 1); + g.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v.value);}); + f.complete(one); + checkCompletedNormally(f, one); + mustEqual(x.get(), 1); assertNull(r.get()); } @@ -3863,17 +3865,17 @@ public void testMinimalCompletionStage() { * completed exceptionally when source is. */ public void testMinimalCompletionStage2() { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage g = f.minimalCompletionStage(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage g = f.minimalCompletionStage(); AtomicInteger x = new AtomicInteger(0); AtomicReference r = new AtomicReference<>(); - g.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v);}); + g.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v.value);}); checkIncomplete(f); CFException ex = new CFException(); f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); - assertEquals(x.get(), 0); - assertEquals(r.get().getCause(), ex); + mustEqual(x.get(), 0); + mustEqual(r.get().getCause(), ex); } /** @@ -3882,21 +3884,21 @@ public void testMinimalCompletionStage2() { */ public void testFailedStage() { CFException ex = new CFException(); - CompletionStage f = CompletableFuture.failedStage(ex); + CompletionStage f = CompletableFuture.failedStage(ex); AtomicInteger x = new AtomicInteger(0); AtomicReference r = new AtomicReference<>(); - f.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v);}); - assertEquals(x.get(), 0); - assertEquals(r.get(), ex); + f.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v.value);}); + mustEqual(x.get(), 0); + mustEqual(r.get(), ex); } /** * completeAsync completes with value of given supplier */ public void testCompleteAsync() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); f.completeAsync(() -> v1); f.join(); checkCompletedNormally(f, v1); @@ -3906,7 +3908,7 @@ public void testCompleteAsync() { * completeAsync completes exceptionally if given supplier throws */ public void testCompleteAsync2() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); CFException ex = new CFException(); f.completeAsync(() -> { throw ex; }); try { @@ -3920,14 +3922,14 @@ public void testCompleteAsync2() { * completeAsync with given executor completes with value of given supplier */ public void testCompleteAsync3() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); ThreadExecutor executor = new ThreadExecutor(); f.completeAsync(() -> v1, executor); assertSame(v1, f.join()); checkCompletedNormally(f, v1); - assertEquals(1, executor.count.get()); + mustEqual(1, executor.count.get()); }} /** @@ -3935,7 +3937,7 @@ public void testCompleteAsync3() { * given supplier throws */ public void testCompleteAsync4() { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); CFException ex = new CFException(); ThreadExecutor executor = new ThreadExecutor(); f.completeAsync(() -> { throw ex; }, executor); @@ -3944,7 +3946,7 @@ public void testCompleteAsync4() { shouldThrow(); } catch (CompletionException success) {} checkCompletedWithWrappedException(f, ex); - assertEquals(1, executor.count.get()); + mustEqual(1, executor.count.get()); } /** @@ -3952,7 +3954,7 @@ public void testCompleteAsync4() { */ public void testOrTimeout_timesOut() { long timeoutMillis = timeoutMillis(); - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); long startTime = System.nanoTime(); assertSame(f, f.orTimeout(timeoutMillis, MILLISECONDS)); checkCompletedWithTimeoutException(f); @@ -3963,10 +3965,10 @@ public void testOrTimeout_timesOut() { * orTimeout completes normally if completed before timeout */ public void testOrTimeout_completed() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture g = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture g = new CompletableFuture<>(); long startTime = System.nanoTime(); f.complete(v1); assertSame(f, f.orTimeout(LONG_DELAY_MS, MILLISECONDS)); @@ -3981,21 +3983,21 @@ public void testOrTimeout_completed() { * completeOnTimeout completes with given value if not complete */ public void testCompleteOnTimeout_timesOut() { - testInParallel(() -> testCompleteOnTimeout_timesOut(42), + testInParallel(() -> testCompleteOnTimeout_timesOut(fortytwo), () -> testCompleteOnTimeout_timesOut(null)); } /** * completeOnTimeout completes with given value if not complete */ - public void testCompleteOnTimeout_timesOut(Integer v) { + public void testCompleteOnTimeout_timesOut(Item v) { long timeoutMillis = timeoutMillis(); - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); long startTime = System.nanoTime(); assertSame(f, f.completeOnTimeout(v, timeoutMillis, MILLISECONDS)); assertSame(v, f.join()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis); - f.complete(99); // should have no effect + f.complete(ninetynine); // should have no effect checkCompletedNormally(f, v); } @@ -4003,14 +4005,14 @@ public void testCompleteOnTimeout_timesOut(Integer v) { * completeOnTimeout has no effect if completed within timeout */ public void testCompleteOnTimeout_completed() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture g = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture g = new CompletableFuture<>(); long startTime = System.nanoTime(); f.complete(v1); - assertSame(f, f.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS)); - assertSame(g, g.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS)); + mustEqual(f, f.completeOnTimeout(minusOne, LONG_DELAY_MS, MILLISECONDS)); + mustEqual(g, g.completeOnTimeout(minusOne, LONG_DELAY_MS, MILLISECONDS)); g.complete(v1); checkCompletedNormally(f, v1); checkCompletedNormally(g, v1); @@ -4022,12 +4024,12 @@ public void testCompleteOnTimeout_completed() { */ public void testDelayedExecutor() { testInParallel(() -> testDelayedExecutor(null, null), - () -> testDelayedExecutor(null, 1), - () -> testDelayedExecutor(new ThreadExecutor(), 1), - () -> testDelayedExecutor(new ThreadExecutor(), 1)); + () -> testDelayedExecutor(null, one), + () -> testDelayedExecutor(new ThreadExecutor(), one), + () -> testDelayedExecutor(new ThreadExecutor(), one)); } - public void testDelayedExecutor(Executor executor, Integer v) throws Exception { + public void testDelayedExecutor(Executor executor, Item v) throws Exception { long timeoutMillis = timeoutMillis(); // Use an "unreasonably long" long timeout to catch lingering threads long longTimeoutMillis = 1000 * 60 * 60 * 24; @@ -4040,9 +4042,9 @@ public void testDelayedExecutor(Executor executor, Integer v) throws Exception { longDelayer = CompletableFuture.delayedExecutor(longTimeoutMillis, MILLISECONDS, executor); } long startTime = System.nanoTime(); - CompletableFuture f = + CompletableFuture f = CompletableFuture.supplyAsync(() -> v, delayer); - CompletableFuture g = + CompletableFuture g = CompletableFuture.supplyAsync(() -> v, longDelayer); assertNull(g.getNow(null)); @@ -4087,14 +4089,14 @@ public void testExceptionPropagationReusesResultObject() { for (ExecutionMode m : ExecutionMode.values()) { final CFException ex = new CFException(); - final CompletableFuture v42 = CompletableFuture.completedFuture(42); - final CompletableFuture incomplete = new CompletableFuture<>(); + final CompletableFuture v42 = CompletableFuture.completedFuture(fortytwo); + final CompletableFuture incomplete = new CompletableFuture<>(); final Runnable noopRunnable = new Noop(m); - final Consumer noopConsumer = new NoopConsumer(m); - final Function incFunction = new IncFunction(m); + final Consumer noopConsumer = new NoopConsumer(m); + final Function incFunction = new IncFunction(m); - List, CompletableFuture>> funs + List, CompletableFuture>> funs = new ArrayList<>(); funs.add(y -> m.thenRun(y, noopRunnable)); @@ -4112,7 +4114,7 @@ public void testExceptionPropagationReusesResultObject() { funs.add(y -> m.thenCombine(y, v42, new SubtractFunction(m))); funs.add(y -> m.thenCombine(v42, y, new SubtractFunction(m))); - funs.add(y -> m.whenComplete(y, (Integer r, Throwable t) -> {})); + funs.add(y -> m.whenComplete(y, (Item r, Throwable t) -> {})); funs.add(y -> m.thenCompose(y, new CompletableFutureInc(m))); @@ -4123,21 +4125,21 @@ public void testExceptionPropagationReusesResultObject() { funs.add(y -> CompletableFuture.anyOf(y, incomplete)); funs.add(y -> CompletableFuture.anyOf(incomplete, y)); - for (Function, CompletableFuture> + for (Function, CompletableFuture> fun : funs) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); f.completeExceptionally(ex); - CompletableFuture src = m.thenApply(f, incFunction); + CompletableFuture src = m.thenApply(f, incFunction); checkCompletedWithWrappedException(src, ex); CompletableFuture dep = fun.apply(src); checkCompletedWithWrappedException(dep, ex); assertSame(resultOf(src), resultOf(dep)); } - for (Function, CompletableFuture> + for (Function, CompletableFuture> fun : funs) { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture src = m.thenApply(f, incFunction); + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture src = m.thenApply(f, incFunction); CompletableFuture dep = fun.apply(src); f.completeExceptionally(ex); checkCompletedWithWrappedException(src, ex); @@ -4146,12 +4148,12 @@ public void testExceptionPropagationReusesResultObject() { } for (boolean mayInterruptIfRunning : new boolean[] { true, false }) - for (Function, CompletableFuture> + for (Function, CompletableFuture> fun : funs) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); f.cancel(mayInterruptIfRunning); checkCancelled(f); - CompletableFuture src = m.thenApply(f, incFunction); + CompletableFuture src = m.thenApply(f, incFunction); checkCompletedWithWrappedCancellationException(src); CompletableFuture dep = fun.apply(src); checkCompletedWithWrappedCancellationException(dep); @@ -4159,10 +4161,10 @@ public void testExceptionPropagationReusesResultObject() { } for (boolean mayInterruptIfRunning : new boolean[] { true, false }) - for (Function, CompletableFuture> + for (Function, CompletableFuture> fun : funs) { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture src = m.thenApply(f, incFunction); + CompletableFuture f = new CompletableFuture<>(); + CompletableFuture src = m.thenApply(f, incFunction); CompletableFuture dep = fun.apply(src); f.cancel(mayInterruptIfRunning); checkCancelled(f); @@ -4202,12 +4204,12 @@ public void testMinimalCompletionStage_minimality() { .filter(method -> !permittedMethodSignatures.contains(toSignature.apply(method))) .collect(Collectors.toList()); - List> stages = new ArrayList<>(); - CompletionStage min = - new CompletableFuture().minimalCompletionStage(); + List> stages = new ArrayList<>(); + CompletionStage min = + new CompletableFuture().minimalCompletionStage(); stages.add(min); stages.add(min.thenApply(x -> x)); - stages.add(CompletableFuture.completedStage(1)); + stages.add(CompletableFuture.completedStage(one)); stages.add(CompletableFuture.failedStage(new CFException())); List bugs = new ArrayList<>(); @@ -4217,14 +4219,11 @@ public void testMinimalCompletionStage_minimality() { // Manufacture boxed primitives for primitive params for (int i = 0; i < args.length; i++) { Class type = parameterTypes[i]; - if (parameterTypes[i] == boolean.class) - args[i] = false; - else if (parameterTypes[i] == int.class) - args[i] = 0; - else if (parameterTypes[i] == long.class) - args[i] = 0L; + if (type == boolean.class) args[i] = false; + else if (type == int.class) args[i] = 0; + else if (type == long.class) args[i] = 0L; } - for (CompletionStage stage : stages) { + for (CompletionStage stage : stages) { try { method.invoke(stage, args); bugs.add(method); @@ -4248,12 +4247,12 @@ else if (parameterTypes[i] == long.class) */ public void testMinimalCompletionStage_toCompletableFuture_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); if (!createIncomplete) assertTrue(f.complete(v1)); - CompletableFuture g = minimal.toCompletableFuture(); + CompletableFuture g = minimal.toCompletableFuture(); if (createIncomplete) { checkIncomplete(f); checkIncomplete(g); @@ -4271,10 +4270,10 @@ public void testMinimalCompletionStage_toCompletableFuture_exceptionalCompletion for (boolean createIncomplete : new boolean[] { true, false }) { CFException ex = new CFException(); - CompletableFuture f = new CompletableFuture<>(); - CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); if (!createIncomplete) f.completeExceptionally(ex); - CompletableFuture g = minimal.toCompletableFuture(); + CompletableFuture g = minimal.toCompletableFuture(); if (createIncomplete) { checkIncomplete(f); checkIncomplete(g); @@ -4288,11 +4287,11 @@ public void testMinimalCompletionStage_toCompletableFuture_exceptionalCompletion * minimalStage.toCompletableFuture() gives mutable CompletableFuture */ public void testMinimalCompletionStage_toCompletableFuture_mutable() { - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage minimal = f.minimalCompletionStage(); - CompletableFuture g = minimal.toCompletableFuture(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture g = minimal.toCompletableFuture(); assertTrue(g.complete(v1)); checkCompletedNormally(g, v1); checkIncomplete(f); @@ -4304,14 +4303,14 @@ public void testMinimalCompletionStage_toCompletableFuture_mutable() { */ public void testMinimalCompletionStage_toCompletableFuture_join() throws Exception { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); - CompletionStage minimal = f.minimalCompletionStage(); + CompletionStage minimal = f.minimalCompletionStage(); if (createIncomplete) assertTrue(f.complete(v1)); - assertEquals(v1, minimal.toCompletableFuture().join()); - assertEquals(v1, minimal.toCompletableFuture().get()); + mustEqual(v1, minimal.toCompletableFuture().join()); + mustEqual(v1, minimal.toCompletableFuture().get()); checkCompletedNormally(minimal.toCompletableFuture(), v1); }} @@ -4320,16 +4319,16 @@ public void testMinimalCompletionStage_toCompletableFuture_join() throws Excepti * does not complete its source. */ public void testMinimalCompletionStage_toCompletableFuture_oneWayPropagation() { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage g = f.minimalCompletionStage(); - assertTrue(g.toCompletableFuture().complete(1)); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage g = f.minimalCompletionStage(); + assertTrue(g.toCompletableFuture().complete(one)); assertTrue(g.toCompletableFuture().complete(null)); assertTrue(g.toCompletableFuture().cancel(true)); assertTrue(g.toCompletableFuture().cancel(false)); assertTrue(g.toCompletableFuture().completeExceptionally(new CFException())); checkIncomplete(g.toCompletableFuture()); - f.complete(1); - checkCompletedNormally(g.toCompletableFuture(), 1); + f.complete(one); + checkCompletedNormally(g.toCompletableFuture(), one); } /** Demo utility method for external reliable toCompletableFuture */ @@ -4353,18 +4352,18 @@ static T join(CompletionStage stage) { */ public void testMinimalCompletionStage_join_by_hand() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - CompletableFuture f = new CompletableFuture<>(); - CompletionStage minimal = f.minimalCompletionStage(); - CompletableFuture g = new CompletableFuture<>(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture g = new CompletableFuture<>(); if (!createIncomplete) assertTrue(f.complete(v1)); minimal.thenAccept(x -> g.complete(x)); if (createIncomplete) assertTrue(f.complete(v1)); g.join(); checkCompletedNormally(g, v1); checkCompletedNormally(f, v1); - assertEquals(v1, join(minimal)); + mustEqual(v1, join(minimal)); }} static class Monad { @@ -4411,7 +4410,7 @@ static void assertFutureEquals(CompletableFuture f, if (fex != null || gex != null) assertSame(fex.getClass(), gex.getClass()); else - assertEquals(fval, gval); + mustEqual(fval, gval); } static class PlusFuture extends CompletableFuture { @@ -4521,18 +4520,18 @@ public void testRecursiveChains() throws Throwable { { final int val = 42; final int n = expensiveTests ? 1_000 : 2; - CompletableFuture head = new CompletableFuture<>(); - CompletableFuture tail = head; + CompletableFuture head = new CompletableFuture<>(); + CompletableFuture tail = head; for (int i = 0; i < n; i++) { - if (addDeadEnds) m.thenApply(tail, v -> v + 1); - tail = m.thenApply(tail, v -> v + 1); - if (addDeadEnds) m.applyToEither(tail, tail, v -> v + 1); - tail = m.applyToEither(tail, tail, v -> v + 1); - if (addDeadEnds) m.thenCombine(tail, tail, (v, w) -> v + 1); - tail = m.thenCombine(tail, tail, (v, w) -> v + 1); + if (addDeadEnds) m.thenApply(tail, v -> new Item(v.value + 1)); + tail = m.thenApply(tail, v -> new Item(v.value + 1)); + if (addDeadEnds) m.applyToEither(tail, tail, v -> new Item(v.value + 1)); + tail = m.applyToEither(tail, tail, v -> new Item(v.value + 1)); + if (addDeadEnds) m.thenCombine(tail, tail, (v, w) -> new Item(v.value + 1)); + tail = m.thenCombine(tail, tail, (v, w) -> new Item(v.value + 1)); } - head.complete(val); - assertEquals(val + 3 * n, (int) tail.join()); + head.complete(itemFor(val)); + mustEqual(val + 3 * n, tail.join()); }} /** @@ -4565,15 +4564,15 @@ public void testManyDependents() throws Throwable { new CompletableFuture().applyToEither(head, x -> count.getAndIncrement()); } head.complete(null); - assertEquals(5 * 3 * n, count.get()); + mustEqual(5 * 3 * n, count.get()); } /** ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest tck */ @SuppressWarnings("FutureReturnValueIgnored") public void testCoCompletionGarbageRetention() throws Throwable { final int n = expensiveTests ? 1_000_000 : 10; - final CompletableFuture incomplete = new CompletableFuture<>(); - CompletableFuture f; + final CompletableFuture incomplete = new CompletableFuture<>(); + CompletableFuture f; for (int i = 0; i < n; i++) { f = new CompletableFuture<>(); f.runAfterEither(incomplete, () -> {}); @@ -4617,11 +4616,12 @@ public void testCoCompletionGarbageRetention() throws Throwable { * cvs update -D '2016-05-01' ./src/main/java/util/concurrent/CompletableFuture.java && ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testAnyOfGarbageRetention tck; cvs update -A */ public void testAnyOfGarbageRetention() throws Throwable { - for (Integer v : new Integer[] { 1, null }) + for (Item v : new Item[] { one, null }) { final int n = expensiveTests ? 100_000 : 10; - CompletableFuture[] fs - = (CompletableFuture[]) new CompletableFuture[100]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs = + (CompletableFuture[])new CompletableFuture[100]; for (int i = 0; i < fs.length; i++) fs[i] = new CompletableFuture<>(); fs[fs.length - 1].complete(v); @@ -4637,8 +4637,9 @@ public void testAnyOfGarbageRetention() throws Throwable { */ public void testCancelledAllOfGarbageRetention() throws Throwable { final int n = expensiveTests ? 100_000 : 10; - CompletableFuture[] fs - = (CompletableFuture[]) new CompletableFuture[100]; + @SuppressWarnings("unchecked") + CompletableFuture[] fs + = (CompletableFuture[]) new CompletableFuture[100]; for (int i = 0; i < fs.length; i++) fs[i] = new CompletableFuture<>(); for (int i = 0; i < n; i++) @@ -4655,7 +4656,7 @@ public void testCancelledAllOfGarbageRetention() throws Throwable { */ public void testCancelledGarbageRetention() throws Throwable { final int n = expensiveTests ? 100_000 : 10; - CompletableFuture neverCompleted = new CompletableFuture<>(); + CompletableFuture neverCompleted = new CompletableFuture<>(); for (int i = 0; i < n; i++) assertTrue(neverCompleted.thenRun(() -> {}).cancel(true)); } @@ -4670,8 +4671,8 @@ public void testCancelledGarbageRetention() throws Throwable { */ public void testToCompletableFutureGarbageRetention() throws Throwable { final int n = expensiveTests ? 900_000 : 10; - CompletableFuture neverCompleted = new CompletableFuture<>(); - CompletionStage minimal = neverCompleted.minimalCompletionStage(); + CompletableFuture neverCompleted = new CompletableFuture<>(); + CompletionStage minimal = neverCompleted.minimalCompletionStage(); for (int i = 0; i < n; i++) assertTrue(minimal.toCompletableFuture().cancel(true)); } @@ -4856,14 +4857,14 @@ public CompletableFuture toCompletableFuture() { */ public void testDefaultExceptionallyAsync_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletionStage g = d.exceptionallyAsync + final CompletionStage g = d.exceptionallyAsync ((Throwable t) -> { ran.getAndIncrement(); throw new AssertionError("should not be called"); @@ -4872,7 +4873,7 @@ public void testDefaultExceptionallyAsync_normalCompletion() { checkCompletedNormally(g.toCompletableFuture(), v1); checkCompletedNormally(f, v1); - assertEquals(0, ran.get()); + mustEqual(0, ran.get()); }} /** @@ -4881,15 +4882,15 @@ public void testDefaultExceptionallyAsync_normalCompletion() { */ public void testDefaultExceptionallyAsync_exceptionalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { final AtomicInteger ran = new AtomicInteger(0); final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyAsync + final CompletionStage g = d.exceptionallyAsync ((Throwable t) -> { assertSame(t, ex); ran.getAndIncrement(); @@ -4899,7 +4900,7 @@ public void testDefaultExceptionallyAsync_exceptionalCompletion() { checkCompletedNormally(g.toCompletableFuture(), v1); checkCompletedExceptionally(f, ex); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -4913,11 +4914,11 @@ public void testDefaultExceptionallyAsync_exceptionalCompletionActionFailed() { final AtomicInteger ran = new AtomicInteger(0); final CFException ex1 = new CFException(); final CFException ex2 = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex1); - final CompletionStage g = d.exceptionallyAsync + final CompletionStage g = d.exceptionallyAsync ((Throwable t) -> { assertSame(t, ex1); ran.getAndIncrement(); @@ -4928,7 +4929,7 @@ public void testDefaultExceptionallyAsync_exceptionalCompletionActionFailed() { checkCompletedWithWrappedException(g.toCompletableFuture(), ex2); checkCompletedExceptionally(f, ex1); checkCompletedExceptionally(d.toCompletableFuture(), ex1); - assertEquals(1, ran.get()); + mustEqual(1, ran.get()); }} /** @@ -4937,15 +4938,15 @@ public void testDefaultExceptionallyAsync_exceptionalCompletionActionFailed() { */ public void testDefaultExceptionallyCompose_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.SYNC); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletionStage g = d.exceptionallyCompose(r); + final CompletionStage g = d.exceptionallyCompose(r); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedNormally(f, v1); @@ -4963,11 +4964,11 @@ public void testDefaultExceptionallyCompose_exceptionalCompletion() { final CFException ex = new CFException(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.SYNC); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyCompose(r); + final CompletionStage g = d.exceptionallyCompose(r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -4983,13 +4984,13 @@ public void testDefaultExceptionallyCompose_actionFailed() { for (boolean createIncomplete : new boolean[] { true, false }) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingExceptionalCompletableFutureFunction r = new FailingExceptionalCompletableFutureFunction(ExecutionMode.SYNC); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyCompose(r); + final CompletionStage g = d.exceptionallyCompose(r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -5003,15 +5004,15 @@ public void testDefaultExceptionallyCompose_actionFailed() { */ public void testDefaultExceptionallyComposeAsync_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.ASYNC); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletionStage g = d.exceptionallyComposeAsync(r); + final CompletionStage g = d.exceptionallyComposeAsync(r); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedNormally(f, v1); @@ -5029,11 +5030,11 @@ public void testDefaultExceptionallyComposeAsync_exceptionalCompletion() { final CFException ex = new CFException(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.ASYNC); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyComposeAsync(r); + final CompletionStage g = d.exceptionallyComposeAsync(r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -5049,13 +5050,13 @@ public void testDefaultExceptionallyComposeAsync_actionFailed() { for (boolean createIncomplete : new boolean[] { true, false }) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingExceptionalCompletableFutureFunction r = new FailingExceptionalCompletableFutureFunction(ExecutionMode.ASYNC); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyComposeAsync(r); + final CompletionStage g = d.exceptionallyComposeAsync(r); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -5069,15 +5070,15 @@ public void testDefaultExceptionallyComposeAsync_actionFailed() { */ public void testDefaultExceptionallyComposeAsyncExecutor_normalCompletion() { for (boolean createIncomplete : new boolean[] { true, false }) - for (Integer v1 : new Integer[] { 1, null }) + for (Item v1 : new Item[] { one, null }) { - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.EXECUTOR); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) assertTrue(f.complete(v1)); - final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); + final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); if (createIncomplete) assertTrue(f.complete(v1)); checkCompletedNormally(f, v1); @@ -5095,11 +5096,11 @@ public void testDefaultExceptionallyComposeAsyncExecutor_exceptionalCompletion() final CFException ex = new CFException(); final ExceptionalCompletableFutureFunction r = new ExceptionalCompletableFutureFunction(ExecutionMode.EXECUTOR); - final CompletableFuture f = new CompletableFuture<>(); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final CompletableFuture f = new CompletableFuture<>(); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); + final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); @@ -5115,13 +5116,13 @@ public void testDefaultExceptionallyComposeAsyncExecutor_actionFailed() { for (boolean createIncomplete : new boolean[] { true, false }) { final CFException ex = new CFException(); - final CompletableFuture f = new CompletableFuture<>(); + final CompletableFuture f = new CompletableFuture<>(); final FailingExceptionalCompletableFutureFunction r = new FailingExceptionalCompletableFutureFunction(ExecutionMode.EXECUTOR); - final DelegatedCompletionStage d = - new DelegatedCompletionStage(f); + final DelegatedCompletionStage d = + new DelegatedCompletionStage<>(f); if (!createIncomplete) f.completeExceptionally(ex); - final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); + final CompletionStage g = d.exceptionallyComposeAsync(r, new ThreadExecutor()); if (createIncomplete) f.completeExceptionally(ex); checkCompletedExceptionally(f, ex); diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java index 4088978c07a..54eb1fb8d4a 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java @@ -61,10 +61,10 @@ public static Test suite() { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static ConcurrentHashMap map5() { - ConcurrentHashMap map = new ConcurrentHashMap(5); + private static ConcurrentHashMap map5() { + ConcurrentHashMap map = new ConcurrentHashMap<>(5); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(two, "B"); @@ -72,7 +72,7 @@ private static ConcurrentHashMap map5() { map.put(four, "D"); map.put(five, "E"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map; } @@ -80,16 +80,16 @@ private static ConcurrentHashMap map5() { * getOrDefault returns value if present, else default */ public void testGetOrDefault() { - ConcurrentHashMap map = map5(); - assertEquals(map.getOrDefault(one, "Z"), "A"); - assertEquals(map.getOrDefault(six, "Z"), "Z"); + ConcurrentHashMap map = map5(); + mustEqual(map.getOrDefault(one, "Z"), "A"); + mustEqual(map.getOrDefault(six, "Z"), "Z"); } /** * computeIfAbsent adds when the given key is not present */ public void testComputeIfAbsent() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.computeIfAbsent(six, x -> "Z"); assertTrue(map.containsKey(six)); } @@ -98,15 +98,15 @@ public void testComputeIfAbsent() { * computeIfAbsent does not replace if the key is already present */ public void testComputeIfAbsent2() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.computeIfAbsent(one, x -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("A", map.computeIfAbsent(one, x -> "Z")); } /** * computeIfAbsent does not add if function returns null */ public void testComputeIfAbsent3() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.computeIfAbsent(six, x -> null); assertFalse(map.containsKey(six)); } @@ -115,7 +115,7 @@ public void testComputeIfAbsent3() { * computeIfPresent does not replace if the key is already present */ public void testComputeIfPresent() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.computeIfPresent(six, (x, y) -> "Z"); assertFalse(map.containsKey(six)); } @@ -124,15 +124,15 @@ public void testComputeIfPresent() { * computeIfPresent adds when the given key is not present */ public void testComputeIfPresent2() { - ConcurrentHashMap map = map5(); - assertEquals("Z", map.computeIfPresent(one, (x, y) -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("Z", map.computeIfPresent(one, (x, y) -> "Z")); } /** * compute does not replace if the function returns null */ public void testCompute() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.compute(six, (x, y) -> null); assertFalse(map.containsKey(six)); } @@ -141,23 +141,23 @@ public void testCompute() { * compute adds when the given key is not present */ public void testCompute2() { - ConcurrentHashMap map = map5(); - assertEquals("Z", map.compute(six, (x, y) -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("Z", map.compute(six, (x, y) -> "Z")); } /** * compute replaces when the given key is present */ public void testCompute3() { - ConcurrentHashMap map = map5(); - assertEquals("Z", map.compute(one, (x, y) -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("Z", map.compute(one, (x, y) -> "Z")); } /** * compute removes when the given key is present and function returns null */ public void testCompute4() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.compute(one, (x, y) -> null); assertFalse(map.containsKey(one)); } @@ -166,44 +166,44 @@ public void testCompute4() { * merge adds when the given key is not present */ public void testMerge1() { - ConcurrentHashMap map = map5(); - assertEquals("Y", map.merge(six, "Y", (x, y) -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("Y", map.merge(six, "Y", (x, y) -> "Z")); } /** * merge replaces when the given key is present */ public void testMerge2() { - ConcurrentHashMap map = map5(); - assertEquals("Z", map.merge(one, "Y", (x, y) -> "Z")); + ConcurrentHashMap map = map5(); + mustEqual("Z", map.merge(one, "Y", (x, y) -> "Z")); } /** * merge removes when the given key is present and function returns null */ public void testMerge3() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.merge(one, "Y", (x, y) -> null); assertFalse(map.containsKey(one)); } - static Set populatedSet(int n) { - Set a = ConcurrentHashMap.newKeySet(); + static Set populatedSet(int n) { + Set a = ConcurrentHashMap.newKeySet(); assertTrue(a.isEmpty()); for (int i = 0; i < n; i++) - assertTrue(a.add(i)); - assertEquals(n == 0, a.isEmpty()); - assertEquals(n, a.size()); + mustAdd(a, i); + mustEqual(n == 0, a.isEmpty()); + mustEqual(n, a.size()); return a; } - static Set populatedSet(Integer[] elements) { - Set a = ConcurrentHashMap.newKeySet(); + static Set populatedSet(Item[] elements) { + Set a = ConcurrentHashMap.newKeySet(); assertTrue(a.isEmpty()); - for (Integer element : elements) + for (Item element : elements) assertTrue(a.add(element)); assertFalse(a.isEmpty()); - assertEquals(elements.length, a.size()); + mustEqual(elements.length, a.size()); return a; } @@ -211,20 +211,20 @@ static Set populatedSet(Integer[] elements) { * replaceAll replaces all matching values. */ public void testReplaceAll() { - ConcurrentHashMap map = map5(); - map.replaceAll((x, y) -> (x > 3) ? "Z" : y); - assertEquals("A", map.get(one)); - assertEquals("B", map.get(two)); - assertEquals("C", map.get(three)); - assertEquals("Z", map.get(four)); - assertEquals("Z", map.get(five)); + ConcurrentHashMap map = map5(); + map.replaceAll((x, y) -> (x.value > 3) ? "Z" : y); + mustEqual("A", map.get(one)); + mustEqual("B", map.get(two)); + mustEqual("C", map.get(three)); + mustEqual("Z", map.get(four)); + mustEqual("Z", map.get(five)); } /** * Default-constructed set is empty */ public void testNewKeySet() { - Set a = ConcurrentHashMap.newKeySet(); + Set a = ConcurrentHashMap.newKeySet(); assertTrue(a.isEmpty()); } @@ -233,32 +233,32 @@ public void testNewKeySet() { * remove removes it. */ public void testKeySetAddRemove() { - ConcurrentHashMap map = map5(); - Set set1 = map.keySet(); - Set set2 = map.keySet(true); + ConcurrentHashMap map = map5(); + Set set1 = map.keySet(); + Set set2 = map.keySet("added"); set2.add(six); assertSame(map, ((ConcurrentHashMap.KeySetView)set2).getMap()); assertSame(map, ((ConcurrentHashMap.KeySetView)set1).getMap()); - assertEquals(set2.size(), map.size()); - assertEquals(set1.size(), map.size()); - assertTrue((Boolean)map.get(six)); - assertTrue(set1.contains(six)); - assertTrue(set2.contains(six)); - set2.remove(six); + mustEqual(set2.size(), map.size()); + mustEqual(set1.size(), map.size()); + assertEquals(map.get(six), "added"); + mustContain(set1, six); + mustContain(set2, six); + mustRemove(set2, six); assertNull(map.get(six)); - assertFalse(set1.contains(six)); - assertFalse(set2.contains(six)); + mustNotContain(set1, six); + mustNotContain(set2, six); } /** * keySet.addAll adds each element from the given collection */ public void testAddAll() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertTrue(full.addAll(Arrays.asList(three, four, five))); - assertEquals(6, full.size()); + mustEqual(6, full.size()); assertFalse(full.addAll(Arrays.asList(three, four, five))); - assertEquals(6, full.size()); + mustEqual(6, full.size()); } /** @@ -266,32 +266,32 @@ public void testAddAll() { * already exist in the set */ public void testAddAll2() { - Set full = populatedSet(3); + Set full = populatedSet(3); // "one" is duplicate and will not be added assertTrue(full.addAll(Arrays.asList(three, four, one))); - assertEquals(5, full.size()); + mustEqual(5, full.size()); assertFalse(full.addAll(Arrays.asList(three, four, one))); - assertEquals(5, full.size()); + mustEqual(5, full.size()); } /** * keySet.add will not add the element if it already exists in the set */ public void testAdd2() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertFalse(full.add(one)); - assertEquals(3, full.size()); + mustEqual(3, full.size()); } /** * keySet.add adds the element when it does not exist in the set */ public void testAdd3() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertTrue(full.add(three)); - assertTrue(full.contains(three)); + mustContain(full, three); assertFalse(full.add(three)); - assertTrue(full.contains(three)); + mustContain(full, three); } /** @@ -299,7 +299,7 @@ public void testAdd3() { * mapped value */ public void testAdd4() { - Set full = map5().keySet(); + Set full = map5().keySet(); try { full.add(three); shouldThrow(); @@ -311,7 +311,7 @@ public void testAdd4() { * null */ public void testAdd5() { - Set full = populatedSet(3); + Set full = populatedSet(3); try { full.add(null); shouldThrow(); @@ -322,25 +322,26 @@ public void testAdd5() { * KeySetView.getMappedValue returns the map's mapped value */ public void testGetMappedValue() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertNull(map.keySet().getMappedValue()); + String added = "added"; try { map.keySet(null); shouldThrow(); } catch (NullPointerException success) {} - ConcurrentHashMap.KeySetView set = map.keySet(one); + ConcurrentHashMap.KeySetView set = map.keySet(added); assertFalse(set.add(one)); assertTrue(set.add(six)); assertTrue(set.add(seven)); - assertSame(one, set.getMappedValue()); - assertNotSame(one, map.get(one)); - assertSame(one, map.get(six)); - assertSame(one, map.get(seven)); + assertSame(added, set.getMappedValue()); + assertNotSame(added, map.get(one)); + assertSame(added, map.get(six)); + assertSame(added, map.get(seven)); } void checkSpliteratorCharacteristics(Spliterator sp, int requiredCharacteristics) { - assertEquals(requiredCharacteristics, + mustEqual(requiredCharacteristics, requiredCharacteristics & sp.characteristics()); } @@ -349,60 +350,60 @@ void checkSpliteratorCharacteristics(Spliterator sp, */ public void testKeySetSpliterator() { LongAdder adder = new LongAdder(); - ConcurrentHashMap map = map5(); - Set set = map.keySet(); - Spliterator sp = set.spliterator(); + ConcurrentHashMap map = map5(); + Set set = map.keySet(); + Spliterator sp = set.spliterator(); checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL); - assertEquals(sp.estimateSize(), map.size()); - Spliterator sp2 = sp.trySplit(); - sp.forEachRemaining((Integer x) -> adder.add(x.longValue())); + mustEqual(sp.estimateSize(), map.size()); + Spliterator sp2 = sp.trySplit(); + sp.forEachRemaining((Item x) -> adder.add(x.longValue())); long v = adder.sumThenReset(); - sp2.forEachRemaining((Integer x) -> adder.add(x.longValue())); + sp2.forEachRemaining((Item x) -> adder.add(x.longValue())); long v2 = adder.sum(); - assertEquals(v + v2, 15); + mustEqual(v + v2, 15); } /** * keyset.clear removes all elements from the set */ public void testClear() { - Set full = populatedSet(3); + Set full = populatedSet(3); full.clear(); - assertEquals(0, full.size()); + mustEqual(0, full.size()); } /** * keyset.contains returns true for added elements */ public void testContains() { - Set full = populatedSet(3); - assertTrue(full.contains(one)); - assertFalse(full.contains(five)); + Set full = populatedSet(3); + mustContain(full, one); + mustNotContain(full, five); } /** * KeySets with equal elements are equal */ public void testEquals() { - Set a = populatedSet(3); - Set b = populatedSet(3); + Set a = populatedSet(3); + Set b = populatedSet(3); assertTrue(a.equals(b)); assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); - a.add(m1); + mustEqual(a.hashCode(), b.hashCode()); + a.add(minusOne); assertFalse(a.equals(b)); assertFalse(b.equals(a)); - b.add(m1); + b.add(minusOne); assertTrue(a.equals(b)); assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); + mustEqual(a.hashCode(), b.hashCode()); } /** * KeySet.containsAll returns true for collections with subset of elements */ public void testContainsAll() { - Collection full = populatedSet(3); + Collection full = populatedSet(3); assertTrue(full.containsAll(Arrays.asList())); assertTrue(full.containsAll(Arrays.asList(one))); assertTrue(full.containsAll(Arrays.asList(one, two))); @@ -423,7 +424,7 @@ public void testIsEmpty() { * set */ public void testIterator() { - Collection empty = ConcurrentHashMap.newKeySet(); + Collection empty = ConcurrentHashMap.newKeySet(); int size = 20; assertFalse(empty.iterator().hasNext()); try { @@ -431,13 +432,11 @@ public void testIterator() { shouldThrow(); } catch (NoSuchElementException success) {} - Integer[] elements = new Integer[size]; - for (int i = 0; i < size; i++) - elements[i] = i; + Item[] elements = seqItems(size); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); - Iterator it = full.iterator(); + Iterator it = full.iterator(); for (int j = 0; j < size; j++) { assertTrue(it.hasNext()); it.next(); @@ -450,17 +449,17 @@ public void testIterator() { */ public void testEmptyIterator() { assertIteratorExhausted(ConcurrentHashMap.newKeySet().iterator()); - assertIteratorExhausted(new ConcurrentHashMap().entrySet().iterator()); - assertIteratorExhausted(new ConcurrentHashMap().values().iterator()); - assertIteratorExhausted(new ConcurrentHashMap().keySet().iterator()); + assertIteratorExhausted(new ConcurrentHashMap().entrySet().iterator()); + assertIteratorExhausted(new ConcurrentHashMap().values().iterator()); + assertIteratorExhausted(new ConcurrentHashMap().keySet().iterator()); } /** * KeySet.iterator.remove removes current element */ public void testIteratorRemove() { - Set q = populatedSet(3); - Iterator it = q.iterator(); + Set q = populatedSet(3); + Iterator it = q.iterator(); Object removed = it.next(); it.remove(); @@ -474,8 +473,8 @@ public void testIteratorRemove() { * KeySet.toString holds toString of elements */ public void testToString() { - assertEquals("[]", ConcurrentHashMap.newKeySet().toString()); - Set full = populatedSet(3); + mustEqual("[]", ConcurrentHashMap.newKeySet().toString()); + Set full = populatedSet(3); String s = full.toString(); for (int i = 0; i < 3; ++i) assertTrue(s.contains(String.valueOf(i))); @@ -485,31 +484,31 @@ public void testToString() { * KeySet.removeAll removes all elements from the given collection */ public void testRemoveAll() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertTrue(full.removeAll(Arrays.asList(one, two))); - assertEquals(1, full.size()); + mustEqual(1, full.size()); assertFalse(full.removeAll(Arrays.asList(one, two))); - assertEquals(1, full.size()); + mustEqual(1, full.size()); } /** * KeySet.remove removes an element */ public void testRemove() { - Set full = populatedSet(3); + Set full = populatedSet(3); full.remove(one); - assertFalse(full.contains(one)); - assertEquals(2, full.size()); + mustNotContain(full, one); + mustEqual(2, full.size()); } /** * keySet.size returns the number of elements */ public void testSize() { - Set empty = ConcurrentHashMap.newKeySet(); - Set full = populatedSet(3); - assertEquals(3, full.size()); - assertEquals(0, empty.size()); + Set empty = ConcurrentHashMap.newKeySet(); + Set full = populatedSet(3); + mustEqual(3, full.size()); + mustEqual(0, empty.size()); } /** @@ -521,11 +520,9 @@ public void testToArray() { assertTrue(Arrays.equals(new Object[0], a)); assertSame(Object[].class, a.getClass()); int size = 20; - Integer[] elements = new Integer[size]; - for (int i = 0; i < size; i++) - elements[i] = i; + Item[] elements = seqItems(size); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray()))); assertTrue(full.containsAll(Arrays.asList(full.toArray()))); @@ -533,38 +530,36 @@ public void testToArray() { } /** - * toArray(Integer array) returns an Integer array containing all + * toArray(Item array) returns an Item array containing all * elements from the set */ public void testToArray2() { - Collection empty = ConcurrentHashMap.newKeySet(); - Integer[] a; + Collection empty = ConcurrentHashMap.newKeySet(); + Item[] a; int size = 20; - a = new Integer[0]; + a = new Item[0]; assertSame(a, empty.toArray(a)); - a = new Integer[size / 2]; - Arrays.fill(a, 42); + a = new Item[size / 2]; + Arrays.fill(a, fortytwo); assertSame(a, empty.toArray(a)); assertNull(a[0]); for (int i = 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); - Integer[] elements = new Integer[size]; - for (int i = 0; i < size; i++) - elements[i] = i; + Item[] elements = seqItems(size); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); - Arrays.fill(a, 42); + Arrays.fill(a, fortytwo); assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray(a)))); for (int i = 0; i < a.length; i++) - assertEquals(42, (int) a[i]); - assertSame(Integer[].class, full.toArray(a).getClass()); + mustEqual(42, a[i]); + assertSame(Item[].class, full.toArray(a).getClass()); - a = new Integer[size]; - Arrays.fill(a, 42); + a = new Item[size]; + Arrays.fill(a, fortytwo); assertSame(a, full.toArray(a)); assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray(a)))); } @@ -574,13 +569,13 @@ public void testToArray2() { */ public void testSerialization() throws Exception { int size = 20; - Set x = populatedSet(size); - Set y = serialClone(x); + Set x = populatedSet(size); + Set y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); } static final int SIZE = 10000; @@ -588,7 +583,7 @@ public void testSerialization() throws Exception { static ConcurrentHashMap longMap() { if (longMap == null) { - longMap = new ConcurrentHashMap(SIZE); + longMap = new ConcurrentHashMap<>(SIZE); for (int i = 0; i < SIZE; ++i) longMap.put(Long.valueOf(i), Long.valueOf(2 *i)); } @@ -611,7 +606,7 @@ public void testForEachKeySequentially() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachKey(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), SIZE * (SIZE - 1) / 2); } /** @@ -621,7 +616,7 @@ public void testForEachValueSequentially() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), SIZE * (SIZE - 1)); + mustEqual(adder.sum(), SIZE * (SIZE - 1)); } /** @@ -631,7 +626,7 @@ public void testForEachSequentially() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEach(Long.MAX_VALUE, (Long x, Long y) -> adder.add(x.longValue() + y.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -641,7 +636,7 @@ public void testForEachEntrySequentially() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachEntry(Long.MAX_VALUE, (Map.Entry e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -651,7 +646,7 @@ public void testForEachKeyInParallel() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachKey(1L, (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), SIZE * (SIZE - 1) / 2); } /** @@ -661,7 +656,7 @@ public void testForEachValueInParallel() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachValue(1L, (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), SIZE * (SIZE - 1)); + mustEqual(adder.sum(), SIZE * (SIZE - 1)); } /** @@ -671,7 +666,7 @@ public void testForEachInParallel() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -681,7 +676,7 @@ public void testForEachEntryInParallel() { LongAdder adder = new LongAdder(); ConcurrentHashMap m = longMap(); m.forEachEntry(1L, (Map.Entry e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -693,7 +688,7 @@ public void testMappedForEachKeySequentially() { ConcurrentHashMap m = longMap(); m.forEachKey(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); } /** @@ -705,7 +700,7 @@ public void testMappedForEachValueSequentially() { ConcurrentHashMap m = longMap(); m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1)); + mustEqual(adder.sum(), 4 * SIZE * (SIZE - 1)); } /** @@ -717,7 +712,7 @@ public void testMappedForEachSequentially() { ConcurrentHashMap m = longMap(); m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -729,7 +724,7 @@ public void testMappedForEachEntrySequentially() { ConcurrentHashMap m = longMap(); m.forEachEntry(Long.MAX_VALUE, (Map.Entry e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -741,7 +736,7 @@ public void testMappedForEachKeyInParallel() { ConcurrentHashMap m = longMap(); m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); } /** @@ -753,7 +748,7 @@ public void testMappedForEachValueInParallel() { ConcurrentHashMap m = longMap(); m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1)); + mustEqual(adder.sum(), 4 * SIZE * (SIZE - 1)); } /** @@ -765,7 +760,7 @@ public void testMappedForEachInParallel() { ConcurrentHashMap m = longMap(); m.forEach(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -777,7 +772,7 @@ public void testMappedForEachEntryInParallel() { ConcurrentHashMap m = longMap(); m.forEachEntry(1L, (Map.Entry e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue())); - assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); + mustEqual(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); } /** @@ -787,7 +782,7 @@ public void testReduceKeysSequentially() { ConcurrentHashMap m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)SIZE * (SIZE - 1) / 2); } /** @@ -797,7 +792,7 @@ public void testReduceValuesSequentially() { ConcurrentHashMap m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)SIZE * (SIZE - 1) / 2); } /** @@ -807,7 +802,7 @@ public void testReduceEntriesSequentially() { ConcurrentHashMap m = longMap(); Map.Entry r; r = m.reduceEntries(Long.MAX_VALUE, new AddKeys()); - assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); + mustEqual(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); } /** @@ -817,7 +812,7 @@ public void testReduceKeysInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)SIZE * (SIZE - 1) / 2); } /** @@ -827,7 +822,7 @@ public void testReduceValuesInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.reduceValues(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)SIZE * (SIZE - 1)); + mustEqual((long)r, (long)SIZE * (SIZE - 1)); } /** @@ -837,7 +832,7 @@ public void testReduceEntriesInParallel() { ConcurrentHashMap m = longMap(); Map.Entry r; r = m.reduceEntries(1L, new AddKeys()); - assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); + mustEqual(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); } /** @@ -847,7 +842,7 @@ public void testMapReduceKeysSequentially() { ConcurrentHashMap m = longMap(); Long r = m.reduceKeys(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)4 * SIZE * (SIZE - 1) / 2); } /** @@ -857,7 +852,7 @@ public void testMapReduceValuesSequentially() { ConcurrentHashMap m = longMap(); Long r = m.reduceValues(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)4 * SIZE * (SIZE - 1)); + mustEqual((long)r, (long)4 * SIZE * (SIZE - 1)); } /** @@ -868,7 +863,7 @@ public void testMappedReduceSequentially() { Long r = m.reduce(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)3 * SIZE * (SIZE - 1) / 2); } /** @@ -878,7 +873,7 @@ public void testMapReduceKeysInParallel() { ConcurrentHashMap m = longMap(); Long r = m.reduceKeys(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)4 * SIZE * (SIZE - 1) / 2); } /** @@ -888,7 +883,7 @@ public void testMapReduceValuesInParallel() { ConcurrentHashMap m = longMap(); Long r = m.reduceValues(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)4 * SIZE * (SIZE - 1)); + mustEqual((long)r, (long)4 * SIZE * (SIZE - 1)); } /** @@ -899,7 +894,7 @@ public void testMappedReduceInParallel() { Long r; r = m.reduce(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); - assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2); + mustEqual((long)r, (long)3 * SIZE * (SIZE - 1) / 2); } /** @@ -908,7 +903,7 @@ public void testMappedReduceInParallel() { public void testReduceKeysToLongSequentially() { ConcurrentHashMap m = longMap(); long lr = m.reduceKeysToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum); - assertEquals(lr, (long)SIZE * (SIZE - 1) / 2); + mustEqual(lr, (long)SIZE * (SIZE - 1) / 2); } /** @@ -917,7 +912,7 @@ public void testReduceKeysToLongSequentially() { public void testReduceKeysToIntSequentially() { ConcurrentHashMap m = longMap(); int ir = m.reduceKeysToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum); - assertEquals(ir, SIZE * (SIZE - 1) / 2); + mustEqual(ir, SIZE * (SIZE - 1) / 2); } /** @@ -926,7 +921,7 @@ public void testReduceKeysToIntSequentially() { public void testReduceKeysToDoubleSequentially() { ConcurrentHashMap m = longMap(); double dr = m.reduceKeysToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum); - assertEquals(dr, (double)SIZE * (SIZE - 1) / 2); + mustEqual(dr, (double)SIZE * (SIZE - 1) / 2); } /** @@ -935,7 +930,7 @@ public void testReduceKeysToDoubleSequentially() { public void testReduceValuesToLongSequentially() { ConcurrentHashMap m = longMap(); long lr = m.reduceValuesToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum); - assertEquals(lr, (long)SIZE * (SIZE - 1)); + mustEqual(lr, (long)SIZE * (SIZE - 1)); } /** @@ -944,7 +939,7 @@ public void testReduceValuesToLongSequentially() { public void testReduceValuesToIntSequentially() { ConcurrentHashMap m = longMap(); int ir = m.reduceValuesToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum); - assertEquals(ir, SIZE * (SIZE - 1)); + mustEqual(ir, SIZE * (SIZE - 1)); } /** @@ -953,7 +948,7 @@ public void testReduceValuesToIntSequentially() { public void testReduceValuesToDoubleSequentially() { ConcurrentHashMap m = longMap(); double dr = m.reduceValuesToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum); - assertEquals(dr, (double)SIZE * (SIZE - 1)); + mustEqual(dr, (double)SIZE * (SIZE - 1)); } /** @@ -962,7 +957,7 @@ public void testReduceValuesToDoubleSequentially() { public void testReduceKeysToLongInParallel() { ConcurrentHashMap m = longMap(); long lr = m.reduceKeysToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum); - assertEquals(lr, (long)SIZE * (SIZE - 1) / 2); + mustEqual(lr, (long)SIZE * (SIZE - 1) / 2); } /** @@ -971,7 +966,7 @@ public void testReduceKeysToLongInParallel() { public void testReduceKeysToIntInParallel() { ConcurrentHashMap m = longMap(); int ir = m.reduceKeysToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum); - assertEquals(ir, SIZE * (SIZE - 1) / 2); + mustEqual(ir, SIZE * (SIZE - 1) / 2); } /** @@ -980,7 +975,7 @@ public void testReduceKeysToIntInParallel() { public void testReduceKeysToDoubleInParallel() { ConcurrentHashMap m = longMap(); double dr = m.reduceKeysToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum); - assertEquals(dr, (double)SIZE * (SIZE - 1) / 2); + mustEqual(dr, (double)SIZE * (SIZE - 1) / 2); } /** @@ -989,7 +984,7 @@ public void testReduceKeysToDoubleInParallel() { public void testReduceValuesToLongInParallel() { ConcurrentHashMap m = longMap(); long lr = m.reduceValuesToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum); - assertEquals(lr, (long)SIZE * (SIZE - 1)); + mustEqual(lr, (long)SIZE * (SIZE - 1)); } /** @@ -998,7 +993,7 @@ public void testReduceValuesToLongInParallel() { public void testReduceValuesToIntInParallel() { ConcurrentHashMap m = longMap(); int ir = m.reduceValuesToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum); - assertEquals(ir, SIZE * (SIZE - 1)); + mustEqual(ir, SIZE * (SIZE - 1)); } /** @@ -1007,7 +1002,7 @@ public void testReduceValuesToIntInParallel() { public void testReduceValuesToDoubleInParallel() { ConcurrentHashMap m = longMap(); double dr = m.reduceValuesToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum); - assertEquals(dr, (double)SIZE * (SIZE - 1)); + mustEqual(dr, (double)SIZE * (SIZE - 1)); } /** @@ -1018,7 +1013,7 @@ public void testSearchKeysSequentially() { ConcurrentHashMap m = longMap(); Long r; r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null); assertNull(r); } @@ -1032,7 +1027,7 @@ public void testSearchValuesSequentially() { Long r; r = m.searchValues(Long.MAX_VALUE, (Long x) -> (x.longValue() == (long)(SIZE/2)) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchValues(Long.MAX_VALUE, (Long x) -> (x.longValue() < 0L) ? x : null); assertNull(r); @@ -1046,7 +1041,7 @@ public void testSearchSequentially() { ConcurrentHashMap m = longMap(); Long r; r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() < 0L ? x : null); assertNull(r); } @@ -1059,7 +1054,7 @@ public void testSearchEntriesSequentially() { ConcurrentHashMap m = longMap(); Long r; r = m.searchEntries(Long.MAX_VALUE, (Map.Entry e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchEntries(Long.MAX_VALUE, (Map.Entry e) -> e.getKey().longValue() < 0L ? e.getKey() : null); assertNull(r); } @@ -1072,7 +1067,7 @@ public void testSearchKeysInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.searchKeys(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchKeys(1L, (Long x) -> x.longValue() < 0L ? x : null); assertNull(r); } @@ -1085,7 +1080,7 @@ public void testSearchValuesInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.searchValues(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchValues(1L, (Long x) -> x.longValue() < 0L ? x : null); assertNull(r); } @@ -1098,7 +1093,7 @@ public void testSearchInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.search(1L, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.search(1L, (Long x, Long y) -> x.longValue() < 0L ? x : null); assertNull(r); } @@ -1111,7 +1106,7 @@ public void testSearchEntriesInParallel() { ConcurrentHashMap m = longMap(); Long r; r = m.searchEntries(1L, (Map.Entry e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); - assertEquals((long)r, (long)(SIZE/2)); + mustEqual((long)r, (long)(SIZE/2)); r = m.searchEntries(1L, (Map.Entry e) -> e.getKey().longValue() < 0L ? e.getKey() : null); assertNull(r); } @@ -1125,16 +1120,18 @@ public void testcomputeIfAbsent_performance() { final int mapSize = 20; final int iterations = expensiveTests ? (1 << 23) : mapSize * 2; final int threads = expensiveTests ? 10 : 2; - final ConcurrentHashMap map = new ConcurrentHashMap<>(); - for (int i = 0; i < mapSize; i++) - map.put(i, i); + final ConcurrentHashMap map = new ConcurrentHashMap<>(); + for (int i = 0; i < mapSize; i++) { + Item I = itemFor(i); + map.put(I, I); + } final ExecutorService pool = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(pool)) { Runnable r = new CheckedRunnable() { public void realRun() { int result = 0; for (int i = 0; i < iterations; i++) - result += map.computeIfAbsent(i % mapSize, k -> k + k); + result += map.computeIfAbsent(itemFor(i % mapSize), k -> itemFor(k.value * 2)).value; if (result == -42) throw new Error(); }}; for (int i = 0; i < threads; i++) diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java index 8cd55c9b746..c87571b01f7 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java @@ -66,10 +66,10 @@ class Implementation implements MapImplementation { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static ConcurrentHashMap map5() { - ConcurrentHashMap map = new ConcurrentHashMap<>(5); + private static ConcurrentHashMap map5() { + ConcurrentHashMap map = new ConcurrentHashMap<>(5); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(two, "B"); @@ -77,7 +77,7 @@ private static ConcurrentHashMap map5() { map.put(four, "D"); map.put(five, "E"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map; } @@ -223,13 +223,13 @@ public void testMixedComparable() { } int count = 0; for (Object k : map.keySet()) { - assertEquals(map.get(k), k); + mustEqual(map.get(k), k); ++count; } - assertEquals(count, size); - assertEquals(map.size(), size); + mustEqual(count, size); + mustEqual(map.size(), size); for (Object k : map.keySet()) { - assertEquals(map.put(k, k), k); + mustEqual(map.put(k, k), k); } } @@ -237,19 +237,19 @@ public void testMixedComparable() { * clear removes all pairs */ public void testClear() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * Maps with same contents are equal */ public void testEquals() { - ConcurrentHashMap map1 = map5(); - ConcurrentHashMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + ConcurrentHashMap map1 = map5(); + ConcurrentHashMap map2 = map5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -259,18 +259,18 @@ public void testEquals() { * hashCode() equals sum of each key.hashCode ^ value.hashCode */ public void testHashCode() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); int sum = 0; - for (Map.Entry e : map.entrySet()) + for (Map.Entry e : map.entrySet()) sum += e.getKey().hashCode() ^ e.getValue().hashCode(); - assertEquals(sum, map.hashCode()); + mustEqual(sum, map.hashCode()); } /** * contains returns true for contained value */ public void testContains() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertTrue(map.contains("A")); assertFalse(map.contains("Z")); } @@ -279,7 +279,7 @@ public void testContains() { * containsKey returns true for contained key */ public void testContainsKey() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); } @@ -288,7 +288,7 @@ public void testContainsKey() { * containsValue returns true for held values */ public void testContainsValue() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -298,24 +298,25 @@ public void testContainsValue() { * elements */ public void testEnumeration() { - ConcurrentHashMap map = map5(); - Enumeration e = map.elements(); + ConcurrentHashMap map = map5(); + Enumeration e = map.elements(); int count = 0; while (e.hasMoreElements()) { count++; e.nextElement(); } - assertEquals(5, count); + mustEqual(5, count); } /** * get returns the correct element at the given key, * or null if not present */ + @SuppressWarnings("CollectionIncompatibleType") public void testGet() { - ConcurrentHashMap map = map5(); - assertEquals("A", (String)map.get(one)); - ConcurrentHashMap empty = new ConcurrentHashMap(); + ConcurrentHashMap map = map5(); + mustEqual("A", map.get(one)); + ConcurrentHashMap empty = new ConcurrentHashMap<>(); assertNull(map.get("anything")); assertNull(empty.get("anything")); } @@ -324,8 +325,8 @@ public void testGet() { * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { - ConcurrentHashMap empty = new ConcurrentHashMap(); - ConcurrentHashMap map = map5(); + ConcurrentHashMap empty = new ConcurrentHashMap<>(); + ConcurrentHashMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -334,36 +335,36 @@ public void testIsEmpty() { * keys returns an enumeration containing all the keys from the map */ public void testKeys() { - ConcurrentHashMap map = map5(); - Enumeration e = map.keys(); + ConcurrentHashMap map = map5(); + Enumeration e = map.keys(); int count = 0; while (e.hasMoreElements()) { count++; e.nextElement(); } - assertEquals(5, count); + mustEqual(5, count); } /** * keySet returns a Set containing all the keys */ public void testKeySet() { - ConcurrentHashMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); + ConcurrentHashMap map = map5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, one); + mustContain(s, two); + mustContain(s, three); + mustContain(s, four); + mustContain(s, five); } /** * Test keySet().removeAll on empty map */ public void testKeySet_empty_removeAll() { - ConcurrentHashMap map = new ConcurrentHashMap<>(); - Set set = map.keySet(); + ConcurrentHashMap map = new ConcurrentHashMap<>(); + Set set = map.keySet(); set.removeAll(Collections.emptyList()); assertTrue(map.isEmpty()); assertTrue(set.isEmpty()); @@ -377,12 +378,12 @@ public void testKeySet_empty_removeAll() { * keySet.toArray returns contains all keys */ public void testKeySetToArray() { - ConcurrentHashMap map = map5(); - Set s = map.keySet(); + ConcurrentHashMap map = map5(); + Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -390,11 +391,11 @@ public void testKeySetToArray() { * Values.toArray contains all values */ public void testValuesToArray() { - ConcurrentHashMap map = map5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); + ConcurrentHashMap map = map5(); + Collection v = map.values(); + String[] ar = v.toArray(new String[0]); + ArrayList s = new ArrayList<>(Arrays.asList(ar)); + mustEqual(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -406,10 +407,10 @@ public void testValuesToArray() { * entrySet.toArray contains all entries */ public void testEntrySetToArray() { - ConcurrentHashMap map = map5(); - Set s = map.entrySet(); + ConcurrentHashMap map = map5(); + Set> s = map.entrySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); @@ -420,9 +421,9 @@ public void testEntrySetToArray() { * values collection contains all values */ public void testValues() { - ConcurrentHashMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); + ConcurrentHashMap map = map5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -434,12 +435,12 @@ public void testValues() { * entrySet contains all pairs */ public void testEntrySet() { - ConcurrentHashMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + ConcurrentHashMap map = map5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -453,22 +454,22 @@ public void testEntrySet() { * putAll adds all key-value pairs from the given map */ public void testPutAll() { - ConcurrentHashMap empty = new ConcurrentHashMap(); - ConcurrentHashMap map = map5(); - empty.putAll(map); - assertEquals(5, empty.size()); - assertTrue(empty.containsKey(one)); - assertTrue(empty.containsKey(two)); - assertTrue(empty.containsKey(three)); - assertTrue(empty.containsKey(four)); - assertTrue(empty.containsKey(five)); + ConcurrentHashMap p = new ConcurrentHashMap<>(); + ConcurrentHashMap map = map5(); + p.putAll(map); + mustEqual(5, p.size()); + assertTrue(p.containsKey(one)); + assertTrue(p.containsKey(two)); + assertTrue(p.containsKey(three)); + assertTrue(p.containsKey(four)); + assertTrue(p.containsKey(five)); } /** * putIfAbsent works when the given key is not present */ public void testPutIfAbsent() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.putIfAbsent(six, "Z"); assertTrue(map.containsKey(six)); } @@ -477,15 +478,15 @@ public void testPutIfAbsent() { * putIfAbsent does not add the pair if the key is already present */ public void testPutIfAbsent2() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.putIfAbsent(one, "Z")); + ConcurrentHashMap map = map5(); + mustEqual("A", map.putIfAbsent(one, "Z")); } /** * replace fails when the given key is not present */ public void testReplace() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertNull(map.replace(six, "Z")); assertFalse(map.containsKey(six)); } @@ -494,38 +495,38 @@ public void testReplace() { * replace succeeds if the key is already present */ public void testReplace2() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); assertNotNull(map.replace(one, "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * replace value fails when the given key not mapped to expected value */ public void testReplaceValue() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentHashMap map = map5(); + mustEqual("A", map.get(one)); assertFalse(map.replace(one, "Z", "Z")); - assertEquals("A", map.get(one)); + mustEqual("A", map.get(one)); } /** * replace value succeeds when the given key mapped to expected value */ public void testReplaceValue2() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentHashMap map = map5(); + mustEqual("A", map.get(one)); assertTrue(map.replace(one, "A", "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * remove removes the correct key-value pair from the map */ public void testRemove() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.remove(five); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); } @@ -533,12 +534,12 @@ public void testRemove() { * remove(key,value) removes only if pair present */ public void testRemove2() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); map.remove(five, "E"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); map.remove(four, "A"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertTrue(map.containsKey(four)); } @@ -546,17 +547,17 @@ public void testRemove2() { * size returns the correct values */ public void testSize() { - ConcurrentHashMap map = map5(); - ConcurrentHashMap empty = new ConcurrentHashMap(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + ConcurrentHashMap map = map5(); + ConcurrentHashMap empty = new ConcurrentHashMap<>(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testToString() { - ConcurrentHashMap map = map5(); + ConcurrentHashMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -570,7 +571,7 @@ public void testToString() { */ public void testConstructor1() { try { - new ConcurrentHashMap(-1); + new ConcurrentHashMap(-1); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -581,12 +582,12 @@ public void testConstructor1() { */ public void testConstructor2() { try { - new ConcurrentHashMap(-1, .75f); + new ConcurrentHashMap(-1, .75f); shouldThrow(); } catch (IllegalArgumentException success) {} try { - new ConcurrentHashMap(16, -1); + new ConcurrentHashMap(16, -1); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -597,17 +598,17 @@ public void testConstructor2() { */ public void testConstructor3() { try { - new ConcurrentHashMap(-1, .75f, 1); + new ConcurrentHashMap(-1, .75f, 1); shouldThrow(); } catch (IllegalArgumentException success) {} try { - new ConcurrentHashMap(16, -1, 1); + new ConcurrentHashMap(16, -1, 1); shouldThrow(); } catch (IllegalArgumentException success) {} try { - new ConcurrentHashMap(16, .75f, -1); + new ConcurrentHashMap(16, .75f, -1); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -618,7 +619,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new ConcurrentHashMap(null); + new ConcurrentHashMap(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -628,8 +629,8 @@ public void testConstructor4() { * as the given map */ public void testConstructor5() { - ConcurrentHashMap map1 = map5(); - ConcurrentHashMap map2 = new ConcurrentHashMap(map5()); + ConcurrentHashMap map1 = map5(); + ConcurrentHashMap map2 = new ConcurrentHashMap<>(map1); assertTrue(map2.equals(map1)); map2.put(one, "F"); assertFalse(map2.equals(map1)); @@ -639,7 +640,7 @@ public void testConstructor5() { * get(null) throws NPE */ public void testGet_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.get(null); shouldThrow(); @@ -650,7 +651,7 @@ public void testGet_NullPointerException() { * containsKey(null) throws NPE */ public void testContainsKey_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.containsKey(null); shouldThrow(); @@ -661,7 +662,7 @@ public void testContainsKey_NullPointerException() { * containsValue(null) throws NPE */ public void testContainsValue_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.containsValue(null); shouldThrow(); @@ -672,7 +673,7 @@ public void testContainsValue_NullPointerException() { * contains(null) throws NPE */ public void testContains_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.contains(null); shouldThrow(); @@ -683,7 +684,7 @@ public void testContains_NullPointerException() { * put(null,x) throws NPE */ public void testPut1_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.put(null, "whatever"); shouldThrow(); @@ -694,9 +695,9 @@ public void testPut1_NullPointerException() { * put(x, null) throws NPE */ public void testPut2_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.put("whatever", null); + c.put(zero, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -705,7 +706,7 @@ public void testPut2_NullPointerException() { * putIfAbsent(null, x) throws NPE */ public void testPutIfAbsent1_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.putIfAbsent(null, "whatever"); shouldThrow(); @@ -716,7 +717,7 @@ public void testPutIfAbsent1_NullPointerException() { * replace(null, x) throws NPE */ public void testReplace_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { c.replace(null, "whatever"); shouldThrow(); @@ -727,9 +728,9 @@ public void testReplace_NullPointerException() { * replace(null, x, y) throws NPE */ public void testReplaceValue_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.replace(null, one, "whatever"); + c.replace(null, "A", "B"); shouldThrow(); } catch (NullPointerException success) {} } @@ -738,9 +739,9 @@ public void testReplaceValue_NullPointerException() { * putIfAbsent(x, null) throws NPE */ public void testPutIfAbsent2_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.putIfAbsent("whatever", null); + c.putIfAbsent(zero, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -749,9 +750,9 @@ public void testPutIfAbsent2_NullPointerException() { * replace(x, null) throws NPE */ public void testReplace2_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.replace("whatever", null); + c.replace(one, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -760,9 +761,9 @@ public void testReplace2_NullPointerException() { * replace(x, null, y) throws NPE */ public void testReplaceValue2_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.replace("whatever", null, "A"); + c.replace(one, null, "A"); shouldThrow(); } catch (NullPointerException success) {} } @@ -771,9 +772,9 @@ public void testReplaceValue2_NullPointerException() { * replace(x, y, null) throws NPE */ public void testReplaceValue3_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); try { - c.replace("whatever", one, null); + c.replace(zero, "A", null); shouldThrow(); } catch (NullPointerException success) {} } @@ -782,8 +783,8 @@ public void testReplaceValue3_NullPointerException() { * remove(null) throws NPE */ public void testRemove1_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); + c.put(one, "asdads"); try { c.remove(null); shouldThrow(); @@ -794,8 +795,8 @@ public void testRemove1_NullPointerException() { * remove(null, x) throws NPE */ public void testRemove2_NullPointerException() { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); + c.put(one, "asdads"); try { c.remove(null, "whatever"); shouldThrow(); @@ -806,41 +807,43 @@ public void testRemove2_NullPointerException() { * remove(x, null) returns false */ public void testRemove3() { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); - assertFalse(c.remove("sadsdf", null)); + ConcurrentHashMap c = new ConcurrentHashMap<>(5); + c.put(one, "asdads"); + assertFalse(c.remove(one, null)); } /** * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { - Map x = map5(); - Map y = serialClone(x); + Map x = map5(); + Map y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); } /** * SetValue of an EntrySet entry sets value in the map. */ + @SuppressWarnings("unchecked") public void testSetValueWriteThrough() { // Adapted from a bug report by Eric Zoerner - ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1); + ConcurrentHashMap map = new ConcurrentHashMap<>(2, 5.0f, 1); assertTrue(map.isEmpty()); for (int i = 0; i < 20; i++) - map.put(new Integer(i), new Integer(i)); + map.put(itemFor(i), itemFor(i)); assertFalse(map.isEmpty()); - Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next(); + Item key = itemFor(16); + Map.Entry entry1 = map.entrySet().iterator().next(); // Unless it happens to be first (in which case remainder of // test is skipped), remove a possibly-colliding key from map // which, under some implementations, may cause entry1 to be // cloned in map - if (!entry1.getKey().equals(new Integer(16))) { - map.remove(new Integer(16)); + if (!entry1.getKey().equals(key)) { + map.remove(key); entry1.setValue("XYZ"); assertTrue(map.containsValue("XYZ")); // fails if write-through broken } @@ -853,30 +856,31 @@ public void testSetValueWriteThrough() { public void testRemoveAll_performance() { final int mapSize = expensiveTests ? 1_000_000 : 100; final int iterations = expensiveTests ? 500 : 2; - final ConcurrentHashMap map = new ConcurrentHashMap<>(); - for (int i = 0; i < mapSize; i++) - map.put(i, i); - Set keySet = map.keySet(); - Collection removeMe = Arrays.asList(new Integer[] { -99, -86 }); + final ConcurrentHashMap map = new ConcurrentHashMap<>(); + for (int i = 0; i < mapSize; i++) { + Item I = itemFor(i); + map.put(I, I); + } + Set keySet = map.keySet(); + Collection removeMe = Arrays.asList(new Item[] { minusOne, minusTwo }); for (int i = 0; i < iterations; i++) assertFalse(keySet.removeAll(removeMe)); - assertEquals(mapSize, map.size()); + mustEqual(mapSize, map.size()); } public void testReentrantComputeIfAbsent() { - ConcurrentHashMap map = new ConcurrentHashMap<>(16); + ConcurrentHashMap map = new ConcurrentHashMap<>(16); try { for (int i = 0; i < 100; i++) { // force a resize - map.computeIfAbsent(i, key -> findValue(map, key)); + map.computeIfAbsent(new Item(i), key -> new Item(findValue(map, key))); } fail("recursive computeIfAbsent should throw IllegalStateException"); } catch (IllegalStateException success) {} } - private Integer findValue(ConcurrentHashMap map, - Integer key) { - return (key % 5 == 0) ? key : - map.computeIfAbsent(key + 1, k -> findValue(map, k)); + private static Item findValue(ConcurrentHashMap map, + Item key) { + return (key.value % 5 == 0) ? key : + map.computeIfAbsent(new Item(key.value + 1), k -> new Item(findValue(map, k))); } - } diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java index e193c923921..58e4a32143b 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java @@ -57,7 +57,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return ConcurrentLinkedDeque.class; } public Collection emptyCollection() { return new ConcurrentLinkedDeque(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -67,17 +67,17 @@ class Implementation implements CollectionImplementation { /** * Returns a new deque of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static ConcurrentLinkedDeque populatedDeque(int n) { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); + private static ConcurrentLinkedDeque populatedDeque(int n) { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peekFirst()); - assertEquals((Integer) (n - 1), q.peekLast()); + mustEqual(n, q.size()); + mustEqual(0, q.peekFirst()); + mustEqual((n - 1), q.peekLast()); return q; } @@ -85,8 +85,8 @@ private static ConcurrentLinkedDeque populatedDeque(int n) { * new deque is empty */ public void testConstructor1() { - assertTrue(new ConcurrentLinkedDeque().isEmpty()); - assertEquals(0, new ConcurrentLinkedDeque().size()); + assertTrue(new ConcurrentLinkedDeque().isEmpty()); + mustEqual(0, new ConcurrentLinkedDeque().size()); } /** @@ -94,7 +94,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new ConcurrentLinkedDeque((Collection)null); + new ConcurrentLinkedDeque((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -104,7 +104,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new ConcurrentLinkedDeque(Arrays.asList(new Integer[SIZE])); + new ConcurrentLinkedDeque(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -113,11 +113,9 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; items[0] = zero; try { - new ConcurrentLinkedDeque(Arrays.asList(ints)); + new ConcurrentLinkedDeque(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -126,19 +124,17 @@ public void testConstructor5() { * Deque contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.isEmpty()); q.add(one); assertFalse(q.isEmpty()); @@ -152,14 +148,14 @@ public void testEmpty() { * size() changes when elements added and removed */ public void testSize() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.remove(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -167,7 +163,7 @@ public void testSize() { * push(null) throws NPE */ public void testPushNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.push(null); shouldThrow(); @@ -178,7 +174,7 @@ public void testPushNull() { * peekFirst() returns element inserted with push */ public void testPush() { - ConcurrentLinkedDeque q = populatedDeque(3); + ConcurrentLinkedDeque q = populatedDeque(3); q.pollLast(); q.push(four); assertSame(four, q.peekFirst()); @@ -188,9 +184,9 @@ public void testPush() { * pop() removes first element, or throws NSEE if empty */ public void testPop() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pop()); + mustEqual(i, q.pop()); } try { q.pop(); @@ -202,7 +198,7 @@ public void testPop() { * offer(null) throws NPE */ public void testOfferNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.offer(null); shouldThrow(); @@ -213,7 +209,7 @@ public void testOfferNull() { * offerFirst(null) throws NPE */ public void testOfferFirstNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.offerFirst(null); shouldThrow(); @@ -224,7 +220,7 @@ public void testOfferFirstNull() { * offerLast(null) throws NPE */ public void testOfferLastNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.offerLast(null); shouldThrow(); @@ -235,7 +231,7 @@ public void testOfferLastNull() { * offer(x) succeeds */ public void testOffer() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); assertSame(zero, q.peekFirst()); @@ -246,7 +242,7 @@ public void testOffer() { * offerFirst(x) succeeds */ public void testOfferFirst() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.offerFirst(zero)); assertTrue(q.offerFirst(one)); assertSame(one, q.peekFirst()); @@ -257,7 +253,7 @@ public void testOfferFirst() { * offerLast(x) succeeds */ public void testOfferLast() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.offerLast(zero)); assertTrue(q.offerLast(one)); assertSame(zero, q.peekFirst()); @@ -268,7 +264,7 @@ public void testOfferLast() { * add(null) throws NPE */ public void testAddNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.add(null); shouldThrow(); @@ -279,7 +275,7 @@ public void testAddNull() { * addFirst(null) throws NPE */ public void testAddFirstNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.addFirst(null); shouldThrow(); @@ -290,7 +286,7 @@ public void testAddFirstNull() { * addLast(null) throws NPE */ public void testAddLastNull() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.addLast(null); shouldThrow(); @@ -301,7 +297,7 @@ public void testAddLastNull() { * add(x) succeeds */ public void testAdd() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.add(zero)); assertTrue(q.add(one)); assertSame(zero, q.peekFirst()); @@ -312,7 +308,7 @@ public void testAdd() { * addFirst(x) succeeds */ public void testAddFirst() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); q.addFirst(zero); q.addFirst(one); assertSame(one, q.peekFirst()); @@ -323,7 +319,7 @@ public void testAddFirst() { * addLast(x) succeeds */ public void testAddLast() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); q.addLast(zero); q.addLast(one); assertSame(zero, q.peekFirst()); @@ -334,7 +330,7 @@ public void testAddLast() { * addAll(null) throws NPE */ public void testAddAll1() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { q.addAll(null); shouldThrow(); @@ -345,7 +341,7 @@ public void testAddAll1() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); try { q.addAll(q); shouldThrow(); @@ -356,9 +352,9 @@ public void testAddAllSelf() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); try { - q.addAll(Arrays.asList(new Integer[SIZE])); + q.addAll(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -368,12 +364,10 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -382,24 +376,22 @@ public void testAddAll3() { * Deque contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * pollFirst() succeeds unless empty */ public void testPollFirst() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -408,9 +400,9 @@ public void testPollFirst() { * pollLast() succeeds unless empty */ public void testPollLast() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollLast()); } @@ -419,9 +411,9 @@ public void testPollLast() { * poll() succeeds unless empty */ public void testPoll() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -430,10 +422,10 @@ public void testPoll() { * peek() returns next element, or null if empty */ public void testPeek() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -444,10 +436,10 @@ public void testPeek() { * element() returns first element, or throws NSEE if empty */ public void testElement() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -459,9 +451,9 @@ public void testElement() { * remove() removes next element, or throws NSEE if empty */ public void testRemove() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -473,19 +465,19 @@ public void testRemove() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -494,10 +486,10 @@ public void testRemoveElement() { * peekFirst() returns next element, or null if empty */ public void testPeekFirst() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peekFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.peekFirst()); + mustEqual(i, q.pollFirst()); assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i)); } @@ -508,10 +500,10 @@ public void testPeekFirst() { * peekLast() returns next element, or null if empty */ public void testPeekLast() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.peekLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.peekLast()); + mustEqual(i, q.pollLast()); assertTrue(q.peekLast() == null || !q.peekLast().equals(i)); } @@ -522,10 +514,10 @@ public void testPeekLast() { * getFirst() returns first element, or throws NSEE if empty */ public void testFirstElement() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.getFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.getFirst()); + mustEqual(i, q.pollFirst()); } try { q.getFirst(); @@ -537,10 +529,10 @@ public void testFirstElement() { * getLast() returns last element, or throws NSEE if empty */ public void testLastElement() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.getLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.getLast()); + mustEqual(i, q.pollLast()); } try { q.getLast(); @@ -553,9 +545,9 @@ public void testLastElement() { * removeFirst() removes first element, or throws NSEE if empty */ public void testRemoveFirst() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.removeFirst()); + mustEqual(i, q.removeFirst()); } try { q.removeFirst(); @@ -568,9 +560,9 @@ public void testRemoveFirst() { * removeLast() removes last element, or throws NSEE if empty */ public void testRemoveLast() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.removeLast()); + mustEqual(i, q.removeLast()); } try { q.removeLast(); @@ -583,13 +575,13 @@ public void testRemoveLast() { * removeFirstOccurrence(x) removes x and returns true if present */ public void testRemoveFirstOccurrence() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); - assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); + assertFalse(q.removeFirstOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } @@ -598,13 +590,13 @@ public void testRemoveFirstOccurrence() { * removeLastOccurrence(x) removes x and returns true if present */ public void testRemoveLastOccurrence() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); + assertTrue(q.removeLastOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); - assertFalse(q.removeLastOccurrence(new Integer(i + 1))); + assertTrue(q.removeLastOccurrence(itemFor(i))); + assertFalse(q.removeLastOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } @@ -613,11 +605,11 @@ public void testRemoveLastOccurrence() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -625,10 +617,10 @@ public void testContains() { * clear() removes all elements */ public void testClear() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); q.add(one); assertFalse(q.isEmpty()); q.clear(); @@ -639,12 +631,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); - ConcurrentLinkedDeque p = new ConcurrentLinkedDeque(); + ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque p = new ConcurrentLinkedDeque<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -653,8 +645,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if change */ public void testRetainAll() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); - ConcurrentLinkedDeque p = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque p = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -663,7 +655,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -673,13 +665,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - ConcurrentLinkedDeque q = populatedDeque(SIZE); - ConcurrentLinkedDeque p = populatedDeque(i); + ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque p = populatedDeque(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + mustNotContain(q, p.remove()); } } } @@ -688,7 +679,7 @@ public void testRemoveAll() { * toArray() contains all elements in FIFO order */ public void testToArray() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -700,11 +691,11 @@ public void testToArray() { * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + ConcurrentLinkedDeque q = populatedDeque(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -713,7 +704,7 @@ public void testToArray2() { * toArray(null) throws NullPointerException */ public void testToArray_NullArg() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); try { q.toArray((Object[])null); shouldThrow(); @@ -723,8 +714,9 @@ public void testToArray_NullArg() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + ConcurrentLinkedDeque q = populatedDeque(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -735,12 +727,12 @@ public void testToArray1_BadArg() { * Iterator iterates through all elements */ public void testIterator() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); - Iterator it = q.iterator(); + ConcurrentLinkedDeque q = populatedDeque(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -748,7 +740,7 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - Deque c = new ConcurrentLinkedDeque(); + Deque c = new ConcurrentLinkedDeque<>(); assertIteratorExhausted(c.iterator()); assertIteratorExhausted(c.descendingIterator()); } @@ -757,57 +749,57 @@ public void testEmptyIterator() { * Iterator ordering is FIFO */ public void testIteratorOrdering() { - final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); q.add(one); q.add(two); q.add(three); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals("deque should be empty again", 0, q.size()); + mustEqual(0, q.size()); } /** * iterator.remove() removes current element */ public void testIteratorRemove() { - final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = 1; j <= max; ++j) - q.add(new Integer(j)); - Iterator it = q.iterator(); + mustAdd(q, j); + Iterator it = q.iterator(); for (int j = 1; j <= split; ++j) - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); - assertEquals(it.next(), new Integer(split + 1)); + mustEqual(it.next(), itemFor(split + 1)); for (int j = 1; j <= split; ++j) - q.remove(new Integer(j)); + q.remove(itemFor(j)); it = q.iterator(); for (int j = split + 1; j <= max; ++j) { - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); } assertFalse(it.hasNext()); @@ -819,14 +811,14 @@ public void testIteratorRemove() { * Descending iterator iterates through all elements */ public void testDescendingIterator() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); int i = 0; - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertFalse(it.hasNext()); try { it.next(); @@ -838,17 +830,17 @@ public void testDescendingIterator() { * Descending iterator ordering is reverse FIFO */ public void testDescendingIteratorOrdering() { - final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); for (int iters = 0; iters < 100; ++iters) { - q.add(new Integer(3)); - q.add(new Integer(2)); - q.add(new Integer(1)); + mustAdd(q, three); + mustAdd(q, two); + mustAdd(q, one); int k = 0; - for (Iterator it = q.descendingIterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.descendingIterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); q.remove(); q.remove(); q.remove(); @@ -859,23 +851,23 @@ public void testDescendingIteratorOrdering() { * descendingIterator.remove() removes current element */ public void testDescendingIteratorRemove() { - final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); final Random rng = new Random(); for (int iters = 0; iters < 100; ++iters) { int max = rng.nextInt(5) + 2; int split = rng.nextInt(max - 1) + 1; for (int j = max; j >= 1; --j) - q.add(new Integer(j)); - Iterator it = q.descendingIterator(); + mustAdd(q, j); + Iterator it = q.descendingIterator(); for (int j = 1; j <= split; ++j) - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); - assertEquals(it.next(), new Integer(split + 1)); + mustEqual(it.next(), itemFor(split + 1)); for (int j = 1; j <= split; ++j) - q.remove(new Integer(j)); + q.remove(itemFor(j)); it = q.descendingIterator(); for (int j = split + 1; j <= max; ++j) { - assertEquals(it.next(), new Integer(j)); + mustEqual(it.next(), j); it.remove(); } assertFalse(it.hasNext()); @@ -887,7 +879,7 @@ public void testDescendingIteratorRemove() { * toString() contains toStrings of elements */ public void testToString() { - ConcurrentLinkedDeque q = populatedDeque(SIZE); + ConcurrentLinkedDeque q = populatedDeque(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -898,16 +890,16 @@ public void testToString() { * A deserialized/reserialized deque has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedDeque(SIZE); - Queue y = serialClone(x); + Queue x = populatedDeque(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -918,7 +910,7 @@ public void testSerialization() throws Exception { */ public void testNeverContainsNull() { Deque[] qs = { - new ConcurrentLinkedDeque(), + new ConcurrentLinkedDeque<>(), populatedDeque(2), }; @@ -956,21 +948,21 @@ public void testBug8188900() { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final LongAdder nulls = new LongAdder(), zeros = new LongAdder(); for (int n = expensiveTests ? 100_000 : 10; n--> 0; ) { - ConcurrentLinkedDeque d = new ConcurrentLinkedDeque<>(); + ConcurrentLinkedDeque d = new ConcurrentLinkedDeque<>(); boolean peek = rnd.nextBoolean(); Runnable getter = () -> { - Integer x = peek ? d.peekFirst() : d.pollFirst(); + Item x = peek ? d.peekFirst() : d.pollFirst(); if (x == null) nulls.increment(); - else if (x == 0) zeros.increment(); + else if (x.value == 0) zeros.increment(); else throw new AssertionError( String.format( - "unexpected value %d after %d nulls and %d zeros", + "unexpected value %s after %d nulls and %d zeros", x, nulls.sum(), zeros.sum())); }; - Runnable adder = () -> { d.addFirst(0); d.addLast(42); }; + Runnable adder = () -> { d.addFirst(zero); d.addLast(fortytwo); }; runAsync(getter, adder); } @@ -983,21 +975,21 @@ public void testBug8188900_reverse() { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final LongAdder nulls = new LongAdder(), zeros = new LongAdder(); for (int n = expensiveTests ? 100_000 : 10; n--> 0; ) { - ConcurrentLinkedDeque d = new ConcurrentLinkedDeque<>(); + ConcurrentLinkedDeque d = new ConcurrentLinkedDeque<>(); boolean peek = rnd.nextBoolean(); Runnable getter = () -> { - Integer x = peek ? d.peekLast() : d.pollLast(); + Item x = peek ? d.peekLast() : d.pollLast(); if (x == null) nulls.increment(); - else if (x == 0) zeros.increment(); + else if (x.value == 0) zeros.increment(); else throw new AssertionError( String.format( - "unexpected value %d after %d nulls and %d zeros", + "unexpected value %s after %d nulls and %d zeros", x, nulls.sum(), zeros.sum())); }; - Runnable adder = () -> { d.addLast(0); d.addFirst(42); }; + Runnable adder = () -> { d.addLast(zero); d.addFirst(fortytwo); }; runAsync(getter, adder); } @@ -1010,7 +1002,6 @@ public void testBug8188900_reverse() { * ant -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ConcurrentLinkedDequeTest -Djsr166.methodFilter=testBug8189387 tck */ public void testBug8189387() { - final ThreadLocalRandom rnd = ThreadLocalRandom.current(); Object x = new Object(); for (int n = expensiveTests ? 100_000 : 10; n--> 0; ) { ConcurrentLinkedDeque d = new ConcurrentLinkedDeque<>(); diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java index badf29ca2e7..605c9e55dbc 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java @@ -52,7 +52,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return ConcurrentLinkedQueue.class; } public Collection emptyCollection() { return new ConcurrentLinkedQueue(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -62,16 +62,16 @@ class Implementation implements CollectionImplementation { /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static ConcurrentLinkedQueue populatedQueue(int n) { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); + private static ConcurrentLinkedQueue populatedQueue(int n) { + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peek()); + mustEqual(n, q.size()); + mustEqual(0, q.peek()); return q; } @@ -79,7 +79,7 @@ private static ConcurrentLinkedQueue populatedQueue(int n) { * new queue is empty */ public void testConstructor1() { - assertEquals(0, new ConcurrentLinkedQueue().size()); + mustEqual(0, new ConcurrentLinkedQueue().size()); } /** @@ -87,7 +87,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new ConcurrentLinkedQueue((Collection)null); + new ConcurrentLinkedQueue((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -97,7 +97,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new ConcurrentLinkedQueue(Arrays.asList(new Integer[SIZE])); + new ConcurrentLinkedQueue(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -106,11 +106,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; + items[0] = zero; try { - new ConcurrentLinkedQueue(Arrays.asList(ints)); + new ConcurrentLinkedQueue(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -119,19 +118,17 @@ public void testConstructor5() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); assertTrue(q.isEmpty()); q.add(one); assertFalse(q.isEmpty()); @@ -145,14 +142,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.remove(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -160,7 +157,7 @@ public void testSize() { * offer(null) throws NPE */ public void testOfferNull() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); try { q.offer(null); shouldThrow(); @@ -171,7 +168,7 @@ public void testOfferNull() { * add(null) throws NPE */ public void testAddNull() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); try { q.add(null); shouldThrow(); @@ -182,7 +179,7 @@ public void testAddNull() { * Offer returns true */ public void testOffer() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); } @@ -191,10 +188,10 @@ public void testOffer() { * add returns true */ public void testAdd() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -202,7 +199,7 @@ public void testAdd() { * addAll(null) throws NullPointerException */ public void testAddAll1() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); try { q.addAll(null); shouldThrow(); @@ -213,7 +210,7 @@ public void testAddAll1() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -224,9 +221,9 @@ public void testAddAllSelf() { * addAll of a collection with null elements throws NullPointerException */ public void testAddAll2() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); try { - q.addAll(Arrays.asList(new Integer[SIZE])); + q.addAll(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -236,12 +233,11 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); + Item[] items = new Item[2]; + items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -250,24 +246,22 @@ public void testAddAll3() { * Queue contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * poll succeeds unless empty */ public void testPoll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -276,10 +270,10 @@ public void testPoll() { * peek returns next element, or null if empty */ public void testPeek() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -290,10 +284,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -305,9 +299,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -319,19 +313,19 @@ public void testRemove() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -340,11 +334,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -352,10 +346,10 @@ public void testContains() { * clear removes all elements */ public void testClear() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); q.add(one); assertFalse(q.isEmpty()); q.clear(); @@ -366,12 +360,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue p = new ConcurrentLinkedQueue<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -380,8 +374,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if change */ public void testRetainAll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -390,7 +384,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -400,12 +394,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = populatedQueue(i); + ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); + Item x = p.remove(); assertFalse(q.contains(x)); } } @@ -415,7 +409,7 @@ public void testRemoveAll() { * toArray contains all elements in FIFO order */ public void testToArray() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -427,11 +421,11 @@ public void testToArray() { * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + ConcurrentLinkedQueue q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -440,7 +434,7 @@ public void testToArray2() { * toArray(null) throws NullPointerException */ public void testToArray_NullArg() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); try { q.toArray((Object[])null); shouldThrow(); @@ -450,8 +444,9 @@ public void testToArray_NullArg() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + ConcurrentLinkedQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -462,12 +457,12 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + ConcurrentLinkedQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -475,52 +470,52 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new ConcurrentLinkedQueue().iterator()); + assertIteratorExhausted(new ConcurrentLinkedQueue<>().iterator()); } /** * iterator ordering is FIFO */ public void testIteratorOrdering() { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); q.add(one); q.add(two); q.add(three); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals("queue should be empty again", 0, q.size()); + mustEqual(0, q.size()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); + final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); q.add(one); q.add(two); q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); @@ -533,7 +528,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); + ConcurrentLinkedQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -544,16 +539,16 @@ public void testToString() { * A deserialized/reserialized queue has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -563,7 +558,7 @@ public void testSerialization() throws Exception { */ public void testNeverContainsNull() { Collection[] qs = { - new ConcurrentLinkedQueue(), + new ConcurrentLinkedQueue<>(), populatedQueue(2), }; diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListMapTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListMapTest.java index 1297186b61d..044f126dd9e 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListMapTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListMapTest.java @@ -66,10 +66,10 @@ class Implementation implements MapImplementation { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static ConcurrentSkipListMap map5() { - ConcurrentSkipListMap map = new ConcurrentSkipListMap(); + private static ConcurrentSkipListMap map5() { + ConcurrentSkipListMap map = new ConcurrentSkipListMap<>(); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(five, "E"); @@ -77,7 +77,7 @@ private static ConcurrentSkipListMap map5() { map.put(two, "B"); map.put(four, "D"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map; } @@ -85,28 +85,28 @@ private static ConcurrentSkipListMap map5() { * clear removes all pairs */ public void testClear() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * copy constructor creates map equal to source map */ public void testConstructFromSorted() { - ConcurrentSkipListMap map = map5(); - ConcurrentSkipListMap map2 = new ConcurrentSkipListMap(map); - assertEquals(map, map2); + ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map2 = new ConcurrentSkipListMap<>(map); + mustEqual(map, map2); } /** * Maps with same contents are equal */ public void testEquals() { - ConcurrentSkipListMap map1 = map5(); - ConcurrentSkipListMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + ConcurrentSkipListMap map1 = map5(); + ConcurrentSkipListMap map2 = map5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -116,7 +116,7 @@ public void testEquals() { * containsKey returns true for contained key */ public void testContainsKey() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); } @@ -125,7 +125,7 @@ public void testContainsKey() { * containsValue returns true for held values */ public void testContainsValue() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -135,9 +135,9 @@ public void testContainsValue() { * or null if not present */ public void testGet() { - ConcurrentSkipListMap map = map5(); - assertEquals("A", (String)map.get(one)); - ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); + ConcurrentSkipListMap map = map5(); + mustEqual("A", map.get(one)); + ConcurrentSkipListMap empty = new ConcurrentSkipListMap<>(); assertNull(empty.get(one)); } @@ -145,8 +145,8 @@ public void testGet() { * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { - ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap empty = new ConcurrentSkipListMap<>(); + ConcurrentSkipListMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -155,28 +155,28 @@ public void testIsEmpty() { * firstKey returns first key */ public void testFirstKey() { - ConcurrentSkipListMap map = map5(); - assertEquals(one, map.firstKey()); + ConcurrentSkipListMap map = map5(); + mustEqual(one, map.firstKey()); } /** * lastKey returns last key */ public void testLastKey() { - ConcurrentSkipListMap map = map5(); - assertEquals(five, map.lastKey()); + ConcurrentSkipListMap map = map5(); + mustEqual(five, map.lastKey()); } /** * keySet.toArray returns contains all keys */ public void testKeySetToArray() { - ConcurrentSkipListMap map = map5(); - Set s = map.keySet(); + ConcurrentSkipListMap map = map5(); + Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -184,12 +184,12 @@ public void testKeySetToArray() { * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { - ConcurrentSkipListMap map = map5(); - Set s = map.descendingKeySet(); + ConcurrentSkipListMap map = map5(); + Set s = map.descendingKeySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); - ar[0] = m10; + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -197,101 +197,101 @@ public void testDescendingKeySetToArray() { * keySet returns a Set containing all the keys */ public void testKeySet() { - ConcurrentSkipListMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); + ConcurrentSkipListMap map = map5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, one); + mustContain(s, two); + mustContain(s, three); + mustContain(s, four); + mustContain(s, five); } /** * keySet is ordered */ public void testKeySetOrder() { - ConcurrentSkipListMap map = map5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + ConcurrentSkipListMap map = map5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = i.next(); + mustEqual(last, one); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descending iterator of key set is inverse ordered */ public void testKeySetDescendingIteratorOrder() { - ConcurrentSkipListMap map = map5(); - NavigableSet s = map.navigableKeySet(); - Iterator i = s.descendingIterator(); - Integer last = (Integer)i.next(); - assertEquals(last, five); + ConcurrentSkipListMap map = map5(); + NavigableSet s = map.navigableKeySet(); + Iterator i = s.descendingIterator(); + Item last = (Item)i.next(); + mustEqual(last, five); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descendingKeySet is ordered */ public void testDescendingKeySetOrder() { - ConcurrentSkipListMap map = map5(); - Set s = map.descendingKeySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, five); + ConcurrentSkipListMap map = map5(); + Set s = map.descendingKeySet(); + Iterator i = s.iterator(); + Item last = (Item)i.next(); + mustEqual(last, five); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descending iterator of descendingKeySet is ordered */ public void testDescendingKeySetDescendingIteratorOrder() { - ConcurrentSkipListMap map = map5(); - NavigableSet s = map.descendingKeySet(); - Iterator i = s.descendingIterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + ConcurrentSkipListMap map = map5(); + NavigableSet s = map.descendingKeySet(); + Iterator i = s.descendingIterator(); + Item last = (Item)i.next(); + mustEqual(last, one); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * Values.toArray contains all values */ public void testValuesToArray() { - ConcurrentSkipListMap map = map5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); + ConcurrentSkipListMap map = map5(); + Collection v = map.values(); + String[] ar = v.toArray(new String[0]); + ArrayList s = new ArrayList<>(Arrays.asList(ar)); + mustEqual(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -303,9 +303,9 @@ public void testValuesToArray() { * values collection contains all values */ public void testValues() { - ConcurrentSkipListMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); + ConcurrentSkipListMap map = map5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -317,12 +317,12 @@ public void testValues() { * entrySet contains all pairs */ public void testEntrySet() { - ConcurrentSkipListMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + ConcurrentSkipListMap map = map5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -336,12 +336,12 @@ public void testEntrySet() { * descendingEntrySet contains all pairs */ public void testDescendingEntrySet() { - ConcurrentSkipListMap map = map5(); - Set s = map.descendingMap().entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + ConcurrentSkipListMap map = map5(); + Set> s = map.descendingMap().entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -355,10 +355,10 @@ public void testDescendingEntrySet() { * entrySet.toArray contains all entries */ public void testEntrySetToArray() { - ConcurrentSkipListMap map = map5(); - Set s = map.entrySet(); + ConcurrentSkipListMap map = map5(); + Set> s = map.entrySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); @@ -369,10 +369,10 @@ public void testEntrySetToArray() { * descendingEntrySet.toArray contains all entries */ public void testDescendingEntrySetToArray() { - ConcurrentSkipListMap map = map5(); - Set s = map.descendingMap().entrySet(); + ConcurrentSkipListMap map = map5(); + Set> s = map.descendingMap().entrySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); @@ -383,22 +383,22 @@ public void testDescendingEntrySetToArray() { * putAll adds all key-value pairs from the given map */ public void testPutAll() { - ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); - ConcurrentSkipListMap map = map5(); - empty.putAll(map); - assertEquals(5, empty.size()); - assertTrue(empty.containsKey(one)); - assertTrue(empty.containsKey(two)); - assertTrue(empty.containsKey(three)); - assertTrue(empty.containsKey(four)); - assertTrue(empty.containsKey(five)); + ConcurrentSkipListMap p = new ConcurrentSkipListMap<>(); + ConcurrentSkipListMap map = map5(); + p.putAll(map); + mustEqual(5, p.size()); + assertTrue(p.containsKey(one)); + assertTrue(p.containsKey(two)); + assertTrue(p.containsKey(three)); + assertTrue(p.containsKey(four)); + assertTrue(p.containsKey(five)); } /** * putIfAbsent works when the given key is not present */ public void testPutIfAbsent() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); map.putIfAbsent(six, "Z"); assertTrue(map.containsKey(six)); } @@ -407,15 +407,15 @@ public void testPutIfAbsent() { * putIfAbsent does not add the pair if the key is already present */ public void testPutIfAbsent2() { - ConcurrentSkipListMap map = map5(); - assertEquals("A", map.putIfAbsent(one, "Z")); + ConcurrentSkipListMap map = map5(); + mustEqual("A", map.putIfAbsent(one, "Z")); } /** * replace fails when the given key is not present */ public void testReplace() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); assertNull(map.replace(six, "Z")); assertFalse(map.containsKey(six)); } @@ -424,38 +424,38 @@ public void testReplace() { * replace succeeds if the key is already present */ public void testReplace2() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); assertNotNull(map.replace(one, "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * replace value fails when the given key not mapped to expected value */ public void testReplaceValue() { - ConcurrentSkipListMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentSkipListMap map = map5(); + mustEqual("A", map.get(one)); assertFalse(map.replace(one, "Z", "Z")); - assertEquals("A", map.get(one)); + mustEqual("A", map.get(one)); } /** * replace value succeeds when the given key mapped to expected value */ public void testReplaceValue2() { - ConcurrentSkipListMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentSkipListMap map = map5(); + mustEqual("A", map.get(one)); assertTrue(map.replace(one, "A", "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * remove removes the correct key-value pair from the map */ public void testRemove() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); map.remove(five); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); } @@ -463,14 +463,14 @@ public void testRemove() { * remove(key,value) removes only if pair present */ public void testRemove2() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); assertTrue(map.containsKey(five)); - assertEquals("E", map.get(five)); + mustEqual("E", map.get(five)); map.remove(five, "E"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); map.remove(four, "A"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertTrue(map.containsKey(four)); } @@ -478,17 +478,17 @@ public void testRemove2() { * lowerEntry returns preceding entry. */ public void testLowerEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e1 = map.lowerEntry(three); - assertEquals(two, e1.getKey()); + ConcurrentSkipListMap map = map5(); + Map.Entry e1 = map.lowerEntry(three); + mustEqual(two, e1.getKey()); - Map.Entry e2 = map.lowerEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.lowerEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.lowerEntry(one); + Map.Entry e3 = map.lowerEntry(one); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -496,17 +496,17 @@ public void testLowerEntry() { * higherEntry returns next entry. */ public void testHigherEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e1 = map.higherEntry(three); - assertEquals(four, e1.getKey()); + ConcurrentSkipListMap map = map5(); + Map.Entry e1 = map.higherEntry(three); + mustEqual(four, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.higherEntry(five); + Map.Entry e3 = map.higherEntry(five); assertNull(e3); - Map.Entry e4 = map.higherEntry(six); + Map.Entry e4 = map.higherEntry(six); assertNull(e4); } @@ -514,17 +514,17 @@ public void testHigherEntry() { * floorEntry returns preceding entry. */ public void testFloorEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e1 = map.floorEntry(three); - assertEquals(three, e1.getKey()); + ConcurrentSkipListMap map = map5(); + Map.Entry e1 = map.floorEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.floorEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.floorEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.floorEntry(one); - assertEquals(one, e3.getKey()); + Map.Entry e3 = map.floorEntry(one); + mustEqual(one, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -532,17 +532,17 @@ public void testFloorEntry() { * ceilingEntry returns next entry. */ public void testCeilingEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e1 = map.ceilingEntry(three); - assertEquals(three, e1.getKey()); + ConcurrentSkipListMap map = map5(); + Map.Entry e1 = map.ceilingEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(five); - assertEquals(five, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(five); + mustEqual(five, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(six); + Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); } @@ -551,27 +551,27 @@ public void testCeilingEntry() { * immutable entries */ public void testEntryImmutability() { - ConcurrentSkipListMap map = map5(); - Map.Entry e = map.lowerEntry(three); - assertEquals(two, e.getKey()); + ConcurrentSkipListMap map = map5(); + Map.Entry e = map.lowerEntry(three); + mustEqual(two, e.getKey()); try { e.setValue("X"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.higherEntry(zero); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("X"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.floorEntry(one); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("X"); shouldThrow(); } catch (UnsupportedOperationException success) {} e = map.ceilingEntry(five); - assertEquals(five, e.getKey()); + mustEqual(five, e.getKey()); try { e.setValue("X"); shouldThrow(); @@ -582,12 +582,12 @@ public void testEntryImmutability() { * lowerKey returns preceding element */ public void testLowerKey() { - ConcurrentSkipListMap q = map5(); + ConcurrentSkipListMap q = map5(); Object e1 = q.lowerKey(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lowerKey(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lowerKey(one); assertNull(e3); @@ -600,12 +600,12 @@ public void testLowerKey() { * higherKey returns next element */ public void testHigherKey() { - ConcurrentSkipListMap q = map5(); + ConcurrentSkipListMap q = map5(); Object e1 = q.higherKey(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higherKey(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higherKey(five); assertNull(e3); @@ -618,15 +618,15 @@ public void testHigherKey() { * floorKey returns preceding element */ public void testFloorKey() { - ConcurrentSkipListMap q = map5(); + ConcurrentSkipListMap q = map5(); Object e1 = q.floorKey(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floorKey(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floorKey(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floorKey(zero); assertNull(e4); @@ -636,15 +636,15 @@ public void testFloorKey() { * ceilingKey returns next element */ public void testCeilingKey() { - ConcurrentSkipListMap q = map5(); + ConcurrentSkipListMap q = map5(); Object e1 = q.ceilingKey(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceilingKey(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceilingKey(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceilingKey(six); assertNull(e4); @@ -654,21 +654,21 @@ public void testCeilingKey() { * pollFirstEntry returns entries in order */ public void testPollFirstEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + ConcurrentSkipListMap map = map5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(two, e.getKey()); + mustEqual(two, e.getKey()); map.put(one, "A"); e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(four); e = map.pollFirstEntry(); - assertEquals(five, e.getKey()); + mustEqual(five, e.getKey()); try { e.setValue("A"); shouldThrow(); @@ -681,21 +681,21 @@ public void testPollFirstEntry() { * pollLastEntry returns entries in order */ public void testPollLastEntry() { - ConcurrentSkipListMap map = map5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + ConcurrentSkipListMap map = map5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(four, e.getKey()); + mustEqual(four, e.getKey()); map.put(five, "E"); e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(two); e = map.pollLastEntry(); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -708,17 +708,17 @@ public void testPollLastEntry() { * size returns the correct values */ public void testSize() { - ConcurrentSkipListMap map = map5(); - ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap empty = new ConcurrentSkipListMap<>(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testToString() { - ConcurrentSkipListMap map = map5(); + ConcurrentSkipListMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -731,7 +731,7 @@ public void testToString() { * get(null) of nonempty map throws NPE */ public void testGet_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { c.get(null); shouldThrow(); @@ -742,7 +742,7 @@ public void testGet_NullPointerException() { * containsKey(null) of nonempty map throws NPE */ public void testContainsKey_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { c.containsKey(null); shouldThrow(); @@ -753,7 +753,7 @@ public void testContainsKey_NullPointerException() { * containsValue(null) throws NPE */ public void testContainsValue_NullPointerException() { - ConcurrentSkipListMap c = new ConcurrentSkipListMap(); + ConcurrentSkipListMap c = new ConcurrentSkipListMap<>(); try { c.containsValue(null); shouldThrow(); @@ -764,7 +764,7 @@ public void testContainsValue_NullPointerException() { * put(null,x) throws NPE */ public void testPut1_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { c.put(null, "whatever"); shouldThrow(); @@ -775,7 +775,7 @@ public void testPut1_NullPointerException() { * putIfAbsent(null, x) throws NPE */ public void testPutIfAbsent1_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { c.putIfAbsent(null, "whatever"); shouldThrow(); @@ -786,9 +786,9 @@ public void testPutIfAbsent1_NullPointerException() { * replace(null, x) throws NPE */ public void testReplace_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { - c.replace(null, "whatever"); + c.replace(null, "A"); shouldThrow(); } catch (NullPointerException success) {} } @@ -797,9 +797,9 @@ public void testReplace_NullPointerException() { * replace(null, x, y) throws NPE */ public void testReplaceValue_NullPointerException() { - ConcurrentSkipListMap c = map5(); + ConcurrentSkipListMap c = map5(); try { - c.replace(null, one, "whatever"); + c.replace(null, "A", "B"); shouldThrow(); } catch (NullPointerException success) {} } @@ -808,8 +808,8 @@ public void testReplaceValue_NullPointerException() { * remove(null) throws NPE */ public void testRemove1_NullPointerException() { - ConcurrentSkipListMap c = new ConcurrentSkipListMap(); - c.put("sadsdf", "asdads"); + ConcurrentSkipListMap c = new ConcurrentSkipListMap<>(); + c.put(zero, "A"); try { c.remove(null); shouldThrow(); @@ -820,8 +820,8 @@ public void testRemove1_NullPointerException() { * remove(null, x) throws NPE */ public void testRemove2_NullPointerException() { - ConcurrentSkipListMap c = new ConcurrentSkipListMap(); - c.put("sadsdf", "asdads"); + ConcurrentSkipListMap c = new ConcurrentSkipListMap<>(); + c.put(zero, "asdads"); try { c.remove(null, "whatever"); shouldThrow(); @@ -832,8 +832,8 @@ public void testRemove2_NullPointerException() { * remove(x, null) returns false */ public void testRemove3() { - ConcurrentSkipListMap c = new ConcurrentSkipListMap(); - c.put("sadsdf", "asdads"); + ConcurrentSkipListMap c = new ConcurrentSkipListMap<>(); + c.put(zero, "asdads"); assertFalse(c.remove("sadsdf", null)); } @@ -841,14 +841,14 @@ public void testRemove3() { * A cloned map equals original */ public void testClone() { - ConcurrentSkipListMap x = map5(); - ConcurrentSkipListMap y = x.clone(); + ConcurrentSkipListMap x = map5(); + ConcurrentSkipListMap y = x.clone(); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); y.clear(); assertTrue(y.isEmpty()); assertFalse(x.equals(y)); @@ -858,14 +858,14 @@ public void testClone() { * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { - NavigableMap x = map5(); - NavigableMap y = serialClone(x); + NavigableMap x = map5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); y.clear(); assertTrue(y.isEmpty()); assertFalse(x.equals(y)); @@ -875,157 +875,156 @@ public void testSerialization() throws Exception { * subMap returns map with keys in requested range */ public void testSubMapContents() { - ConcurrentSkipListMap map = map5(); - NavigableMap sm = map.subMap(two, true, four, false); - assertEquals(two, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals(2, sm.size()); + ConcurrentSkipListMap map = map5(); + NavigableMap sm = map.subMap(two, true, four, false); + mustEqual(two, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual(2, sm.size()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(three, k); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = (Item)(r.next()); + mustEqual(three, k); + k = (Item)(r.next()); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals("C", sm.remove(three)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual("C", sm.remove(three)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testSubMapContents2() { - ConcurrentSkipListMap map = map5(); - NavigableMap sm = map.subMap(two, true, three, false); - assertEquals(1, sm.size()); - assertEquals(two, sm.firstKey()); - assertEquals(two, sm.lastKey()); + ConcurrentSkipListMap map = map5(); + NavigableMap sm = map.subMap(two, true, three, false); + mustEqual(1, sm.size()); + mustEqual(two, sm.firstKey()); + mustEqual(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = (Item)(r.next()); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); - assertEquals(4, map.size()); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testHeadMapContents() { - ConcurrentSkipListMap map = map5(); - NavigableMap sm = map.headMap(four, false); + ConcurrentSkipListMap map = map5(); + NavigableMap sm = map.headMap(four, false); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(one, k); + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(four, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(four, map.firstKey()); } /** * tailMap returns map with keys in requested range */ public void testTailMapContents() { - ConcurrentSkipListMap map = map5(); - NavigableMap sm = map.tailMap(two, true); + ConcurrentSkipListMap map = map5(); + NavigableMap sm = map.tailMap(two, true); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertTrue(sm.containsKey(four)); assertTrue(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + Iterator i = sm.keySet().iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(five, k); - k = (Integer)(r.next()); - assertEquals(four, k); - k = (Integer)(r.next()); - assertEquals(three, k); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = r.next(); + mustEqual(five, k); + k = r.next(); + mustEqual(four, k); + k = r.next(); + mustEqual(three, k); + k = r.next(); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(two, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(three, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(four, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = (ei.next()); + mustEqual(two, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(three, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(four, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - NavigableMap ssm = sm.tailMap(four, true); - assertEquals(four, ssm.firstKey()); - assertEquals(five, ssm.lastKey()); - assertEquals("D", ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + NavigableMap ssm = sm.tailMap(four, true); + mustEqual(four, ssm.firstKey()); + mustEqual(five, ssm.lastKey()); + mustEqual("D", ssm.remove(four)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } Random rnd = new Random(666); @@ -1036,8 +1035,8 @@ public void testTailMapContents() { */ public void testRecursiveSubMaps() throws Exception { int mapSize = expensiveTests ? 1000 : 100; - Class cl = ConcurrentSkipListMap.class; - NavigableMap map = newMap(cl); + Class cl = ConcurrentSkipListMap.class; + NavigableMap map = newMap(cl); bs = new BitSet(mapSize); populate(map, mapSize); @@ -1048,26 +1047,27 @@ public void testRecursiveSubMaps() throws Exception { check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); - bashSubMap(map.subMap(0, true, mapSize, false), + bashSubMap(map.subMap(zero, true, itemFor(mapSize), false), 0, mapSize - 1, true); } - static NavigableMap newMap(Class cl) throws Exception { - NavigableMap result = - (NavigableMap) cl.getConstructor().newInstance(); - assertEquals(0, result.size()); + static NavigableMap newMap(Class cl) throws Exception { + @SuppressWarnings("unchecked") + NavigableMap result = + (NavigableMap) cl.getConstructor().newInstance(); + mustEqual(0, result.size()); assertFalse(result.keySet().iterator().hasNext()); return result; } - void populate(NavigableMap map, int limit) { + void populate(NavigableMap map, int limit) { for (int i = 0, n = 2 * limit / 3; i < n; i++) { int key = rnd.nextInt(limit); put(map, key); } } - void mutateMap(NavigableMap map, int min, int max) { + void mutateMap(NavigableMap map, int min, int max) { int size = map.size(); int rangeSize = max - min + 1; @@ -1077,9 +1077,9 @@ void mutateMap(NavigableMap map, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { + for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -1092,7 +1092,7 @@ void mutateMap(NavigableMap map, int min, int max) { } } - void mutateSubMap(NavigableMap map, int min, int max) { + void mutateSubMap(NavigableMap map, int min, int max) { int size = map.size(); int rangeSize = max - min + 1; @@ -1102,9 +1102,9 @@ void mutateSubMap(NavigableMap map, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { + for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -1116,24 +1116,24 @@ void mutateSubMap(NavigableMap map, int min, int max) { put(map, key); } else { try { - map.put(key, 2 * key); + map.put(itemFor(key), itemFor(2 * key)); shouldThrow(); } catch (IllegalArgumentException success) {} } } } - void put(NavigableMap map, int key) { - if (map.put(key, 2 * key) == null) + void put(NavigableMap map, int key) { + if (map.put(itemFor(key), itemFor(2 * key)) == null) bs.set(key); } - void remove(NavigableMap map, int key) { - if (map.remove(key) != null) + void remove(NavigableMap map, int key) { + if (map.remove(itemFor(key)) != null) bs.clear(key); } - void bashSubMap(NavigableMap map, + void bashSubMap(NavigableMap map, int min, int max, boolean ascending) { check(map, min, max, ascending); check(map.descendingMap(), min, max, !ascending); @@ -1149,7 +1149,7 @@ void bashSubMap(NavigableMap map, // headMap - pick direction and endpoint inclusion randomly boolean incl = rnd.nextBoolean(); - NavigableMap hm = map.headMap(midPoint, incl); + NavigableMap hm = map.headMap(itemFor(midPoint), incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(hm, min, midPoint - (incl ? 0 : 1), true); @@ -1166,7 +1166,7 @@ void bashSubMap(NavigableMap map, // tailMap - pick direction and endpoint inclusion randomly incl = rnd.nextBoolean(); - NavigableMap tm = map.tailMap(midPoint,incl); + NavigableMap tm = map.tailMap(itemFor(midPoint),incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(tm, midPoint + (incl ? 0 : 1), max, true); @@ -1191,8 +1191,8 @@ void bashSubMap(NavigableMap map, boolean lowIncl = rnd.nextBoolean(); boolean highIncl = rnd.nextBoolean(); if (ascending) { - NavigableMap sm = map.subMap( - endpoints[0], lowIncl, endpoints[1], highIncl); + NavigableMap sm = map.subMap( + itemFor(endpoints[0]), lowIncl, itemFor(endpoints[1]), highIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), true); @@ -1200,8 +1200,8 @@ void bashSubMap(NavigableMap map, bashSubMap(sm.descendingMap(), endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); } else { - NavigableMap sm = map.subMap( - endpoints[1], highIncl, endpoints[0], lowIncl); + NavigableMap sm = map.subMap( + itemFor(endpoints[1]), highIncl, itemFor(endpoints[0]), lowIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); @@ -1214,7 +1214,7 @@ void bashSubMap(NavigableMap map, /** * min and max are both inclusive. If max < min, interval is empty. */ - void check(NavigableMap map, + void check(NavigableMap map, final int min, final int max, final boolean ascending) { class ReferenceSet { int lower(int key) { @@ -1278,30 +1278,31 @@ private int lastAscending() { int size = 0; for (int i = min; i <= max; i++) { boolean bsContainsI = bs.get(i); - assertEquals(bsContainsI, map.containsKey(i)); + mustEqual(bsContainsI, map.containsKey(itemFor(i))); if (bsContainsI) size++; } - assertEquals(size, map.size()); + mustEqual(size, map.size()); // Test contents using contains keySet iterator int size2 = 0; int previousKey = -1; - for (int key : map.keySet()) { - assertTrue(bs.get(key)); + for (Item key : map.keySet()) { + assertTrue(bs.get(key.value)); size2++; assertTrue(previousKey < 0 || - (ascending ? key - previousKey > 0 : key - previousKey < 0)); - previousKey = key; + (ascending ? key.value - previousKey > 0 : key.value - previousKey < 0)); + previousKey = key.value; } - assertEquals(size2, size); + mustEqual(size2, size); // Test navigation ops for (int key = min - 1; key <= max + 1; key++) { - assertEq(map.lowerKey(key), rs.lower(key)); - assertEq(map.floorKey(key), rs.floor(key)); - assertEq(map.higherKey(key), rs.higher(key)); - assertEq(map.ceilingKey(key), rs.ceiling(key)); + Item k = itemFor(key); + assertEq(map.lowerKey(k), rs.lower(key)); + assertEq(map.floorKey(k), rs.floor(key)); + assertEq(map.higherKey(k), rs.higher(key)); + assertEq(map.ceilingKey(k), rs.ceiling(key)); } // Test extrema @@ -1309,8 +1310,8 @@ private int lastAscending() { assertEq(map.firstKey(), rs.first()); assertEq(map.lastKey(), rs.last()); } else { - assertEq(rs.first(), -1); - assertEq(rs.last(), -1); + mustEqual(rs.first(), -1); + mustEqual(rs.last(), -1); try { map.firstKey(); shouldThrow(); @@ -1322,15 +1323,15 @@ private int lastAscending() { } } - static void assertEq(Integer i, int j) { + static void assertEq(Item i, int j) { if (i == null) - assertEquals(j, -1); + mustEqual(j, -1); else - assertEquals((int) i, j); + mustEqual(i, j); } - static boolean eq(Integer i, int j) { - return (i == null) ? j == -1 : i == j; + static boolean eq(Item i, int j) { + return (i == null) ? j == -1 : i.value == j; } } diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java index 3941b23476c..89b2704c8c9 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java @@ -55,6 +55,7 @@ public static Test suite() { } static class MyReverseComparator implements Comparator { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -62,32 +63,32 @@ public int compare(Object x, Object y) { /** * Returns a new set of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static ConcurrentSkipListSet populatedSet(int n) { - ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); + private static ConcurrentSkipListSet populatedSet(int n) { + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); + mustEqual(n, q.size()); return q; } /** * Returns a new set of first 5 ints. */ - private static ConcurrentSkipListSet set5() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + private static ConcurrentSkipListSet set5() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); q.add(one); q.add(two); q.add(three); q.add(four); q.add(five); - assertEquals(5, q.size()); + mustEqual(5, q.size()); return q; } @@ -95,7 +96,7 @@ private static ConcurrentSkipListSet set5() { * A new set has unbounded capacity */ public void testConstructor1() { - assertEquals(0, new ConcurrentSkipListSet().size()); + mustEqual(0, new ConcurrentSkipListSet().size()); } /** @@ -103,7 +104,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new ConcurrentSkipListSet((Collection)null); + new ConcurrentSkipListSet((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -113,7 +114,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new ConcurrentSkipListSet(Arrays.asList(new Integer[SIZE])); + new ConcurrentSkipListSet(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -122,11 +123,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; + items[0] = zero; try { - new ConcurrentSkipListSet(Arrays.asList(ints)); + new ConcurrentSkipListSet(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -135,12 +135,10 @@ public void testConstructor5() { * Set contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentSkipListSet q = new ConcurrentSkipListSet(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** @@ -148,25 +146,24 @@ public void testConstructor6() { */ public void testConstructor7() { MyReverseComparator cmp = new MyReverseComparator(); - ConcurrentSkipListSet q = new ConcurrentSkipListSet(cmp); - assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); + @SuppressWarnings("unchecked") + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(cmp); + mustEqual(cmp, q.comparator()); + Item[] items = defaultItems; + q.addAll(Arrays.asList(items)); for (int i = SIZE - 1; i >= 0; --i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + mustAdd(q, one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + mustAdd(q, two); q.pollFirst(); q.pollFirst(); assertTrue(q.isEmpty()); @@ -176,14 +173,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -191,7 +188,7 @@ public void testSize() { * add(null) throws NPE */ public void testAddNull() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); try { q.add(null); shouldThrow(); @@ -202,7 +199,7 @@ public void testAddNull() { * Add of comparable element succeeds */ public void testAdd() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.add(zero)); assertTrue(q.add(one)); } @@ -211,7 +208,7 @@ public void testAdd() { * Add of duplicate element fails */ public void testAddDup() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.add(zero)); assertFalse(q.add(zero)); } @@ -220,7 +217,7 @@ public void testAddDup() { * Add of non-Comparable throws CCE */ public void testAddNonComparable() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); try { q.add(new Object()); q.add(new Object()); @@ -231,7 +228,7 @@ public void testAddNonComparable() { assertSame(Object.class, q.pollFirst().getClass()); assertNull(q.pollFirst()); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); } } @@ -239,7 +236,7 @@ public void testAddNonComparable() { * addAll(null) throws NPE */ public void testAddAll1() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); try { q.addAll(null); shouldThrow(); @@ -250,10 +247,10 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - Integer[] ints = new Integer[SIZE]; + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); + Item[] items = new Item[SIZE]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -263,12 +260,10 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -277,24 +272,22 @@ public void testAddAll3() { * Set contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * pollFirst succeeds unless empty */ public void testPollFirst() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -303,9 +296,9 @@ public void testPollFirst() { * pollLast succeeds unless empty */ public void testPollLast() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollFirst()); } @@ -314,19 +307,19 @@ public void testPollLast() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -335,11 +328,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -347,11 +340,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -361,12 +354,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - ConcurrentSkipListSet q = populatedSet(SIZE); - ConcurrentSkipListSet p = new ConcurrentSkipListSet(); + ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet p = new ConcurrentSkipListSet<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -375,8 +368,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - ConcurrentSkipListSet q = populatedSet(SIZE); - ConcurrentSkipListSet p = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -385,7 +378,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -395,13 +388,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - ConcurrentSkipListSet q = populatedSet(SIZE); - ConcurrentSkipListSet p = populatedSet(i); + ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -410,12 +402,12 @@ public void testRemoveAll() { * lower returns preceding element */ public void testLower() { - ConcurrentSkipListSet q = set5(); + ConcurrentSkipListSet q = set5(); Object e1 = q.lower(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lower(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lower(one); assertNull(e3); @@ -428,12 +420,12 @@ public void testLower() { * higher returns next element */ public void testHigher() { - ConcurrentSkipListSet q = set5(); + ConcurrentSkipListSet q = set5(); Object e1 = q.higher(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higher(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higher(five); assertNull(e3); @@ -446,15 +438,15 @@ public void testHigher() { * floor returns preceding element */ public void testFloor() { - ConcurrentSkipListSet q = set5(); + ConcurrentSkipListSet q = set5(); Object e1 = q.floor(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floor(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floor(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -464,15 +456,15 @@ public void testFloor() { * ceiling returns next element */ public void testCeiling() { - ConcurrentSkipListSet q = set5(); + ConcurrentSkipListSet q = set5(); Object e1 = q.ceiling(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceiling(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceiling(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceiling(six); assertNull(e4); @@ -482,7 +474,7 @@ public void testCeiling() { * toArray contains all elements in sorted order */ public void testToArray() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -494,10 +486,10 @@ public void testToArray() { * toArray(a) contains all elements in sorted order */ public void testToArray2() { - ConcurrentSkipListSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - assertSame(ints, q.toArray(ints)); - for (Integer o : ints) + ConcurrentSkipListSet q = populatedSet(SIZE); + Item[] items = new Item[SIZE]; + assertSame(items, q.toArray(items)); + for (Item o : items) assertSame(o, q.pollFirst()); assertTrue(q.isEmpty()); } @@ -506,12 +498,12 @@ public void testToArray2() { * iterator iterates through all elements */ public void testIterator() { - ConcurrentSkipListSet q = populatedSet(SIZE); - Iterator it = q.iterator(); + ConcurrentSkipListSet q = populatedSet(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -519,7 +511,7 @@ public void testIterator() { * iterator of empty set has no elements */ public void testEmptyIterator() { - NavigableSet s = new ConcurrentSkipListSet(); + NavigableSet s = new ConcurrentSkipListSet<>(); assertIteratorExhausted(s.iterator()); assertIteratorExhausted(s.descendingSet().iterator()); } @@ -528,18 +520,18 @@ public void testEmptyIterator() { * iterator.remove removes current element */ public void testIteratorRemove() { - final ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -547,7 +539,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - ConcurrentSkipListSet q = populatedSet(SIZE); + ConcurrentSkipListSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -558,16 +550,16 @@ public void testToString() { * A cloned set equals original */ public void testClone() { - ConcurrentSkipListSet x = populatedSet(SIZE); - ConcurrentSkipListSet y = x.clone(); + ConcurrentSkipListSet x = populatedSet(SIZE); + ConcurrentSkipListSet y = x.clone(); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -576,16 +568,16 @@ public void testClone() { * A deserialized/reserialized set equals original */ public void testSerialization() throws Exception { - NavigableSet x = populatedSet(SIZE); - NavigableSet y = serialClone(x); + NavigableSet x = populatedSet(SIZE); + NavigableSet y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -594,119 +586,116 @@ public void testSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testSubSetContents() { - ConcurrentSkipListSet set = set5(); - SortedSet sm = set.subSet(two, four); - assertEquals(two, sm.first()); - assertEquals(three, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + ConcurrentSkipListSet set = set5(); + SortedSet sm = set.subSet(two, four); + mustEqual(two, sm.first()); + mustEqual(three, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.first()); - assertEquals(three, sm.last()); - assertTrue(sm.remove(three)); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.first()); + mustEqual(three, sm.last()); + mustRemove(sm, three); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testSubSetContents2() { - ConcurrentSkipListSet set = set5(); - SortedSet sm = set.subSet(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.first()); - assertEquals(two, sm.last()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertFalse(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + ConcurrentSkipListSet set = set5(); + SortedSet sm = set.subSet(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.first()); + mustEqual(two, sm.last()); + mustNotContain(sm, one); + mustContain(sm, two); + mustNotContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertFalse(sm.remove(three)); - assertEquals(4, set.size()); + mustNotRemove(sm, three); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testHeadSetContents() { - ConcurrentSkipListSet set = set5(); - SortedSet sm = set.headSet(four); - assertTrue(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + ConcurrentSkipListSet set = set5(); + SortedSet sm = set.headSet(four); + mustContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(one, k); + k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(four, set.first()); + mustEqual(2, set.size()); + mustEqual(four, set.first()); } /** * tailSet returns set with keys in requested range */ public void testTailSetContents() { - ConcurrentSkipListSet set = set5(); - SortedSet sm = set.tailSet(two); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertTrue(sm.contains(four)); - assertTrue(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + ConcurrentSkipListSet set = set5(); + SortedSet sm = set.tailSet(two); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustContain(sm, four); + mustContain(sm, five); + mustContain(sm, two); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(four); - assertEquals(four, ssm.first()); - assertEquals(five, ssm.last()); - assertTrue(ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(four); + mustEqual(four, ssm.first()); + mustEqual(five, ssm.last()); + mustRemove(ssm, four); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } Random rnd = new Random(666); @@ -716,9 +705,9 @@ public void testTailSetContents() { */ public void testRecursiveSubSets() throws Exception { int setSize = expensiveTests ? 1000 : 100; - Class cl = ConcurrentSkipListSet.class; + Class cl = ConcurrentSkipListSet.class; - NavigableSet set = newSet(cl); + NavigableSet set = newSet(cl); BitSet bs = new BitSet(setSize); populate(set, setSize, bs); @@ -729,7 +718,7 @@ public void testRecursiveSubSets() throws Exception { check(set, 0, setSize - 1, true, bs); check(set.descendingSet(), 0, setSize - 1, false, bs); - bashSubSet(set.subSet(0, true, setSize, false), + bashSubSet(set.subSet(zero, true, itemFor(setSize), false), 0, setSize - 1, true, bs); } @@ -737,29 +726,30 @@ public void testRecursiveSubSets() throws Exception { * addAll is idempotent */ public void testAddAll_idempotent() throws Exception { - Set x = populatedSet(SIZE); - Set y = new ConcurrentSkipListSet(x); + Set x = populatedSet(SIZE); + Set y = new ConcurrentSkipListSet<>(x); y.addAll(x); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); } - static NavigableSet newSet(Class cl) throws Exception { - NavigableSet result = - (NavigableSet) cl.getConstructor().newInstance(); - assertEquals(0, result.size()); + static NavigableSet newSet(Class cl) throws Exception { + @SuppressWarnings("unchecked") + NavigableSet result = + (NavigableSet) cl.getConstructor().newInstance(); + mustEqual(0, result.size()); assertFalse(result.iterator().hasNext()); return result; } - void populate(NavigableSet set, int limit, BitSet bs) { + void populate(NavigableSet set, int limit, BitSet bs) { for (int i = 0, n = 2 * limit / 3; i < n; i++) { int element = rnd.nextInt(limit); put(set, element, bs); } } - void mutateSet(NavigableSet set, int min, int max, BitSet bs) { + void mutateSet(NavigableSet set, int min, int max, BitSet bs) { int size = set.size(); int rangeSize = max - min + 1; @@ -769,9 +759,9 @@ void mutateSet(NavigableSet set, int min, int max, BitSet bs) { } // Remove a bunch of entries with iterator - for (Iterator it = set.iterator(); it.hasNext(); ) { + for (Iterator it = set.iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -784,7 +774,7 @@ void mutateSet(NavigableSet set, int min, int max, BitSet bs) { } } - void mutateSubSet(NavigableSet set, int min, int max, + void mutateSubSet(NavigableSet set, int min, int max, BitSet bs) { int size = set.size(); int rangeSize = max - min + 1; @@ -795,9 +785,9 @@ void mutateSubSet(NavigableSet set, int min, int max, } // Remove a bunch of entries with iterator - for (Iterator it = set.iterator(); it.hasNext(); ) { + for (Iterator it = set.iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -809,24 +799,24 @@ void mutateSubSet(NavigableSet set, int min, int max, put(set, element, bs); } else { try { - set.add(element); + set.add(itemFor(element)); shouldThrow(); } catch (IllegalArgumentException success) {} } } } - void put(NavigableSet set, int element, BitSet bs) { - if (set.add(element)) + void put(NavigableSet set, int element, BitSet bs) { + if (set.add(itemFor(element))) bs.set(element); } - void remove(NavigableSet set, int element, BitSet bs) { - if (set.remove(element)) + void remove(NavigableSet set, int element, BitSet bs) { + if (set.remove(itemFor(element))) bs.clear(element); } - void bashSubSet(NavigableSet set, + void bashSubSet(NavigableSet set, int min, int max, boolean ascending, BitSet bs) { check(set, min, max, ascending, bs); @@ -843,7 +833,7 @@ void bashSubSet(NavigableSet set, // headSet - pick direction and endpoint inclusion randomly boolean incl = rnd.nextBoolean(); - NavigableSet hm = set.headSet(midPoint, incl); + NavigableSet hm = set.headSet(itemFor(midPoint), incl); if (ascending) { if (rnd.nextBoolean()) bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true, bs); @@ -860,7 +850,7 @@ void bashSubSet(NavigableSet set, // tailSet - pick direction and endpoint inclusion randomly incl = rnd.nextBoolean(); - NavigableSet tm = set.tailSet(midPoint,incl); + NavigableSet tm = set.tailSet(itemFor(midPoint),incl); if (ascending) { if (rnd.nextBoolean()) bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true, bs); @@ -885,8 +875,8 @@ void bashSubSet(NavigableSet set, boolean lowIncl = rnd.nextBoolean(); boolean highIncl = rnd.nextBoolean(); if (ascending) { - NavigableSet sm = set.subSet( - endpoints[0], lowIncl, endpoints[1], highIncl); + NavigableSet sm = set.subSet( + itemFor(endpoints[0]), lowIncl, itemFor(endpoints[1]), highIncl); if (rnd.nextBoolean()) bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), true, bs); @@ -894,8 +884,8 @@ void bashSubSet(NavigableSet set, bashSubSet(sm.descendingSet(), endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false, bs); } else { - NavigableSet sm = set.subSet( - endpoints[1], highIncl, endpoints[0], lowIncl); + NavigableSet sm = set.subSet( + itemFor(endpoints[1]), highIncl, itemFor(endpoints[0]), lowIncl); if (rnd.nextBoolean()) bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false, bs); @@ -908,7 +898,7 @@ void bashSubSet(NavigableSet set, /** * min and max are both inclusive. If max < min, interval is empty. */ - void check(NavigableSet set, + void check(NavigableSet set, final int min, final int max, final boolean ascending, final BitSet bs) { class ReferenceSet { @@ -977,30 +967,31 @@ private int lastAscending() { int size = 0; for (int i = min; i <= max; i++) { boolean bsContainsI = bs.get(i); - assertEquals(bsContainsI, set.contains(i)); + mustEqual(bsContainsI, set.contains(itemFor(i))); if (bsContainsI) size++; } - assertEquals(size, set.size()); + mustEqual(size, set.size()); // Test contents using contains elementSet iterator int size2 = 0; int previousElement = -1; - for (int element : set) { - assertTrue(bs.get(element)); + for (Item element : set) { + assertTrue(bs.get(element.value)); size2++; assertTrue(previousElement < 0 || (ascending ? - element - previousElement > 0 : element - previousElement < 0)); - previousElement = element; + element.value - previousElement > 0 : element.value - previousElement < 0)); + previousElement = element.value; } - assertEquals(size2, size); + mustEqual(size2, size); // Test navigation ops for (int element = min - 1; element <= max + 1; element++) { - assertEq(set.lower(element), rs.lower(element)); - assertEq(set.floor(element), rs.floor(element)); - assertEq(set.higher(element), rs.higher(element)); - assertEq(set.ceiling(element), rs.ceiling(element)); + Item e = itemFor(element); + assertEq(set.lower(e), rs.lower(element)); + assertEq(set.floor(e), rs.floor(element)); + assertEq(set.higher(e), rs.higher(element)); + assertEq(set.ceiling(e), rs.ceiling(element)); } // Test extrema @@ -1008,8 +999,8 @@ private int lastAscending() { assertEq(set.first(), rs.first()); assertEq(set.last(), rs.last()); } else { - assertEq(rs.first(), -1); - assertEq(rs.last(), -1); + mustEqual(rs.first(), -1); + mustEqual(rs.last(), -1); try { set.first(); shouldThrow(); @@ -1021,15 +1012,15 @@ private int lastAscending() { } } - static void assertEq(Integer i, int j) { + static void assertEq(Item i, int j) { if (i == null) - assertEquals(j, -1); + mustEqual(j, -1); else - assertEquals((int) i, j); + mustEqual(i, j); } - static boolean eq(Integer i, int j) { - return (i == null) ? j == -1 : i == j; + static boolean eq(Item i, int j) { + return (i == null) ? j == -1 : i.value == j; } } diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java index e3f6c577cf2..59bfb2ef385 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java @@ -54,10 +54,10 @@ public static Test suite() { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static ConcurrentNavigableMap map5() { - ConcurrentSkipListMap map = new ConcurrentSkipListMap(); + private static ConcurrentNavigableMap map5() { + ConcurrentSkipListMapmap = new ConcurrentSkipListMap<>(); assertTrue(map.isEmpty()); map.put(zero, "Z"); map.put(one, "A"); @@ -67,34 +67,34 @@ private static ConcurrentNavigableMap map5() { map.put(four, "D"); map.put(seven, "F"); assertFalse(map.isEmpty()); - assertEquals(7, map.size()); + mustEqual(7, map.size()); return map.subMap(one, true, seven, false); } /** - * Returns a new map from Integers -5 to -1 to Strings "A"-"E". + * Returns a new map from Items -5 to -1 to Strings "A"-"E". */ - private static ConcurrentNavigableMap dmap5() { - ConcurrentSkipListMap map = new ConcurrentSkipListMap(); + private static ConcurrentNavigableMap dmap5() { + ConcurrentSkipListMapmap = new ConcurrentSkipListMap<>(); assertTrue(map.isEmpty()); - map.put(m1, "A"); - map.put(m5, "E"); - map.put(m3, "C"); - map.put(m2, "B"); - map.put(m4, "D"); + map.put(minusOne, "A"); + map.put(minusFive, "E"); + map.put(minusThree, "C"); + map.put(minusTwo, "B"); + map.put(minusFour, "D"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map.descendingMap(); } - private static ConcurrentNavigableMap map0() { - ConcurrentSkipListMap map = new ConcurrentSkipListMap(); + private static ConcurrentNavigableMap map0() { + ConcurrentSkipListMapmap = new ConcurrentSkipListMap<>(); assertTrue(map.isEmpty()); return map.tailMap(one, true); } - private static ConcurrentNavigableMap dmap0() { - ConcurrentSkipListMap map = new ConcurrentSkipListMap(); + private static ConcurrentNavigableMap dmap0() { + ConcurrentSkipListMapmap = new ConcurrentSkipListMap<>(); assertTrue(map.isEmpty()); return map; } @@ -103,19 +103,19 @@ private static ConcurrentNavigableMap dmap0() { * clear removes all pairs */ public void testClear() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * Maps with same contents are equal */ public void testEquals() { - ConcurrentNavigableMap map1 = map5(); - ConcurrentNavigableMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + ConcurrentNavigableMap map1 = map5(); + ConcurrentNavigableMap map2 = map5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -125,7 +125,7 @@ public void testEquals() { * containsKey returns true for contained key */ public void testContainsKey() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); } @@ -134,7 +134,7 @@ public void testContainsKey() { * containsValue returns true for held values */ public void testContainsValue() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -144,9 +144,9 @@ public void testContainsValue() { * or null if not present */ public void testGet() { - ConcurrentNavigableMap map = map5(); - assertEquals("A", (String)map.get(one)); - ConcurrentNavigableMap empty = map0(); + ConcurrentNavigableMap map = map5(); + mustEqual("A", map.get(one)); + ConcurrentNavigableMap empty = map0(); assertNull(empty.get(one)); } @@ -154,8 +154,8 @@ public void testGet() { * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { - ConcurrentNavigableMap empty = map0(); - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap empty = map0(); + ConcurrentNavigableMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -164,43 +164,43 @@ public void testIsEmpty() { * firstKey returns first key */ public void testFirstKey() { - ConcurrentNavigableMap map = map5(); - assertEquals(one, map.firstKey()); + ConcurrentNavigableMap map = map5(); + mustEqual(one, map.firstKey()); } /** * lastKey returns last key */ public void testLastKey() { - ConcurrentNavigableMap map = map5(); - assertEquals(five, map.lastKey()); + ConcurrentNavigableMap map = map5(); + mustEqual(five, map.lastKey()); } /** * keySet returns a Set containing all the keys */ public void testKeySet() { - ConcurrentNavigableMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); + ConcurrentNavigableMap map = map5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, one); + mustContain(s, two); + mustContain(s, three); + mustContain(s, four); + mustContain(s, five); } /** * keySet is ordered */ public void testKeySetOrder() { - ConcurrentNavigableMap map = map5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + ConcurrentNavigableMap map = map5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = i.next(); + mustEqual(last, one); while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = i.next(); assertTrue(last.compareTo(k) < 0); last = k; } @@ -210,9 +210,9 @@ public void testKeySetOrder() { * values collection contains all values */ public void testValues() { - ConcurrentNavigableMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); + ConcurrentNavigableMap map = map5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -224,12 +224,12 @@ public void testValues() { * keySet.toArray returns contains all keys */ public void testKeySetToArray() { - ConcurrentNavigableMap map = map5(); - Set s = map.keySet(); + ConcurrentNavigableMap map = map5(); + Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -237,12 +237,12 @@ public void testKeySetToArray() { * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { - ConcurrentNavigableMap map = map5(); - Set s = map.descendingKeySet(); - Object[] ar = s.toArray(); - assertEquals(5, ar.length); + ConcurrentNavigableMap map = map5(); + Set s = map.descendingKeySet(); + Item[] ar = s.toArray(new Item[0]); + mustEqual(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); - ar[0] = m10; + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -250,11 +250,11 @@ public void testDescendingKeySetToArray() { * Values.toArray contains all values */ public void testValuesToArray() { - ConcurrentNavigableMap map = map5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); + ConcurrentNavigableMap map = map5(); + Collection v = map.values(); + String[] ar = v.toArray(new String[0]); + ArrayList s = new ArrayList<>(Arrays.asList(ar)); + mustEqual(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -266,12 +266,12 @@ public void testValuesToArray() { * entrySet contains all pairs */ public void testEntrySet() { - ConcurrentNavigableMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + ConcurrentNavigableMap map = map5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -285,10 +285,10 @@ public void testEntrySet() { * putAll adds all key-value pairs from the given map */ public void testPutAll() { - ConcurrentNavigableMap empty = map0(); - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap empty = map0(); + ConcurrentNavigableMap map = map5(); empty.putAll(map); - assertEquals(5, empty.size()); + mustEqual(5, empty.size()); assertTrue(empty.containsKey(one)); assertTrue(empty.containsKey(two)); assertTrue(empty.containsKey(three)); @@ -300,7 +300,7 @@ public void testPutAll() { * putIfAbsent works when the given key is not present */ public void testPutIfAbsent() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); map.putIfAbsent(six, "Z"); assertTrue(map.containsKey(six)); } @@ -309,15 +309,15 @@ public void testPutIfAbsent() { * putIfAbsent does not add the pair if the key is already present */ public void testPutIfAbsent2() { - ConcurrentNavigableMap map = map5(); - assertEquals("A", map.putIfAbsent(one, "Z")); + ConcurrentNavigableMap map = map5(); + mustEqual("A", map.putIfAbsent(one, "Z")); } /** * replace fails when the given key is not present */ public void testReplace() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); assertNull(map.replace(six, "Z")); assertFalse(map.containsKey(six)); } @@ -326,38 +326,38 @@ public void testReplace() { * replace succeeds if the key is already present */ public void testReplace2() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); assertNotNull(map.replace(one, "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * replace value fails when the given key not mapped to expected value */ public void testReplaceValue() { - ConcurrentNavigableMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentNavigableMap map = map5(); + mustEqual("A", map.get(one)); assertFalse(map.replace(one, "Z", "Z")); - assertEquals("A", map.get(one)); + mustEqual("A", map.get(one)); } /** * replace value succeeds when the given key mapped to expected value */ public void testReplaceValue2() { - ConcurrentNavigableMap map = map5(); - assertEquals("A", map.get(one)); + ConcurrentNavigableMap map = map5(); + mustEqual("A", map.get(one)); assertTrue(map.replace(one, "A", "Z")); - assertEquals("Z", map.get(one)); + mustEqual("Z", map.get(one)); } /** * remove removes the correct key-value pair from the map */ public void testRemove() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); map.remove(five); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); } @@ -365,14 +365,14 @@ public void testRemove() { * remove(key,value) removes only if pair present */ public void testRemove2() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); assertTrue(map.containsKey(five)); - assertEquals("E", map.get(five)); + mustEqual("E", map.get(five)); map.remove(five, "E"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); map.remove(four, "A"); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertTrue(map.containsKey(four)); } @@ -380,17 +380,17 @@ public void testRemove2() { * lowerEntry returns preceding entry. */ public void testLowerEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e1 = map.lowerEntry(three); - assertEquals(two, e1.getKey()); + ConcurrentNavigableMap map = map5(); + Map.Entry e1 = map.lowerEntry(three); + mustEqual(two, e1.getKey()); - Map.Entry e2 = map.lowerEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.lowerEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.lowerEntry(one); + Map.Entry e3 = map.lowerEntry(one); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -398,17 +398,17 @@ public void testLowerEntry() { * higherEntry returns next entry. */ public void testHigherEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e1 = map.higherEntry(three); - assertEquals(four, e1.getKey()); + ConcurrentNavigableMap map = map5(); + Map.Entry e1 = map.higherEntry(three); + mustEqual(four, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.higherEntry(five); + Map.Entry e3 = map.higherEntry(five); assertNull(e3); - Map.Entry e4 = map.higherEntry(six); + Map.Entry e4 = map.higherEntry(six); assertNull(e4); } @@ -416,17 +416,17 @@ public void testHigherEntry() { * floorEntry returns preceding entry. */ public void testFloorEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e1 = map.floorEntry(three); - assertEquals(three, e1.getKey()); + ConcurrentNavigableMap map = map5(); + Map.Entry e1 = map.floorEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.floorEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.floorEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.floorEntry(one); - assertEquals(one, e3.getKey()); + Map.Entry e3 = map.floorEntry(one); + mustEqual(one, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -434,17 +434,17 @@ public void testFloorEntry() { * ceilingEntry returns next entry. */ public void testCeilingEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e1 = map.ceilingEntry(three); - assertEquals(three, e1.getKey()); + ConcurrentNavigableMap map = map5(); + Map.Entry e1 = map.ceilingEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(five); - assertEquals(five, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(five); + mustEqual(five, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(six); + Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); } @@ -452,21 +452,21 @@ public void testCeilingEntry() { * pollFirstEntry returns entries in order */ public void testPollFirstEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + ConcurrentNavigableMap map = map5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(two, e.getKey()); + mustEqual(two, e.getKey()); map.put(one, "A"); e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(four); e = map.pollFirstEntry(); - assertEquals(five, e.getKey()); + mustEqual(five, e.getKey()); try { e.setValue("A"); shouldThrow(); @@ -479,21 +479,21 @@ public void testPollFirstEntry() { * pollLastEntry returns entries in order */ public void testPollLastEntry() { - ConcurrentNavigableMap map = map5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + ConcurrentNavigableMap map = map5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(four, e.getKey()); + mustEqual(four, e.getKey()); map.put(five, "E"); e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(two); e = map.pollLastEntry(); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -506,17 +506,17 @@ public void testPollLastEntry() { * size returns the correct values */ public void testSize() { - ConcurrentNavigableMap map = map5(); - ConcurrentNavigableMap empty = map0(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap empty = map0(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testToString() { - ConcurrentNavigableMap map = map5(); + ConcurrentNavigableMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -530,7 +530,7 @@ public void testToString() { */ public void testGet_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.get(null); shouldThrow(); } catch (NullPointerException success) {} @@ -541,7 +541,7 @@ public void testGet_NullPointerException() { */ public void testContainsKey_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.containsKey(null); shouldThrow(); } catch (NullPointerException success) {} @@ -552,7 +552,7 @@ public void testContainsKey_NullPointerException() { */ public void testContainsValue_NullPointerException() { try { - ConcurrentNavigableMap c = map0(); + ConcurrentNavigableMap c = map0(); c.containsValue(null); shouldThrow(); } catch (NullPointerException success) {} @@ -563,7 +563,7 @@ public void testContainsValue_NullPointerException() { */ public void testPut1_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.put(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -574,7 +574,7 @@ public void testPut1_NullPointerException() { */ public void testPutIfAbsent1_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.putIfAbsent(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -585,8 +585,8 @@ public void testPutIfAbsent1_NullPointerException() { */ public void testReplace_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); - c.replace(null, "whatever"); + ConcurrentNavigableMap c = map5(); + c.replace(null, "A"); shouldThrow(); } catch (NullPointerException success) {} } @@ -596,8 +596,8 @@ public void testReplace_NullPointerException() { */ public void testReplaceValue_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); - c.replace(null, one, "whatever"); + ConcurrentNavigableMap c = map5(); + c.replace(null, "A", "B"); shouldThrow(); } catch (NullPointerException success) {} } @@ -607,7 +607,7 @@ public void testReplaceValue_NullPointerException() { */ public void testRemove1_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.remove(null); shouldThrow(); } catch (NullPointerException success) {} @@ -618,7 +618,7 @@ public void testRemove1_NullPointerException() { */ public void testRemove2_NullPointerException() { try { - ConcurrentNavigableMap c = map5(); + ConcurrentNavigableMap c = map5(); c.remove(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -628,168 +628,167 @@ public void testRemove2_NullPointerException() { * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { - NavigableMap x = map5(); - NavigableMap y = serialClone(x); + NavigableMap x = map5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); } /** * subMap returns map with keys in requested range */ public void testSubMapContents() { - ConcurrentNavigableMap map = map5(); - SortedMap sm = map.subMap(two, four); - assertEquals(two, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals(2, sm.size()); + ConcurrentNavigableMap map = map5(); + SortedMap sm = map.subMap(two, four); + mustEqual(two, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual(2, sm.size()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals("C", sm.remove(three)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual("C", sm.remove(three)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testSubMapContents2() { - ConcurrentNavigableMap map = map5(); - SortedMap sm = map.subMap(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.firstKey()); - assertEquals(two, sm.lastKey()); + ConcurrentNavigableMap map = map5(); + SortedMap sm = map.subMap(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.firstKey()); + mustEqual(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); - assertEquals(4, map.size()); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testHeadMapContents() { - ConcurrentNavigableMap map = map5(); - SortedMap sm = map.headMap(four); + ConcurrentNavigableMap map = map5(); + SortedMap sm = map.headMap(four); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); + Iterator i = sm.keySet().iterator(); Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + k = (Item)(i.next()); + mustEqual(one, k); + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(four, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(four, map.firstKey()); } /** * headMap returns map with keys in requested range */ public void testTailMapContents() { - ConcurrentNavigableMap map = map5(); - SortedMap sm = map.tailMap(two); + ConcurrentNavigableMap map = map5(); + SortedMap sm = map.tailMap(two); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertTrue(sm.containsKey(four)); assertTrue(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + Iterator i = sm.keySet().iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(two, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(three, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(four, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = (ei.next()); + mustEqual(two, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(three, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(four, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - SortedMap ssm = sm.tailMap(four); - assertEquals(four, ssm.firstKey()); - assertEquals(five, ssm.lastKey()); - assertEquals("D", ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + SortedMap ssm = sm.tailMap(four); + mustEqual(four, ssm.firstKey()); + mustEqual(five, ssm.lastKey()); + mustEqual("D", ssm.remove(four)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } /** * clear removes all pairs */ public void testDescendingClear() { - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap map = dmap5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * Maps with same contents are equal */ public void testDescendingEquals() { - ConcurrentNavigableMap map1 = dmap5(); - ConcurrentNavigableMap map2 = dmap5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + ConcurrentNavigableMap map1 = dmap5(); + ConcurrentNavigableMap map2 = dmap5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -799,8 +798,8 @@ public void testDescendingEquals() { * containsKey returns true for contained key */ public void testDescendingContainsKey() { - ConcurrentNavigableMap map = dmap5(); - assertTrue(map.containsKey(m1)); + ConcurrentNavigableMap map = dmap5(); + assertTrue(map.containsKey(minusOne)); assertFalse(map.containsKey(zero)); } @@ -808,7 +807,7 @@ public void testDescendingContainsKey() { * containsValue returns true for held values */ public void testDescendingContainsValue() { - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap map = dmap5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -818,18 +817,18 @@ public void testDescendingContainsValue() { * or null if not present */ public void testDescendingGet() { - ConcurrentNavigableMap map = dmap5(); - assertEquals("A", (String)map.get(m1)); - ConcurrentNavigableMap empty = dmap0(); - assertNull(empty.get(m1)); + ConcurrentNavigableMap map = dmap5(); + mustEqual("A", map.get(minusOne)); + ConcurrentNavigableMap empty = dmap0(); + assertNull(empty.get(minusOne)); } /** * isEmpty is true of empty map and false for non-empty */ public void testDescendingIsEmpty() { - ConcurrentNavigableMap empty = dmap0(); - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap empty = dmap0(); + ConcurrentNavigableMap map = dmap5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -838,43 +837,43 @@ public void testDescendingIsEmpty() { * firstKey returns first key */ public void testDescendingFirstKey() { - ConcurrentNavigableMap map = dmap5(); - assertEquals(m1, map.firstKey()); + ConcurrentNavigableMap map = dmap5(); + mustEqual(minusOne, map.firstKey()); } /** * lastKey returns last key */ public void testDescendingLastKey() { - ConcurrentNavigableMap map = dmap5(); - assertEquals(m5, map.lastKey()); + ConcurrentNavigableMap map = dmap5(); + mustEqual(minusFive, map.lastKey()); } /** * keySet returns a Set containing all the keys */ public void testDescendingKeySet() { - ConcurrentNavigableMap map = dmap5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(m1)); - assertTrue(s.contains(m2)); - assertTrue(s.contains(m3)); - assertTrue(s.contains(m4)); - assertTrue(s.contains(m5)); + ConcurrentNavigableMap map = dmap5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, minusOne); + mustContain(s, minusTwo); + mustContain(s, minusThree); + mustContain(s, minusFour); + mustContain(s, minusFive); } /** * keySet is ordered */ public void testDescendingKeySetOrder() { - ConcurrentNavigableMap map = dmap5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, m1); + ConcurrentNavigableMap map = dmap5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = i.next(); + mustEqual(last, minusOne); while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = i.next(); assertTrue(last.compareTo(k) > 0); last = k; } @@ -884,9 +883,9 @@ public void testDescendingKeySetOrder() { * values collection contains all values */ public void testDescendingValues() { - ConcurrentNavigableMap map = dmap5(); - Collection s = map.values(); - assertEquals(5, s.size()); + ConcurrentNavigableMap map = dmap5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -898,12 +897,12 @@ public void testDescendingValues() { * keySet.toArray returns contains all keys */ public void testDescendingAscendingKeySetToArray() { - ConcurrentNavigableMap map = dmap5(); - Set s = map.keySet(); - Object[] ar = s.toArray(); + ConcurrentNavigableMap map = dmap5(); + Set s = map.keySet(); + Item[] ar = s.toArray(new Item[0]); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -911,12 +910,12 @@ public void testDescendingAscendingKeySetToArray() { * descendingkeySet.toArray returns contains all keys */ public void testDescendingDescendingKeySetToArray() { - ConcurrentNavigableMap map = dmap5(); - Set s = map.descendingKeySet(); - Object[] ar = s.toArray(); - assertEquals(5, ar.length); + ConcurrentNavigableMap map = dmap5(); + Set s = map.descendingKeySet(); + Item[] ar = s.toArray(new Item[0]); + mustEqual(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); - ar[0] = m10; + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -924,11 +923,11 @@ public void testDescendingDescendingKeySetToArray() { * Values.toArray contains all values */ public void testDescendingValuesToArray() { - ConcurrentNavigableMap map = dmap5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); + ConcurrentNavigableMap map = dmap5(); + Collection v = map.values(); + String[] ar = v.toArray(new String[0]); + ArrayList s = new ArrayList<>(Arrays.asList(ar)); + mustEqual(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -940,18 +939,18 @@ public void testDescendingValuesToArray() { * entrySet contains all pairs */ public void testDescendingEntrySet() { - ConcurrentNavigableMap map = dmap5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + ConcurrentNavigableMap map = dmap5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( - (e.getKey().equals(m1) && e.getValue().equals("A")) || - (e.getKey().equals(m2) && e.getValue().equals("B")) || - (e.getKey().equals(m3) && e.getValue().equals("C")) || - (e.getKey().equals(m4) && e.getValue().equals("D")) || - (e.getKey().equals(m5) && e.getValue().equals("E"))); + (e.getKey().equals(minusOne) && e.getValue().equals("A")) || + (e.getKey().equals(minusTwo) && e.getValue().equals("B")) || + (e.getKey().equals(minusThree) && e.getValue().equals("C")) || + (e.getKey().equals(minusFour) && e.getValue().equals("D")) || + (e.getKey().equals(minusFive) && e.getValue().equals("E"))); } } @@ -959,22 +958,22 @@ public void testDescendingEntrySet() { * putAll adds all key-value pairs from the given map */ public void testDescendingPutAll() { - ConcurrentNavigableMap empty = dmap0(); - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap empty = dmap0(); + ConcurrentNavigableMap map = dmap5(); empty.putAll(map); - assertEquals(5, empty.size()); - assertTrue(empty.containsKey(m1)); - assertTrue(empty.containsKey(m2)); - assertTrue(empty.containsKey(m3)); - assertTrue(empty.containsKey(m4)); - assertTrue(empty.containsKey(m5)); + mustEqual(5, empty.size()); + assertTrue(empty.containsKey(minusOne)); + assertTrue(empty.containsKey(minusTwo)); + assertTrue(empty.containsKey(minusThree)); + assertTrue(empty.containsKey(minusFour)); + assertTrue(empty.containsKey(minusFive)); } /** * putIfAbsent works when the given key is not present */ public void testDescendingPutIfAbsent() { - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap map = dmap5(); map.putIfAbsent(six, "Z"); assertTrue(map.containsKey(six)); } @@ -983,15 +982,15 @@ public void testDescendingPutIfAbsent() { * putIfAbsent does not add the pair if the key is already present */ public void testDescendingPutIfAbsent2() { - ConcurrentNavigableMap map = dmap5(); - assertEquals("A", map.putIfAbsent(m1, "Z")); + ConcurrentNavigableMap map = dmap5(); + mustEqual("A", map.putIfAbsent(minusOne, "Z")); } /** * replace fails when the given key is not present */ public void testDescendingReplace() { - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap map = dmap5(); assertNull(map.replace(six, "Z")); assertFalse(map.containsKey(six)); } @@ -1000,71 +999,71 @@ public void testDescendingReplace() { * replace succeeds if the key is already present */ public void testDescendingReplace2() { - ConcurrentNavigableMap map = dmap5(); - assertNotNull(map.replace(m1, "Z")); - assertEquals("Z", map.get(m1)); + ConcurrentNavigableMap map = dmap5(); + assertNotNull(map.replace(minusOne, "Z")); + mustEqual("Z", map.get(minusOne)); } /** * replace value fails when the given key not mapped to expected value */ public void testDescendingReplaceValue() { - ConcurrentNavigableMap map = dmap5(); - assertEquals("A", map.get(m1)); - assertFalse(map.replace(m1, "Z", "Z")); - assertEquals("A", map.get(m1)); + ConcurrentNavigableMap map = dmap5(); + mustEqual("A", map.get(minusOne)); + assertFalse(map.replace(minusOne, "Z", "Z")); + mustEqual("A", map.get(minusOne)); } /** * replace value succeeds when the given key mapped to expected value */ public void testDescendingReplaceValue2() { - ConcurrentNavigableMap map = dmap5(); - assertEquals("A", map.get(m1)); - assertTrue(map.replace(m1, "A", "Z")); - assertEquals("Z", map.get(m1)); + ConcurrentNavigableMap map = dmap5(); + mustEqual("A", map.get(minusOne)); + assertTrue(map.replace(minusOne, "A", "Z")); + mustEqual("Z", map.get(minusOne)); } /** * remove removes the correct key-value pair from the map */ public void testDescendingRemove() { - ConcurrentNavigableMap map = dmap5(); - map.remove(m5); - assertEquals(4, map.size()); - assertFalse(map.containsKey(m5)); + ConcurrentNavigableMap map = dmap5(); + map.remove(minusFive); + mustEqual(4, map.size()); + assertFalse(map.containsKey(minusFive)); } /** * remove(key,value) removes only if pair present */ public void testDescendingRemove2() { - ConcurrentNavigableMap map = dmap5(); - assertTrue(map.containsKey(m5)); - assertEquals("E", map.get(m5)); - map.remove(m5, "E"); - assertEquals(4, map.size()); - assertFalse(map.containsKey(m5)); - map.remove(m4, "A"); - assertEquals(4, map.size()); - assertTrue(map.containsKey(m4)); + ConcurrentNavigableMap map = dmap5(); + assertTrue(map.containsKey(minusFive)); + mustEqual("E", map.get(minusFive)); + map.remove(minusFive, "E"); + mustEqual(4, map.size()); + assertFalse(map.containsKey(minusFive)); + map.remove(minusFour, "A"); + mustEqual(4, map.size()); + assertTrue(map.containsKey(minusFour)); } /** * lowerEntry returns preceding entry. */ public void testDescendingLowerEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e1 = map.lowerEntry(m3); - assertEquals(m2, e1.getKey()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e1 = map.lowerEntry(minusThree); + mustEqual(minusTwo, e1.getKey()); - Map.Entry e2 = map.lowerEntry(m6); - assertEquals(m5, e2.getKey()); + Map.Entry e2 = map.lowerEntry(minusSix); + mustEqual(minusFive, e2.getKey()); - Map.Entry e3 = map.lowerEntry(m1); + Map.Entry e3 = map.lowerEntry(minusOne); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -1072,17 +1071,17 @@ public void testDescendingLowerEntry() { * higherEntry returns next entry. */ public void testDescendingHigherEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e1 = map.higherEntry(m3); - assertEquals(m4, e1.getKey()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e1 = map.higherEntry(minusThree); + mustEqual(minusFour, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(m1, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(minusOne, e2.getKey()); - Map.Entry e3 = map.higherEntry(m5); + Map.Entry e3 = map.higherEntry(minusFive); assertNull(e3); - Map.Entry e4 = map.higherEntry(m6); + Map.Entry e4 = map.higherEntry(minusSix); assertNull(e4); } @@ -1090,17 +1089,17 @@ public void testDescendingHigherEntry() { * floorEntry returns preceding entry. */ public void testDescendingFloorEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e1 = map.floorEntry(m3); - assertEquals(m3, e1.getKey()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e1 = map.floorEntry(minusThree); + mustEqual(minusThree, e1.getKey()); - Map.Entry e2 = map.floorEntry(m6); - assertEquals(m5, e2.getKey()); + Map.Entry e2 = map.floorEntry(minusSix); + mustEqual(minusFive, e2.getKey()); - Map.Entry e3 = map.floorEntry(m1); - assertEquals(m1, e3.getKey()); + Map.Entry e3 = map.floorEntry(minusOne); + mustEqual(minusOne, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -1108,17 +1107,17 @@ public void testDescendingFloorEntry() { * ceilingEntry returns next entry. */ public void testDescendingCeilingEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e1 = map.ceilingEntry(m3); - assertEquals(m3, e1.getKey()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e1 = map.ceilingEntry(minusThree); + mustEqual(minusThree, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(m1, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(minusOne, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(m5); - assertEquals(m5, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(minusFive); + mustEqual(minusFive, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(m6); + Map.Entry e4 = map.ceilingEntry(minusSix); assertNull(e4); } @@ -1126,21 +1125,21 @@ public void testDescendingCeilingEntry() { * pollFirstEntry returns entries in order */ public void testDescendingPollFirstEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(m1, e.getKey()); - assertEquals("A", e.getValue()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(minusOne, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(m2, e.getKey()); - map.put(m1, "A"); + mustEqual(minusTwo, e.getKey()); + map.put(minusOne, "A"); e = map.pollFirstEntry(); - assertEquals(m1, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(minusOne, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(m3, e.getKey()); - map.remove(m4); + mustEqual(minusThree, e.getKey()); + map.remove(minusFour); e = map.pollFirstEntry(); - assertEquals(m5, e.getKey()); + mustEqual(minusFive, e.getKey()); try { e.setValue("A"); shouldThrow(); @@ -1153,21 +1152,21 @@ public void testDescendingPollFirstEntry() { * pollLastEntry returns entries in order */ public void testDescendingPollLastEntry() { - ConcurrentNavigableMap map = dmap5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + ConcurrentNavigableMap map = dmap5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(m4, e.getKey()); - map.put(m5, "E"); + mustEqual(minusFour, e.getKey()); + map.put(minusFive, "E"); e = map.pollLastEntry(); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(m3, e.getKey()); - map.remove(m2); + mustEqual(minusThree, e.getKey()); + map.remove(minusTwo); e = map.pollLastEntry(); - assertEquals(m1, e.getKey()); + mustEqual(minusOne, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -1180,17 +1179,17 @@ public void testDescendingPollLastEntry() { * size returns the correct values */ public void testDescendingSize() { - ConcurrentNavigableMap map = dmap5(); - ConcurrentNavigableMap empty = dmap0(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap empty = dmap0(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testDescendingToString() { - ConcurrentNavigableMap map = dmap5(); + ConcurrentNavigableMap map = dmap5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -1204,7 +1203,7 @@ public void testDescendingToString() { */ public void testDescendingGet_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.get(null); shouldThrow(); } catch (NullPointerException success) {} @@ -1215,7 +1214,7 @@ public void testDescendingGet_NullPointerException() { */ public void testDescendingContainsKey_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.containsKey(null); shouldThrow(); } catch (NullPointerException success) {} @@ -1226,7 +1225,7 @@ public void testDescendingContainsKey_NullPointerException() { */ public void testDescendingContainsValue_NullPointerException() { try { - ConcurrentNavigableMap c = dmap0(); + ConcurrentNavigableMap c = dmap0(); c.containsValue(null); shouldThrow(); } catch (NullPointerException success) {} @@ -1237,7 +1236,7 @@ public void testDescendingContainsValue_NullPointerException() { */ public void testDescendingPut1_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.put(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -1248,7 +1247,7 @@ public void testDescendingPut1_NullPointerException() { */ public void testDescendingPutIfAbsent1_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.putIfAbsent(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -1259,7 +1258,7 @@ public void testDescendingPutIfAbsent1_NullPointerException() { */ public void testDescendingReplace_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.replace(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -1270,8 +1269,8 @@ public void testDescendingReplace_NullPointerException() { */ public void testDescendingReplaceValue_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); - c.replace(null, m1, "whatever"); + ConcurrentNavigableMap c = dmap5(); + c.replace(null, "A", "B"); shouldThrow(); } catch (NullPointerException success) {} } @@ -1281,7 +1280,7 @@ public void testDescendingReplaceValue_NullPointerException() { */ public void testDescendingRemove1_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.remove(null); shouldThrow(); } catch (NullPointerException success) {} @@ -1292,7 +1291,7 @@ public void testDescendingRemove1_NullPointerException() { */ public void testDescendingRemove2_NullPointerException() { try { - ConcurrentNavigableMap c = dmap5(); + ConcurrentNavigableMap c = dmap5(); c.remove(null, "whatever"); shouldThrow(); } catch (NullPointerException success) {} @@ -1302,149 +1301,148 @@ public void testDescendingRemove2_NullPointerException() { * A deserialized/reserialized map equals original */ public void testDescendingSerialization() throws Exception { - NavigableMap x = dmap5(); - NavigableMap y = serialClone(x); + NavigableMap x = dmap5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); } /** * subMap returns map with keys in requested range */ public void testDescendingSubMapContents() { - ConcurrentNavigableMap map = dmap5(); - SortedMap sm = map.subMap(m2, m4); - assertEquals(m2, sm.firstKey()); - assertEquals(m3, sm.lastKey()); - assertEquals(2, sm.size()); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + ConcurrentNavigableMap map = dmap5(); + SortedMap sm = map.subMap(minusTwo, minusFour); + mustEqual(minusTwo, sm.firstKey()); + mustEqual(minusThree, sm.lastKey()); + mustEqual(2, sm.size()); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusTwo, k); + k = (Item)(i.next()); + mustEqual(minusThree, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); - assertFalse(map.containsKey(m2)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(m3, sm.firstKey()); - assertEquals(m3, sm.lastKey()); - assertEquals("C", sm.remove(m3)); + assertFalse(map.containsKey(minusTwo)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(minusThree, sm.firstKey()); + mustEqual(minusThree, sm.lastKey()); + mustEqual("C", sm.remove(minusThree)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testDescendingSubMapContents2() { - ConcurrentNavigableMap map = dmap5(); - SortedMap sm = map.subMap(m2, m3); - assertEquals(1, sm.size()); - assertEquals(m2, sm.firstKey()); - assertEquals(m2, sm.lastKey()); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertFalse(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); + ConcurrentNavigableMap map = dmap5(); + SortedMap sm = map.subMap(minusTwo, minusThree); + mustEqual(1, sm.size()); + mustEqual(minusTwo, sm.firstKey()); + mustEqual(minusTwo, sm.lastKey()); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertFalse(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusTwo, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); - assertFalse(map.containsKey(m2)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + assertFalse(map.containsKey(minusTwo)); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertSame(sm.remove(m3), null); - assertEquals(4, map.size()); + assertSame(sm.remove(minusThree), null); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testDescendingHeadMapContents() { - ConcurrentNavigableMap map = dmap5(); - SortedMap sm = map.headMap(m4); - assertTrue(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m1, k); - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + ConcurrentNavigableMap map = dmap5(); + SortedMap sm = map.headMap(minusFour); + assertTrue(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusOne, k); + k = (Item)(i.next()); + mustEqual(minusTwo, k); + k = (Item)(i.next()); + mustEqual(minusThree, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(m4, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(minusFour, map.firstKey()); } /** * headMap returns map with keys in requested range */ public void testDescendingTailMapContents() { - ConcurrentNavigableMap map = dmap5(); - SortedMap sm = map.tailMap(m2); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertTrue(sm.containsKey(m4)); - assertTrue(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); - k = (Integer)(i.next()); - assertEquals(m4, k); - k = (Integer)(i.next()); - assertEquals(m5, k); + ConcurrentNavigableMap map = dmap5(); + SortedMap sm = map.tailMap(minusTwo); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertTrue(sm.containsKey(minusFour)); + assertTrue(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); + k = (i.next()); + mustEqual(minusThree, k); + k = (i.next()); + mustEqual(minusFour, k); + k = (i.next()); + mustEqual(minusFive, k); assertFalse(i.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(m2, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m3, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m4, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = (ei.next()); + mustEqual(minusTwo, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(minusThree, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(minusFour, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - SortedMap ssm = sm.tailMap(m4); - assertEquals(m4, ssm.firstKey()); - assertEquals(m5, ssm.lastKey()); - assertEquals("D", ssm.remove(m4)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + SortedMap ssm = sm.tailMap(minusFour); + mustEqual(minusFour, ssm.firstKey()); + mustEqual(minusFive, ssm.lastKey()); + mustEqual("D", ssm.remove(minusFour)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } } diff --git a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java index 6df5830333d..e49f6f9a696 100644 --- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java +++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java @@ -50,6 +50,7 @@ public static Test suite() { } static class MyReverseComparator implements Comparator { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -57,29 +58,29 @@ public int compare(Object x, Object y) { /** * Returns a new set of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static NavigableSet populatedSet(int n) { - ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); + private static NavigableSet populatedSet(int n) { + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.add(new Integer(i))); - assertTrue(q.add(new Integer(-n))); - assertTrue(q.add(new Integer(n))); - NavigableSet s = q.subSet(new Integer(0), true, new Integer(n), false); + mustAdd(q, i); + mustAdd(q, -n); + mustAdd(q, n); + NavigableSet s = q.subSet(itemFor(0), true, itemFor(n), false); assertFalse(s.isEmpty()); - assertEquals(n, s.size()); + mustEqual(n, s.size()); return s; } /** * Returns a new set of first 5 ints. */ - private static NavigableSet set5() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + private static NavigableSet set5() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); q.add(one); q.add(two); @@ -88,35 +89,35 @@ private static NavigableSet set5() { q.add(five); q.add(zero); q.add(seven); - NavigableSet s = q.subSet(one, true, seven, false); - assertEquals(5, s.size()); + NavigableSet s = q.subSet(one, true, seven, false); + mustEqual(5, s.size()); return s; } /** * Returns a new set of first 5 negative ints. */ - private static NavigableSet dset5() { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + private static NavigableSet dset5() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet<>(); assertTrue(q.isEmpty()); - q.add(m1); - q.add(m2); - q.add(m3); - q.add(m4); - q.add(m5); - NavigableSet s = q.descendingSet(); - assertEquals(5, s.size()); + q.add(minusOne); + q.add(minusTwo); + q.add(minusThree); + q.add(minusFour); + q.add(minusFive); + NavigableSet s = q.descendingSet(); + mustEqual(5, s.size()); return s; } - private static NavigableSet set0() { - ConcurrentSkipListSet set = new ConcurrentSkipListSet(); + private static NavigableSet set0() { + ConcurrentSkipListSet set = new ConcurrentSkipListSet<>(); assertTrue(set.isEmpty()); - return set.tailSet(m1, true); + return set.tailSet(minusOne, true); } - private static NavigableSet dset0() { - ConcurrentSkipListSet set = new ConcurrentSkipListSet(); + private static NavigableSet dset0() { + ConcurrentSkipListSet set = new ConcurrentSkipListSet<>(); assertTrue(set.isEmpty()); return set; } @@ -125,18 +126,18 @@ private static NavigableSet dset0() { * A new set has unbounded capacity */ public void testConstructor1() { - assertEquals(0, set0().size()); + mustEqual(0, set0().size()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + mustAdd(q, one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + mustAdd(q, two); q.pollFirst(); q.pollFirst(); assertTrue(q.isEmpty()); @@ -146,14 +147,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -161,7 +162,7 @@ public void testSize() { * add(null) throws NPE */ public void testAddNull() { - NavigableSet q = set0(); + NavigableSet q = set0(); try { q.add(null); shouldThrow(); @@ -172,7 +173,7 @@ public void testAddNull() { * Add of comparable element succeeds */ public void testAdd() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.add(six)); } @@ -180,7 +181,7 @@ public void testAdd() { * Add of duplicate element fails */ public void testAddDup() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.add(six)); assertFalse(q.add(six)); } @@ -189,7 +190,8 @@ public void testAddDup() { * Add of non-Comparable throws CCE */ public void testAddNonComparable() { - NavigableSet q = set0(); + ConcurrentSkipListSet src = new ConcurrentSkipListSet<>(); + NavigableSet q = src.tailSet(minusOne, true); try { q.add(new Object()); q.add(new Object()); @@ -201,7 +203,7 @@ public void testAddNonComparable() { * addAll(null) throws NPE */ public void testAddAll1() { - NavigableSet q = set0(); + NavigableSet q = set0(); try { q.addAll(null); shouldThrow(); @@ -212,10 +214,10 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - NavigableSet q = set0(); - Integer[] ints = new Integer[SIZE]; + NavigableSet q = set0(); + Item[] items = new Item[SIZE]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -225,12 +227,10 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - NavigableSet q = set0(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i + SIZE); + NavigableSet q = set0(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -239,24 +239,24 @@ public void testAddAll3() { * Set contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; + Item[] empty = new Item[0]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - NavigableSet q = set0(); + items[i] = itemFor(SIZE - 1 - i); + NavigableSet q = set0(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * poll succeeds unless empty */ public void testPoll() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -265,19 +265,19 @@ public void testPoll() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -286,11 +286,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -298,11 +298,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -312,12 +312,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = set0(); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = set0(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -326,8 +326,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -336,7 +336,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -346,13 +346,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(i); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -361,12 +360,12 @@ public void testRemoveAll() { * lower returns preceding element */ public void testLower() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.lower(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lower(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lower(one); assertNull(e3); @@ -379,12 +378,12 @@ public void testLower() { * higher returns next element */ public void testHigher() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.higher(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higher(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higher(five); assertNull(e3); @@ -397,15 +396,15 @@ public void testHigher() { * floor returns preceding element */ public void testFloor() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.floor(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floor(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floor(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -415,15 +414,15 @@ public void testFloor() { * ceiling returns next element */ public void testCeiling() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.ceiling(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceiling(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceiling(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceiling(six); assertNull(e4); @@ -433,7 +432,7 @@ public void testCeiling() { * toArray contains all elements in sorted order */ public void testToArray() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -445,11 +444,11 @@ public void testToArray() { * toArray(a) contains all elements in sorted order */ public void testToArray2() { - NavigableSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + NavigableSet q = populatedSet(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.pollFirst()); assertTrue(q.isEmpty()); } @@ -458,12 +457,12 @@ public void testToArray2() { * iterator iterates through all elements */ public void testIterator() { - NavigableSet q = populatedSet(SIZE); - Iterator it = q.iterator(); + NavigableSet q = populatedSet(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -478,18 +477,17 @@ public void testEmptyIterator() { * iterator.remove removes current element */ public void testIteratorRemove() { - final NavigableSet q = set0(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); - - Iterator it = q.iterator(); + final NavigableSet q = set0(); + mustAdd(q, two); + mustAdd(q, one); + mustAdd(q, three); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -497,7 +495,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -508,16 +506,16 @@ public void testToString() { * A deserialized/reserialized set equals original */ public void testSerialization() throws Exception { - NavigableSet x = populatedSet(SIZE); - NavigableSet y = serialClone(x); + NavigableSet x = populatedSet(SIZE); + NavigableSet y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -526,133 +524,134 @@ public void testSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testSubSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.subSet(two, four); - assertEquals(two, sm.first()); - assertEquals(three, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + NavigableSet set = set5(); + SortedSet sm = set.subSet(two, four); + mustEqual(two, sm.first()); + mustEqual(three, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.first()); - assertEquals(three, sm.last()); - assertTrue(sm.remove(three)); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.first()); + mustEqual(three, sm.last()); + mustRemove(sm, three); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testSubSetContents2() { - NavigableSet set = set5(); - SortedSet sm = set.subSet(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.first()); - assertEquals(two, sm.last()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertFalse(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + NavigableSet set = set5(); + SortedSet sm = set.subSet(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.first()); + mustEqual(two, sm.last()); + mustNotContain(sm, one); + mustContain(sm, two); + mustNotContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); assertFalse(sm.remove(three)); - assertEquals(4, set.size()); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testHeadSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.headSet(four); - assertTrue(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + NavigableSet set = set5(); + SortedSet sm = set.headSet(four); + mustContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(one, k); + k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(four, set.first()); + mustEqual(2, set.size()); + mustEqual(four, set.first()); } /** * tailSet returns set with keys in requested range */ public void testTailSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.tailSet(two); + NavigableSet set = set5(); + SortedSet sm = set.tailSet(two); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustContain(sm, four); + mustContain(sm, five); assertFalse(sm.contains(one)); assertTrue(sm.contains(two)); assertTrue(sm.contains(three)); assertTrue(sm.contains(four)); assertTrue(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(four); - assertEquals(four, ssm.first()); - assertEquals(five, ssm.last()); - assertTrue(ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(four); + mustEqual(four, ssm.first()); + mustEqual(five, ssm.last()); + mustRemove(ssm, four); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } /** * size changes when elements added and removed */ public void testDescendingSize() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -660,7 +659,7 @@ public void testDescendingSize() { * add(null) throws NPE */ public void testDescendingAddNull() { - NavigableSet q = dset0(); + NavigableSet q = dset0(); try { q.add(null); shouldThrow(); @@ -671,24 +670,24 @@ public void testDescendingAddNull() { * Add of comparable element succeeds */ public void testDescendingAdd() { - NavigableSet q = dset0(); - assertTrue(q.add(m6)); + NavigableSet q = dset0(); + assertTrue(q.add(minusSix)); } /** * Add of duplicate element fails */ public void testDescendingAddDup() { - NavigableSet q = dset0(); - assertTrue(q.add(m6)); - assertFalse(q.add(m6)); + NavigableSet q = dset0(); + assertTrue(q.add(minusSix)); + assertFalse(q.add(minusSix)); } /** * Add of non-Comparable throws CCE */ public void testDescendingAddNonComparable() { - NavigableSet q = dset0(); + NavigableSet q = new ConcurrentSkipListSet<>(); try { q.add(new Object()); q.add(new Object()); @@ -700,7 +699,7 @@ public void testDescendingAddNonComparable() { * addAll(null) throws NPE */ public void testDescendingAddAll1() { - NavigableSet q = dset0(); + NavigableSet q = dset0(); try { q.addAll(null); shouldThrow(); @@ -711,10 +710,10 @@ public void testDescendingAddAll1() { * addAll of a collection with null elements throws NPE */ public void testDescendingAddAll2() { - NavigableSet q = dset0(); - Integer[] ints = new Integer[SIZE]; + NavigableSet q = dset0(); + Item[] items = new Item[1]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -724,12 +723,10 @@ public void testDescendingAddAll2() { * possibly adding some elements */ public void testDescendingAddAll3() { - NavigableSet q = dset0(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i + SIZE); + NavigableSet q = dset0(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -738,24 +735,24 @@ public void testDescendingAddAll3() { * Set contains all elements of successful addAll */ public void testDescendingAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; + Item[] empty = new Item[0]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - NavigableSet q = dset0(); + items[i] = itemFor(SIZE - 1 - i); + NavigableSet q = dset0(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * poll succeeds unless empty */ public void testDescendingPoll() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -764,13 +761,13 @@ public void testDescendingPoll() { * remove(x) removes x and returns true if present */ public void testDescendingRemoveElement() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.remove(new Integer(i))); + mustRemove(q, i); } for (int i = 0; i < SIZE; i += 2 ) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i + 1))); + mustRemove(q, i); + mustNotRemove(q, i + 1); } assertTrue(q.isEmpty()); } @@ -779,11 +776,11 @@ public void testDescendingRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testDescendingContains() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -791,11 +788,11 @@ public void testDescendingContains() { * clear removes all elements */ public void testDescendingClear() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -805,12 +802,12 @@ public void testDescendingClear() { * containsAll(c) is true when c contains a subset of elements */ public void testDescendingContainsAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = dset0(); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = dset0(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -819,8 +816,8 @@ public void testDescendingContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testDescendingRetainAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -829,7 +826,7 @@ public void testDescendingRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -839,13 +836,12 @@ public void testDescendingRetainAll() { */ public void testDescendingRemoveAll() { for (int i = 1; i < SIZE; ++i) { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(i); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -854,14 +850,14 @@ public void testDescendingRemoveAll() { * lower returns preceding element */ public void testDescendingLower() { - NavigableSet q = dset5(); - Object e1 = q.lower(m3); - assertEquals(m2, e1); + NavigableSet q = dset5(); + Object e1 = q.lower(minusThree); + mustEqual(minusTwo, e1); - Object e2 = q.lower(m6); - assertEquals(m5, e2); + Object e2 = q.lower(minusSix); + mustEqual(minusFive, e2); - Object e3 = q.lower(m1); + Object e3 = q.lower(minusOne); assertNull(e3); Object e4 = q.lower(zero); @@ -872,17 +868,17 @@ public void testDescendingLower() { * higher returns next element */ public void testDescendingHigher() { - NavigableSet q = dset5(); - Object e1 = q.higher(m3); - assertEquals(m4, e1); + NavigableSet q = dset5(); + Object e1 = q.higher(minusThree); + mustEqual(minusFour, e1); Object e2 = q.higher(zero); - assertEquals(m1, e2); + mustEqual(minusOne, e2); - Object e3 = q.higher(m5); + Object e3 = q.higher(minusFive); assertNull(e3); - Object e4 = q.higher(m6); + Object e4 = q.higher(minusSix); assertNull(e4); } @@ -890,15 +886,15 @@ public void testDescendingHigher() { * floor returns preceding element */ public void testDescendingFloor() { - NavigableSet q = dset5(); - Object e1 = q.floor(m3); - assertEquals(m3, e1); + NavigableSet q = dset5(); + Object e1 = q.floor(minusThree); + mustEqual(minusThree, e1); - Object e2 = q.floor(m6); - assertEquals(m5, e2); + Object e2 = q.floor(minusSix); + mustEqual(minusFive, e2); - Object e3 = q.floor(m1); - assertEquals(m1, e3); + Object e3 = q.floor(minusOne); + mustEqual(minusOne, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -908,17 +904,17 @@ public void testDescendingFloor() { * ceiling returns next element */ public void testDescendingCeiling() { - NavigableSet q = dset5(); - Object e1 = q.ceiling(m3); - assertEquals(m3, e1); + NavigableSet q = dset5(); + Object e1 = q.ceiling(minusThree); + mustEqual(minusThree, e1); Object e2 = q.ceiling(zero); - assertEquals(m1, e2); + mustEqual(minusOne, e2); - Object e3 = q.ceiling(m5); - assertEquals(m5, e3); + Object e3 = q.ceiling(minusFive); + mustEqual(minusFive, e3); - Object e4 = q.ceiling(m6); + Object e4 = q.ceiling(minusSix); assertNull(e4); } @@ -926,69 +922,69 @@ public void testDescendingCeiling() { * toArray contains all elements */ public void testDescendingToArray() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); Object[] o = q.toArray(); Arrays.sort(o); for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.pollFirst()); + mustEqual(o[i], q.pollFirst()); } /** * toArray(a) contains all elements */ public void testDescendingToArray2() { - NavigableSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - assertSame(ints, q.toArray(ints)); - Arrays.sort(ints); - for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.pollFirst()); + NavigableSet q = populatedSet(SIZE); + Item[] items = new Item[SIZE]; + assertSame(items, q.toArray(items)); + Arrays.sort(items); + for (int i = 0; i < items.length; i++) + mustEqual(items[i], q.pollFirst()); } /** * iterator iterates through all elements */ public void testDescendingIterator() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); int i = 0; - Iterator it = q.iterator(); + Iterator it = q.iterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); } /** * iterator of empty set has no elements */ public void testDescendingEmptyIterator() { - NavigableSet q = dset0(); + NavigableSet q = dset0(); int i = 0; - Iterator it = q.iterator(); + Iterator it = q.iterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(0, i); + mustEqual(0, i); } /** * iterator.remove removes current element */ public void testDescendingIteratorRemove() { - final NavigableSet q = dset0(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final NavigableSet q = dset0(); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -996,7 +992,7 @@ public void testDescendingIteratorRemove() { * toString contains toStrings of elements */ public void testDescendingToString() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -1007,16 +1003,16 @@ public void testDescendingToString() { * A deserialized/reserialized set equals original */ public void testDescendingSerialization() throws Exception { - NavigableSet x = dset5(); - NavigableSet y = serialClone(x); + NavigableSet x = dset5(); + NavigableSet y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -1025,119 +1021,115 @@ public void testDescendingSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testDescendingSubSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.subSet(m2, m4); - assertEquals(m2, sm.first()); - assertEquals(m3, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableSet set = dset5(); + SortedSet sm = set.subSet(minusTwo, minusFour); + mustEqual(minusTwo, sm.first()); + mustEqual(minusThree, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(m2)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(m3, sm.first()); - assertEquals(m3, sm.last()); - assertTrue(sm.remove(m3)); + mustNotContain(set, minusTwo); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(minusThree, sm.first()); + mustEqual(minusThree, sm.last()); + mustRemove(sm, minusThree); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testDescendingSubSetContents2() { - NavigableSet set = dset5(); - SortedSet sm = set.subSet(m2, m3); - assertEquals(1, sm.size()); - assertEquals(m2, sm.first()); - assertEquals(m2, sm.last()); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertFalse(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); + NavigableSet set = dset5(); + SortedSet sm = set.subSet(minusTwo, minusThree); + mustEqual(1, sm.size()); + mustEqual(minusTwo, sm.first()); + mustEqual(minusTwo, sm.last()); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustNotContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(m2)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, minusTwo); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertFalse(sm.remove(m3)); - assertEquals(4, set.size()); + mustNotRemove(sm, minusThree); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testDescendingHeadSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.headSet(m4); - assertTrue(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m1, k); - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableSet set = dset5(); + SortedSet sm = set.headSet(minusFour); + mustContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusOne, k); + k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(m4, set.first()); + mustEqual(2, set.size()); + mustEqual(minusFour, set.first()); } /** * tailSet returns set with keys in requested range */ public void testDescendingTailSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.tailSet(m2); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertTrue(sm.contains(m4)); - assertTrue(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); - k = (Integer)(i.next()); - assertEquals(m4, k); - k = (Integer)(i.next()); - assertEquals(m5, k); + NavigableSet set = dset5(); + SortedSet sm = set.tailSet(minusTwo); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustContain(sm, minusFour); + mustContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); + k = i.next(); + mustEqual(minusFour, k); + k = i.next(); + mustEqual(minusFive, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(m4); - assertEquals(m4, ssm.first()); - assertEquals(m5, ssm.last()); - assertTrue(ssm.remove(m4)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(minusFour); + mustEqual(minusFour, ssm.first()); + mustEqual(minusFive, ssm.last()); + mustRemove(ssm, minusFour); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } } diff --git a/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java index d893ba3fbc9..83e6c61c877 100644 --- a/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java +++ b/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java @@ -56,11 +56,12 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return CopyOnWriteArrayList.class; } public List emptyCollection() { return new CopyOnWriteArrayList(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return true; } } class SubListImplementation extends Implementation { + @SuppressWarnings("unchecked") public List emptyCollection() { List list = super.emptyCollection(); ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -76,23 +77,23 @@ public List emptyCollection() { CollectionTest.testSuite(new SubListImplementation())); } - static CopyOnWriteArrayList populatedList(int n) { - CopyOnWriteArrayList list = new CopyOnWriteArrayList<>(); + static CopyOnWriteArrayList populatedList(int n) { + CopyOnWriteArrayList list = new CopyOnWriteArrayList<>(); assertTrue(list.isEmpty()); for (int i = 0; i < n; i++) - list.add(i); - assertEquals(n <= 0, list.isEmpty()); - assertEquals(n, list.size()); + mustAdd(list, i); + mustEqual(n <= 0, list.isEmpty()); + mustEqual(n, list.size()); return list; } - static CopyOnWriteArrayList populatedList(Integer[] elements) { - CopyOnWriteArrayList list = new CopyOnWriteArrayList<>(); + static CopyOnWriteArrayList populatedList(Item[] elements) { + CopyOnWriteArrayList list = new CopyOnWriteArrayList<>(); assertTrue(list.isEmpty()); - for (Integer element : elements) + for (Item element : elements) list.add(element); assertFalse(list.isEmpty()); - assertEquals(elements.length, list.size()); + mustEqual(elements.length, list.size()); return list; } @@ -100,7 +101,7 @@ static CopyOnWriteArrayList populatedList(Integer[] elements) { * a new list is empty */ public void testConstructor() { - List list = new CopyOnWriteArrayList(); + List list = new CopyOnWriteArrayList<>(); assertTrue(list.isEmpty()); } @@ -108,35 +109,31 @@ public void testConstructor() { * new list contains all elements of initializing array */ public void testConstructor2() { - Integer[] elts = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - elts[i] = i; - List list = new CopyOnWriteArrayList(elts); + Item[] elts = defaultItems; + List list = new CopyOnWriteArrayList<>(elts); for (int i = 0; i < SIZE; ++i) - assertEquals(elts[i], list.get(i)); + mustEqual(elts[i], list.get(i)); } /** * new list contains all elements of initializing collection */ public void testConstructor3() { - Integer[] elts = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - elts[i] = i; - List list = new CopyOnWriteArrayList(Arrays.asList(elts)); + Item[] elts = defaultItems; + List list = new CopyOnWriteArrayList<>(Arrays.asList(elts)); for (int i = 0; i < SIZE; ++i) - assertEquals(elts[i], list.get(i)); + mustEqual(elts[i], list.get(i)); } /** * addAll adds each element from the given collection, including duplicates */ public void testAddAll() { - List list = populatedList(3); + List list = populatedList(3); assertTrue(list.addAll(Arrays.asList(three, four, five))); - assertEquals(6, list.size()); + mustEqual(6, list.size()); assertTrue(list.addAll(Arrays.asList(three, four, five))); - assertEquals(9, list.size()); + mustEqual(9, list.size()); } /** @@ -144,48 +141,49 @@ public void testAddAll() { * already exist in the List */ public void testAddAllAbsent() { - CopyOnWriteArrayList list = populatedList(3); + CopyOnWriteArrayList list = populatedList(3); // "one" is duplicate and will not be added - assertEquals(2, list.addAllAbsent(Arrays.asList(three, four, one))); - assertEquals(5, list.size()); - assertEquals(0, list.addAllAbsent(Arrays.asList(three, four, one))); - assertEquals(5, list.size()); + mustEqual(2, list.addAllAbsent(Arrays.asList(three, four, one))); + mustEqual(5, list.size()); + mustEqual(0, list.addAllAbsent(Arrays.asList(three, four, one))); + mustEqual(5, list.size()); } /** * addIfAbsent will not add the element if it already exists in the list */ public void testAddIfAbsent() { - CopyOnWriteArrayList list = populatedList(SIZE); + CopyOnWriteArrayList list = populatedList(SIZE); list.addIfAbsent(one); - assertEquals(SIZE, list.size()); + mustEqual(SIZE, list.size()); } /** * addIfAbsent adds the element when it does not exist in the list */ public void testAddIfAbsent2() { - CopyOnWriteArrayList list = populatedList(SIZE); + CopyOnWriteArrayList list = populatedList(SIZE); list.addIfAbsent(three); - assertTrue(list.contains(three)); + mustContain(list, three); } /** * clear removes all elements from the list */ public void testClear() { - List list = populatedList(SIZE); + List list = populatedList(SIZE); list.clear(); - assertEquals(0, list.size()); + mustEqual(0, list.size()); } /** * Cloned list is equal */ public void testClone() { - CopyOnWriteArrayList l1 = populatedList(SIZE); - CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone()); - assertEquals(l1, l2); + CopyOnWriteArrayList l1 = populatedList(SIZE); + @SuppressWarnings("unchecked") + CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone()); + mustEqual(l1, l2); l1.clear(); assertFalse(l1.equals(l2)); } @@ -194,49 +192,49 @@ public void testClone() { * contains is true for added elements */ public void testContains() { - List list = populatedList(3); - assertTrue(list.contains(one)); - assertFalse(list.contains(five)); + List list = populatedList(3); + mustContain(list, one); + mustNotContain(list, five); } /** * adding at an index places it in the indicated index */ public void testAddIndex() { - List list = populatedList(3); - list.add(0, m1); - assertEquals(4, list.size()); - assertEquals(m1, list.get(0)); - assertEquals(zero, list.get(1)); + List list = populatedList(3); + list.add(0, minusOne); + mustEqual(4, list.size()); + mustEqual(minusOne, list.get(0)); + mustEqual(zero, list.get(1)); - list.add(2, m2); - assertEquals(5, list.size()); - assertEquals(m2, list.get(2)); - assertEquals(two, list.get(4)); + list.add(2, minusTwo); + mustEqual(5, list.size()); + mustEqual(minusTwo, list.get(2)); + mustEqual(two, list.get(4)); } /** * lists with same elements are equal and have same hashCode */ public void testEquals() { - List a = populatedList(3); - List b = populatedList(3); + List a = populatedList(3); + List b = populatedList(3); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); - a.add(m1); + mustEqual(a.hashCode(), b.hashCode()); + a.add(minusOne); assertFalse(a.equals(b)); assertFalse(b.equals(a)); assertTrue(a.containsAll(b)); assertFalse(b.containsAll(a)); - b.add(m1); + b.add(minusOne); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); + mustEqual(a.hashCode(), b.hashCode()); assertFalse(a.equals(null)); } @@ -245,7 +243,7 @@ public void testEquals() { * containsAll returns true for collections with subset of elements */ public void testContainsAll() { - List list = populatedList(3); + List list = populatedList(3); assertTrue(list.containsAll(Arrays.asList())); assertTrue(list.containsAll(Arrays.asList(one))); assertTrue(list.containsAll(Arrays.asList(one, two))); @@ -262,8 +260,8 @@ public void testContainsAll() { * get returns the value at the given index */ public void testGet() { - List list = populatedList(3); - assertEquals(0, list.get(0)); + List list = populatedList(3); + mustEqual(0, list.get(0)); } /** @@ -272,25 +270,26 @@ public void testGet() { * contain the element */ public void testIndexOf() { - List list = populatedList(3); - assertEquals(-1, list.indexOf(-42)); + List list = populatedList(3); + mustEqual(-1, list.indexOf(minusTen)); int size = list.size(); for (int i = 0; i < size; i++) { - assertEquals(i, list.indexOf(i)); - assertEquals(i, list.subList(0, size).indexOf(i)); - assertEquals(i, list.subList(0, i + 1).indexOf(i)); - assertEquals(-1, list.subList(0, i).indexOf(i)); - assertEquals(0, list.subList(i, size).indexOf(i)); - assertEquals(-1, list.subList(i + 1, size).indexOf(i)); + Item I = itemFor(i); + mustEqual(i, list.indexOf(I)); + mustEqual(i, list.subList(0, size).indexOf(I)); + mustEqual(i, list.subList(0, i + 1).indexOf(I)); + mustEqual(-1, list.subList(0, i).indexOf(I)); + mustEqual(0, list.subList(i, size).indexOf(I)); + mustEqual(-1, list.subList(i + 1, size).indexOf(I)); } - list.add(1); - assertEquals(1, list.indexOf(1)); - assertEquals(1, list.subList(0, size + 1).indexOf(1)); - assertEquals(0, list.subList(1, size + 1).indexOf(1)); - assertEquals(size - 2, list.subList(2, size + 1).indexOf(1)); - assertEquals(0, list.subList(size, size + 1).indexOf(1)); - assertEquals(-1, list.subList(size + 1, size + 1).indexOf(1)); + list.add(one); + mustEqual(1, list.indexOf(one)); + mustEqual(1, list.subList(0, size + 1).indexOf(one)); + mustEqual(0, list.subList(1, size + 1).indexOf(one)); + mustEqual(size - 2, list.subList(2, size + 1).indexOf(one)); + mustEqual(0, list.subList(size, size + 1).indexOf(one)); + mustEqual(-1, list.subList(size + 1, size + 1).indexOf(one)); } /** @@ -299,41 +298,42 @@ public void testIndexOf() { * or returns -1 if the element is not found */ public void testIndexOf2() { - CopyOnWriteArrayList list = populatedList(3); + CopyOnWriteArrayList list = populatedList(3); int size = list.size(); - assertEquals(-1, list.indexOf(-42, 0)); + mustEqual(-1, list.indexOf(minusTen, 0)); // we might expect IOOBE, but spec says otherwise - assertEquals(-1, list.indexOf(0, size)); - assertEquals(-1, list.indexOf(0, Integer.MAX_VALUE)); + mustEqual(-1, list.indexOf(zero, size)); + mustEqual(-1, list.indexOf(zero, Integer.MAX_VALUE)); assertThrows( IndexOutOfBoundsException.class, - () -> list.indexOf(0, -1), - () -> list.indexOf(0, Integer.MIN_VALUE)); + () -> list.indexOf(zero, -1), + () -> list.indexOf(zero, Integer.MIN_VALUE)); for (int i = 0; i < size; i++) { - assertEquals(i, list.indexOf(i, 0)); - assertEquals(i, list.indexOf(i, i)); - assertEquals(-1, list.indexOf(i, i + 1)); + Item I = itemFor(i); + mustEqual(i, list.indexOf(I, 0)); + mustEqual(i, list.indexOf(I, i)); + mustEqual(-1, list.indexOf(I, i + 1)); } - list.add(1); - assertEquals(1, list.indexOf(1, 0)); - assertEquals(1, list.indexOf(1, 1)); - assertEquals(size, list.indexOf(1, 2)); - assertEquals(size, list.indexOf(1, size)); + list.add(one); + mustEqual(1, list.indexOf(one, 0)); + mustEqual(1, list.indexOf(one, 1)); + mustEqual(size, list.indexOf(one, 2)); + mustEqual(size, list.indexOf(one, size)); } /** * isEmpty returns true when empty, else false */ public void testIsEmpty() { - List empty = new CopyOnWriteArrayList(); + List empty = new CopyOnWriteArrayList<>(); assertTrue(empty.isEmpty()); assertTrue(empty.subList(0, 0).isEmpty()); - List full = populatedList(SIZE); + List full = populatedList(SIZE); assertFalse(full.isEmpty()); assertTrue(full.subList(0, 0).isEmpty()); assertTrue(full.subList(SIZE, SIZE).isEmpty()); @@ -344,23 +344,21 @@ public void testIsEmpty() { * list in insertion order */ public void testIterator() { - Collection empty = new CopyOnWriteArrayList(); + Collection empty = new CopyOnWriteArrayList<>(); assertFalse(empty.iterator().hasNext()); try { empty.iterator().next(); shouldThrow(); } catch (NoSuchElementException success) {} - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedList(elements); + Collection full = populatedList(elements); - Iterator it = full.iterator(); + Iterator it = full.iterator(); for (int j = 0; j < SIZE; j++) { assertTrue(it.hasNext()); - assertEquals(elements[j], it.next()); + mustEqual(elements[j], it.next()); } assertIteratorExhausted(it); } @@ -369,7 +367,7 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - Collection c = new CopyOnWriteArrayList(); + Collection c = new CopyOnWriteArrayList<>(); assertIteratorExhausted(c.iterator()); } @@ -377,8 +375,8 @@ public void testEmptyIterator() { * iterator.remove throws UnsupportedOperationException */ public void testIteratorRemove() { - CopyOnWriteArrayList list = populatedList(SIZE); - Iterator it = list.iterator(); + CopyOnWriteArrayList list = populatedList(SIZE); + Iterator it = list.iterator(); it.next(); try { it.remove(); @@ -390,12 +388,12 @@ public void testIteratorRemove() { * toString contains toString of elements */ public void testToString() { - assertEquals("[]", new CopyOnWriteArrayList().toString()); - List list = populatedList(3); + mustEqual("[]", new CopyOnWriteArrayList<>().toString()); + List list = populatedList(3); String s = list.toString(); for (int i = 0; i < 3; ++i) assertTrue(s.contains(String.valueOf(i))); - assertEquals(new ArrayList(list).toString(), + mustEqual(new ArrayList(list).toString(), list.toString()); } @@ -405,24 +403,25 @@ public void testToString() { * contain the element */ public void testLastIndexOf1() { - List list = populatedList(3); - assertEquals(-1, list.lastIndexOf(-42)); + List list = populatedList(3); + mustEqual(-1, list.lastIndexOf(itemFor(-42))); int size = list.size(); for (int i = 0; i < size; i++) { - assertEquals(i, list.lastIndexOf(i)); - assertEquals(i, list.subList(0, size).lastIndexOf(i)); - assertEquals(i, list.subList(0, i + 1).lastIndexOf(i)); - assertEquals(-1, list.subList(0, i).lastIndexOf(i)); - assertEquals(0, list.subList(i, size).lastIndexOf(i)); - assertEquals(-1, list.subList(i + 1, size).lastIndexOf(i)); + Item I = itemFor(i); + mustEqual(i, list.lastIndexOf(I)); + mustEqual(i, list.subList(0, size).lastIndexOf(I)); + mustEqual(i, list.subList(0, i + 1).lastIndexOf(I)); + mustEqual(-1, list.subList(0, i).lastIndexOf(I)); + mustEqual(0, list.subList(i, size).lastIndexOf(I)); + mustEqual(-1, list.subList(i + 1, size).lastIndexOf(I)); } - list.add(1); - assertEquals(size, list.lastIndexOf(1)); - assertEquals(size, list.subList(0, size + 1).lastIndexOf(1)); - assertEquals(1, list.subList(0, size).lastIndexOf(1)); - assertEquals(0, list.subList(1, 2).lastIndexOf(1)); - assertEquals(-1, list.subList(0, 1).indexOf(1)); + list.add(one); + mustEqual(size, list.lastIndexOf(one)); + mustEqual(size, list.subList(0, size + 1).lastIndexOf(one)); + mustEqual(1, list.subList(0, size).lastIndexOf(one)); + mustEqual(0, list.subList(1, 2).lastIndexOf(one)); + mustEqual(-1, list.subList(0, 1).indexOf(one)); } /** @@ -431,54 +430,55 @@ public void testLastIndexOf1() { * returns -1 if the element is not found */ public void testLastIndexOf2() { - CopyOnWriteArrayList list = populatedList(3); + CopyOnWriteArrayList list = populatedList(3); // we might expect IOOBE, but spec says otherwise - assertEquals(-1, list.lastIndexOf(0, -1)); + mustEqual(-1, list.lastIndexOf(zero, -1)); int size = list.size(); assertThrows( IndexOutOfBoundsException.class, - () -> list.lastIndexOf(0, size), - () -> list.lastIndexOf(0, Integer.MAX_VALUE)); + () -> list.lastIndexOf(zero, size), + () -> list.lastIndexOf(zero, Integer.MAX_VALUE)); for (int i = 0; i < size; i++) { - assertEquals(i, list.lastIndexOf(i, i)); - assertEquals(list.indexOf(i), list.lastIndexOf(i, i)); + Item I = itemFor(i); + mustEqual(i, list.lastIndexOf(I, i)); + mustEqual(list.indexOf(I), list.lastIndexOf(I, i)); if (i > 0) - assertEquals(-1, list.lastIndexOf(i, i - 1)); + mustEqual(-1, list.lastIndexOf(I, i - 1)); } list.add(one); list.add(three); - assertEquals(1, list.lastIndexOf(one, 1)); - assertEquals(1, list.lastIndexOf(one, 2)); - assertEquals(3, list.lastIndexOf(one, 3)); - assertEquals(3, list.lastIndexOf(one, 4)); - assertEquals(-1, list.lastIndexOf(three, 3)); + mustEqual(1, list.lastIndexOf(one, 1)); + mustEqual(1, list.lastIndexOf(one, 2)); + mustEqual(3, list.lastIndexOf(one, 3)); + mustEqual(3, list.lastIndexOf(one, 4)); + mustEqual(-1, list.lastIndexOf(three, 3)); } /** * listIterator traverses all elements */ public void testListIterator1() { - List list = populatedList(SIZE); - ListIterator i = list.listIterator(); + List list = populatedList(SIZE); + ListIterator i = list.listIterator(); int j; for (j = 0; i.hasNext(); j++) - assertEquals(j, i.next()); - assertEquals(SIZE, j); + mustEqual(j, i.next()); + mustEqual(SIZE, j); } /** * listIterator only returns those elements after the given index */ public void testListIterator2() { - List list = populatedList(3); - ListIterator i = list.listIterator(1); + List list = populatedList(3); + ListIterator i = list.listIterator(1); int j; for (j = 0; i.hasNext(); j++) - assertEquals(j + 1, i.next()); - assertEquals(2, j); + mustEqual(j + 1, i.next()); + mustEqual(2, j); } /** @@ -487,10 +487,10 @@ public void testListIterator2() { public void testRemove_int() { int SIZE = 3; for (int i = 0; i < SIZE; i++) { - List list = populatedList(SIZE); - assertEquals(i, list.remove(i)); - assertEquals(SIZE - 1, list.size()); - assertFalse(list.contains(new Integer(i))); + List list = populatedList(SIZE); + mustEqual(i, list.remove(i)); + mustEqual(SIZE - 1, list.size()); + mustNotContain(list, i); } } @@ -500,54 +500,54 @@ public void testRemove_int() { public void testRemove_Object() { int SIZE = 3; for (int i = 0; i < SIZE; i++) { - List list = populatedList(SIZE); - assertFalse(list.remove(new Integer(-42))); - assertTrue(list.remove(new Integer(i))); - assertEquals(SIZE - 1, list.size()); - assertFalse(list.contains(new Integer(i))); + List list = populatedList(SIZE); + mustNotRemove(list, fortytwo); + mustRemove(list, i); + mustEqual(SIZE - 1, list.size()); + mustNotContain(list, i); } - CopyOnWriteArrayList x = new CopyOnWriteArrayList(Arrays.asList(4, 5, 6)); - assertTrue(x.remove(new Integer(6))); - assertEquals(x, Arrays.asList(4, 5)); - assertTrue(x.remove(new Integer(4))); - assertEquals(x, Arrays.asList(5)); - assertTrue(x.remove(new Integer(5))); - assertEquals(x, Arrays.asList()); - assertFalse(x.remove(new Integer(5))); + CopyOnWriteArrayList x = new CopyOnWriteArrayList<>(Arrays.asList(four, five, six)); + mustRemove(x, six); + mustEqual(x, Arrays.asList(four, five)); + mustRemove(x, four); + mustEqual(x, Arrays.asList(five)); + mustRemove(x, five); + mustEqual(x, Arrays.asList()); + mustNotRemove(x, five); } /** * removeAll removes all elements from the given collection */ public void testRemoveAll() { - List list = populatedList(3); + List list = populatedList(3); assertTrue(list.removeAll(Arrays.asList(one, two))); - assertEquals(1, list.size()); + mustEqual(1, list.size()); assertFalse(list.removeAll(Arrays.asList(one, two))); - assertEquals(1, list.size()); + mustEqual(1, list.size()); } /** * set changes the element at the given index */ public void testSet() { - List list = populatedList(3); - assertEquals(2, list.set(2, four)); - assertEquals(4, list.get(2)); + List list = populatedList(3); + mustEqual(2, list.set(2, four)); + mustEqual(4, list.get(2)); } /** * size returns the number of elements */ public void testSize() { - List empty = new CopyOnWriteArrayList(); - assertEquals(0, empty.size()); - assertEquals(0, empty.subList(0, 0).size()); + List empty = new CopyOnWriteArrayList<>(); + mustEqual(0, empty.size()); + mustEqual(0, empty.subList(0, 0).size()); - List full = populatedList(SIZE); - assertEquals(SIZE, full.size()); - assertEquals(0, full.subList(0, 0).size()); - assertEquals(0, full.subList(SIZE, SIZE).size()); + List full = populatedList(SIZE); + mustEqual(SIZE, full.size()); + mustEqual(0, full.subList(0, 0).size()); + mustEqual(0, full.subList(SIZE, SIZE).size()); } /** @@ -555,90 +555,86 @@ public void testSize() { * the list in insertion order */ public void testToArray() { - Object[] a = new CopyOnWriteArrayList().toArray(); + Object[] a = new CopyOnWriteArrayList<>().toArray(); assertTrue(Arrays.equals(new Object[0], a)); assertSame(Object[].class, a.getClass()); - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedList(elements); + Collection full = populatedList(elements); assertTrue(Arrays.equals(elements, full.toArray())); assertSame(Object[].class, full.toArray().getClass()); } /** - * toArray(Integer array) returns an Integer array containing all + * toArray(Item array) returns an Item array containing all * elements from the list in insertion order */ public void testToArray2() { - Collection empty = new CopyOnWriteArrayList(); - Integer[] a; + Collection empty = new CopyOnWriteArrayList<>(); + Item[] a; - a = new Integer[0]; + a = new Item[0]; assertSame(a, empty.toArray(a)); - a = new Integer[SIZE / 2]; - Arrays.fill(a, 42); + a = new Item[SIZE / 2]; + Arrays.fill(a, fortytwo); assertSame(a, empty.toArray(a)); assertNull(a[0]); for (int i = 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedList(elements); + Collection full = populatedList(elements); - Arrays.fill(a, 42); + Arrays.fill(a, fortytwo); assertTrue(Arrays.equals(elements, full.toArray(a))); for (int i = 0; i < a.length; i++) - assertEquals(42, (int) a[i]); - assertSame(Integer[].class, full.toArray(a).getClass()); + mustEqual(42, a[i]); + assertSame(Item[].class, full.toArray(a).getClass()); - a = new Integer[SIZE]; - Arrays.fill(a, 42); + a = new Item[SIZE]; + Arrays.fill(a, fortytwo); assertSame(a, full.toArray(a)); assertTrue(Arrays.equals(elements, a)); - a = new Integer[2 * SIZE]; - Arrays.fill(a, 42); + a = new Item[2 * SIZE]; + Arrays.fill(a, fortytwo); assertSame(a, full.toArray(a)); assertTrue(Arrays.equals(elements, Arrays.copyOf(a, SIZE))); assertNull(a[SIZE]); for (int i = SIZE + 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); } /** * sublists contains elements at indexes offset from their base */ public void testSubList() { - List a = populatedList(10); + List a = populatedList(10); assertTrue(a.subList(1,1).isEmpty()); for (int j = 0; j < 9; ++j) { for (int i = j ; i < 10; ++i) { - List b = a.subList(j,i); + List b = a.subList(j,i); for (int k = j; k < i; ++k) { - assertEquals(new Integer(k), b.get(k-j)); + mustEqual(itemFor(k), b.get(k-j)); } } } - List s = a.subList(2, 5); - assertEquals(3, s.size()); - s.set(2, m1); - assertEquals(a.get(4), m1); + List s = a.subList(2, 5); + mustEqual(3, s.size()); + s.set(2, minusOne); + mustEqual(a.get(4), minusOne); s.clear(); - assertEquals(7, a.size()); + mustEqual(7, a.size()); assertThrows( IndexOutOfBoundsException.class, () -> s.get(0), - () -> s.set(0, 42)); + () -> s.set(0, fortytwo)); } // Exception tests @@ -647,17 +643,19 @@ public void testSubList() { * toArray throws an ArrayStoreException when the given array * can not store the objects inside the list */ + @SuppressWarnings("CollectionToArraySafeParameter") public void testToArray_ArrayStoreException() { - List list = new CopyOnWriteArrayList(); - // Integers are not auto-converted to Longs - list.add(86); - list.add(99); + List list = new CopyOnWriteArrayList<>(); + // Items are not auto-converted to Longs + list.add(eightysix); + list.add(ninetynine); assertThrows( ArrayStoreException.class, () -> list.toArray(new Long[0]), () -> list.toArray(new Long[5])); } + @SuppressWarnings("unchecked") void testIndexOutOfBoundsException(List list) { int size = list.size(); assertThrows( @@ -697,7 +695,7 @@ void testIndexOutOfBoundsException(List list) { */ public void testIndexOutOfBoundsException() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); - List x = populatedList(rnd.nextInt(5)); + List x = populatedList(rnd.nextInt(5)); testIndexOutOfBoundsException(x); int start = rnd.nextInt(x.size() + 1); @@ -705,7 +703,7 @@ public void testIndexOutOfBoundsException() { assertThrows( IndexOutOfBoundsException.class, () -> x.subList(start, start - 1)); - List subList = x.subList(start, end); + List subList = x.subList(start, end); testIndexOutOfBoundsException(x); } @@ -713,18 +711,18 @@ public void testIndexOutOfBoundsException() { * a deserialized/reserialized list equals original */ public void testSerialization() throws Exception { - List x = populatedList(SIZE); - List y = serialClone(x); + List x = populatedList(SIZE); + List y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(0), y.remove(0)); + mustEqual(x.remove(0), y.remove(0)); } assertTrue(y.isEmpty()); } diff --git a/test/jdk/java/util/concurrent/tck/CopyOnWriteArraySetTest.java b/test/jdk/java/util/concurrent/tck/CopyOnWriteArraySetTest.java index 9844a63c225..02f0da0e155 100644 --- a/test/jdk/java/util/concurrent/tck/CopyOnWriteArraySetTest.java +++ b/test/jdk/java/util/concurrent/tck/CopyOnWriteArraySetTest.java @@ -51,7 +51,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return CopyOnWriteArraySet.class; } public Set emptyCollection() { return new CopyOnWriteArraySet(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return true; } } @@ -60,23 +60,23 @@ class Implementation implements CollectionImplementation { CollectionTest.testSuite(new Implementation())); } - static CopyOnWriteArraySet populatedSet(int n) { - CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(); + static CopyOnWriteArraySet populatedSet(int n) { + CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(); assertTrue(a.isEmpty()); for (int i = 0; i < n; i++) - a.add(i); - assertEquals(n == 0, a.isEmpty()); - assertEquals(n, a.size()); + mustAdd(a, i); + mustEqual(n == 0, a.isEmpty()); + mustEqual(n, a.size()); return a; } - static CopyOnWriteArraySet populatedSet(Integer[] elements) { - CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(); + static CopyOnWriteArraySet populatedSet(Item[] elements) { + CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(); assertTrue(a.isEmpty()); for (int i = 0; i < elements.length; i++) - a.add(elements[i]); + mustAdd(a, elements[i]); assertFalse(a.isEmpty()); - assertEquals(elements.length, a.size()); + mustEqual(elements.length, a.size()); return a; } @@ -84,7 +84,7 @@ static CopyOnWriteArraySet populatedSet(Integer[] elements) { * Default-constructed set is empty */ public void testConstructor() { - CopyOnWriteArraySet a = new CopyOnWriteArraySet(); + CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(); assertTrue(a.isEmpty()); } @@ -92,62 +92,60 @@ public void testConstructor() { * Collection-constructed set holds all of its elements */ public void testConstructor3() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); - CopyOnWriteArraySet a = new CopyOnWriteArraySet(Arrays.asList(ints)); + Item[] items = defaultItems; + CopyOnWriteArraySet a = new CopyOnWriteArraySet<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - assertTrue(a.contains(ints[i])); + mustContain(a, i); } /** * addAll adds each non-duplicate element from the given collection */ public void testAddAll() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertTrue(full.addAll(Arrays.asList(three, four, five))); - assertEquals(6, full.size()); + mustEqual(6, full.size()); assertFalse(full.addAll(Arrays.asList(three, four, five))); - assertEquals(6, full.size()); + mustEqual(6, full.size()); } /** * addAll adds each non-duplicate element from the given collection */ public void testAddAll2() { - Set full = populatedSet(3); + Set full = populatedSet(3); // "one" is duplicate and will not be added assertTrue(full.addAll(Arrays.asList(three, four, one))); - assertEquals(5, full.size()); + mustEqual(5, full.size()); assertFalse(full.addAll(Arrays.asList(three, four, one))); - assertEquals(5, full.size()); + mustEqual(5, full.size()); } /** * add will not add the element if it already exists in the set */ public void testAdd2() { - Set full = populatedSet(3); + Set full = populatedSet(3); full.add(one); - assertEquals(3, full.size()); + mustEqual(3, full.size()); } /** * add adds the element when it does not exist in the set */ public void testAdd3() { - Set full = populatedSet(3); + Set full = populatedSet(3); full.add(three); - assertTrue(full.contains(three)); + mustContain(full, three); } /** * clear removes all elements from the set */ public void testClear() { - Collection full = populatedSet(3); + Collection full = populatedSet(3); full.clear(); - assertEquals(0, full.size()); + mustEqual(0, full.size()); assertTrue(full.isEmpty()); } @@ -155,37 +153,37 @@ public void testClear() { * contains returns true for added elements */ public void testContains() { - Collection full = populatedSet(3); - assertTrue(full.contains(one)); - assertFalse(full.contains(five)); + Collection full = populatedSet(3); + mustContain(full, one); + mustNotContain(full, five); } /** * Sets with equal elements are equal */ public void testEquals() { - CopyOnWriteArraySet a = populatedSet(3); - CopyOnWriteArraySet b = populatedSet(3); + CopyOnWriteArraySet a = populatedSet(3); + CopyOnWriteArraySet b = populatedSet(3); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); - assertEquals(a.size(), b.size()); + mustEqual(a.hashCode(), b.hashCode()); + mustEqual(a.size(), b.size()); - a.add(m1); + a.add(minusOne); assertFalse(a.equals(b)); assertFalse(b.equals(a)); assertTrue(a.containsAll(b)); assertFalse(b.containsAll(a)); - b.add(m1); + b.add(minusOne); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); + mustEqual(a.hashCode(), b.hashCode()); - Object x = a.iterator().next(); + Item x = a.iterator().next(); a.remove(x); assertFalse(a.equals(b)); assertFalse(b.equals(a)); @@ -196,11 +194,11 @@ public void testEquals() { assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); - assertEquals(a.size(), b.size()); + mustEqual(a.hashCode(), b.hashCode()); + mustEqual(a.size(), b.size()); - CopyOnWriteArraySet empty1 = new CopyOnWriteArraySet(Arrays.asList()); - CopyOnWriteArraySet empty2 = new CopyOnWriteArraySet(Arrays.asList()); + CopyOnWriteArraySet empty1 = new CopyOnWriteArraySet<>(Arrays.asList()); + CopyOnWriteArraySet empty2 = new CopyOnWriteArraySet<>(Arrays.asList()); assertTrue(empty1.equals(empty1)); assertTrue(empty1.equals(empty2)); @@ -214,7 +212,7 @@ public void testEquals() { * containsAll returns true for collections with subset of elements */ public void testContainsAll() { - Collection full = populatedSet(3); + Collection full = populatedSet(3); assertTrue(full.containsAll(full)); assertTrue(full.containsAll(Arrays.asList())); assertTrue(full.containsAll(Arrays.asList(one))); @@ -222,8 +220,8 @@ public void testContainsAll() { assertFalse(full.containsAll(Arrays.asList(one, two, six))); assertFalse(full.containsAll(Arrays.asList(six))); - CopyOnWriteArraySet empty1 = new CopyOnWriteArraySet(Arrays.asList()); - CopyOnWriteArraySet empty2 = new CopyOnWriteArraySet(Arrays.asList()); + CopyOnWriteArraySet empty1 = new CopyOnWriteArraySet<>(Arrays.asList()); + CopyOnWriteArraySet empty2 = new CopyOnWriteArraySet<>(Arrays.asList()); assertTrue(empty1.containsAll(empty2)); assertTrue(empty1.containsAll(empty1)); assertFalse(empty1.containsAll(full)); @@ -248,23 +246,21 @@ public void testIsEmpty() { * set in insertion order */ public void testIterator() { - Collection empty = new CopyOnWriteArraySet(); + Collection empty = new CopyOnWriteArraySet<>(); assertFalse(empty.iterator().hasNext()); try { empty.iterator().next(); shouldThrow(); } catch (NoSuchElementException success) {} - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); - Iterator it = full.iterator(); + Iterator it = full.iterator(); for (int j = 0; j < SIZE; j++) { assertTrue(it.hasNext()); - assertEquals(elements[j], it.next()); + mustEqual(elements[j], it.next()); } assertIteratorExhausted(it); } @@ -273,15 +269,15 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new CopyOnWriteArraySet().iterator()); + assertIteratorExhausted(new CopyOnWriteArraySet().iterator()); } /** * iterator remove is unsupported */ public void testIteratorRemove() { - Collection full = populatedSet(3); - Iterator it = full.iterator(); + Collection full = populatedSet(3); + Iterator it = full.iterator(); it.next(); try { it.remove(); @@ -293,12 +289,12 @@ public void testIteratorRemove() { * toString holds toString of elements */ public void testToString() { - assertEquals("[]", new CopyOnWriteArraySet().toString()); - Collection full = populatedSet(3); + mustEqual("[]", new CopyOnWriteArraySet().toString()); + Collection full = populatedSet(3); String s = full.toString(); for (int i = 0; i < 3; ++i) assertTrue(s.contains(String.valueOf(i))); - assertEquals(new ArrayList(full).toString(), + mustEqual(new ArrayList(full).toString(), full.toString()); } @@ -306,31 +302,31 @@ public void testToString() { * removeAll removes all elements from the given collection */ public void testRemoveAll() { - Set full = populatedSet(3); + Set full = populatedSet(3); assertTrue(full.removeAll(Arrays.asList(one, two))); - assertEquals(1, full.size()); + mustEqual(1, full.size()); assertFalse(full.removeAll(Arrays.asList(one, two))); - assertEquals(1, full.size()); + mustEqual(1, full.size()); } /** * remove removes an element */ public void testRemove() { - Collection full = populatedSet(3); + Collection full = populatedSet(3); full.remove(one); - assertFalse(full.contains(one)); - assertEquals(2, full.size()); + mustNotContain(full, one); + mustEqual(2, full.size()); } /** * size returns the number of elements */ public void testSize() { - Collection empty = new CopyOnWriteArraySet(); - Collection full = populatedSet(3); - assertEquals(3, full.size()); - assertEquals(0, empty.size()); + Collection empty = new CopyOnWriteArraySet<>(); + Collection full = populatedSet(3); + mustEqual(3, full.size()); + mustEqual(0, empty.size()); } /** @@ -338,72 +334,69 @@ public void testSize() { * the set in insertion order */ public void testToArray() { - Object[] a = new CopyOnWriteArraySet().toArray(); + Object[] a = new CopyOnWriteArraySet<>().toArray(); assertTrue(Arrays.equals(new Object[0], a)); assertSame(Object[].class, a.getClass()); - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); assertTrue(Arrays.equals(elements, full.toArray())); assertSame(Object[].class, full.toArray().getClass()); } /** - * toArray(Integer array) returns an Integer array containing all + * toArray(Item array) returns an Item array containing all * elements from the set in insertion order */ public void testToArray2() { - Collection empty = new CopyOnWriteArraySet(); - Integer[] a; + Collection empty = new CopyOnWriteArraySet<>(); + Item[] a; - a = new Integer[0]; + a = new Item[0]; assertSame(a, empty.toArray(a)); - a = new Integer[SIZE / 2]; - Arrays.fill(a, 42); + a = new Item[SIZE / 2]; + Arrays.fill(a, fortytwo); assertSame(a, empty.toArray(a)); assertNull(a[0]); for (int i = 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); - Integer[] elements = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) - elements[i] = i; + Item[] elements = seqItems(SIZE); shuffle(elements); - Collection full = populatedSet(elements); + Collection full = populatedSet(elements); - Arrays.fill(a, 42); + Arrays.fill(a, fortytwo); assertTrue(Arrays.equals(elements, full.toArray(a))); for (int i = 0; i < a.length; i++) - assertEquals(42, (int) a[i]); - assertSame(Integer[].class, full.toArray(a).getClass()); + mustEqual(42, a[i]); + assertSame(Item[].class, full.toArray(a).getClass()); - a = new Integer[SIZE]; - Arrays.fill(a, 42); + a = new Item[SIZE]; + Arrays.fill(a, fortytwo); assertSame(a, full.toArray(a)); assertTrue(Arrays.equals(elements, a)); - a = new Integer[2 * SIZE]; - Arrays.fill(a, 42); + a = new Item[2 * SIZE]; + Arrays.fill(a, fortytwo); assertSame(a, full.toArray(a)); assertTrue(Arrays.equals(elements, Arrays.copyOf(a, SIZE))); assertNull(a[SIZE]); for (int i = SIZE + 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); } /** * toArray throws an ArrayStoreException when the given array can * not store the objects inside the set */ + @SuppressWarnings("CollectionToArraySafeParameter") public void testToArray_ArrayStoreException() { - CopyOnWriteArraySet c = new CopyOnWriteArraySet(); - c.add("zfasdfsdf"); - c.add("asdadasd"); + CopyOnWriteArraySet c = new CopyOnWriteArraySet<>(); + c.add(one); + c.add(two); try { c.toArray(new Long[5]); shouldThrow(); @@ -414,26 +407,26 @@ public void testToArray_ArrayStoreException() { * A deserialized/reserialized set equals original */ public void testSerialization() throws Exception { - Set x = populatedSet(SIZE); - Set y = serialClone(x); + Set x = populatedSet(SIZE); + Set y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); } /** * addAll is idempotent */ public void testAddAll_idempotent() throws Exception { - Set x = populatedSet(SIZE); - Set y = new CopyOnWriteArraySet(x); + Set x = populatedSet(SIZE); + Set y = new CopyOnWriteArraySet<>(x); y.addAll(x); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); } } diff --git a/test/jdk/java/util/concurrent/tck/CountedCompleterTest.java b/test/jdk/java/util/concurrent/tck/CountedCompleterTest.java index 2dc163b271a..2547ca3a200 100644 --- a/test/jdk/java/util/concurrent/tck/CountedCompleterTest.java +++ b/test/jdk/java/util/concurrent/tck/CountedCompleterTest.java @@ -74,7 +74,7 @@ private static ForkJoinPool asyncSingletonPool() { null, true); } - private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) { + private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) { try (PoolCleaner cleaner = cleaner(pool)) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); @@ -94,7 +94,7 @@ private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) { } } - void checkNotDone(CountedCompleter a) { + void checkNotDone(CountedCompleter a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -145,7 +145,7 @@ void checkCompletedNormally(CountedCompleter a) { assertNull(v2); } - void checkCancelled(CountedCompleter a) { + void checkCancelled(CountedCompleter a) { assertTrue(a.isDone()); assertTrue(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -182,7 +182,7 @@ void checkCancelled(CountedCompleter a) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedAbnormally(CountedCompleter a, Throwable t) { + void checkCompletedAbnormally(CountedCompleter a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -245,19 +245,19 @@ abstract class CheckedCC extends CountedCompleter { int setRawResultN() { return setRawResultN.get(); } CheckedCC() { super(); } - CheckedCC(CountedCompleter p) { super(p); } - CheckedCC(CountedCompleter p, int n) { super(p, n); } + CheckedCC(CountedCompleter p) { super(p); } + CheckedCC(CountedCompleter p, int n) { super(p, n); } abstract void realCompute(); public final void compute() { computeN.incrementAndGet(); realCompute(); } - public void onCompletion(CountedCompleter caller) { + public void onCompletion(CountedCompleter caller) { onCompletionN.incrementAndGet(); super.onCompletion(caller); } public boolean onExceptionalCompletion(Throwable ex, - CountedCompleter caller) { + CountedCompleter caller) { onExceptionalCompletionN.incrementAndGet(); assertNotNull(ex); assertTrue(isCompletedAbnormally()); @@ -305,8 +305,8 @@ void checkCompletedExceptionally(Throwable ex) { final class NoopCC extends CheckedCC { NoopCC() { super(); } - NoopCC(CountedCompleter p) { super(p); } - NoopCC(CountedCompleter p, int initialPendingCount) { + NoopCC(CountedCompleter p) { super(p); } + NoopCC(CountedCompleter p, int initialPendingCount) { super(p, initialPendingCount); } protected void realCompute() {} @@ -427,9 +427,9 @@ public void testCompareAndSetPendingCount() { public void testGetCompleter() { NoopCC a = new NoopCC(); assertNull(a.getCompleter()); - CountedCompleter b = new NoopCC(a); + NoopCC b = new NoopCC(a); assertSame(a, b.getCompleter()); - CountedCompleter c = new NoopCC(b); + NoopCC c = new NoopCC(b); assertSame(b, c.getCompleter()); } @@ -552,7 +552,7 @@ abstract class CCF extends CheckedCC { int number; int rnumber; - public CCF(CountedCompleter parent, int n) { + public CCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } @@ -570,10 +570,10 @@ protected final void realCompute() { final class LCCF extends CCF { public LCCF(int n) { this(null, n); } - public LCCF(CountedCompleter parent, int n) { + public LCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; @@ -584,10 +584,10 @@ public final void onCompletion(CountedCompleter caller) { } } final class RCCF extends CCF { - public RCCF(CountedCompleter parent, int n) { + public RCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; @@ -603,7 +603,7 @@ abstract class FailingCCF extends CheckedCC { int number; int rnumber; - public FailingCCF(CountedCompleter parent, int n) { + public FailingCCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } @@ -621,10 +621,10 @@ protected final void realCompute() { final class LFCCF extends FailingCCF { public LFCCF(int n) { this(null, n); } - public LFCCF(CountedCompleter parent, int n) { + public LFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); FailingCCF p = (FailingCCF)getCompleter(); int n = number + rnumber; @@ -635,10 +635,10 @@ public final void onCompletion(CountedCompleter caller) { } } final class RFCCF extends FailingCCF { - public RFCCF(CountedCompleter parent, int n) { + public RFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { super.onCompletion(caller); completeExceptionally(new FJException()); } @@ -650,7 +650,7 @@ public final void onCompletion(CountedCompleter caller) { * completed tasks; getRawResult returns null. */ public void testInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertNull(f.invoke()); @@ -666,7 +666,7 @@ protected void realCompute() { * completed tasks */ public void testQuietlyInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); f.quietlyInvoke(); @@ -680,7 +680,7 @@ protected void realCompute() { * join of a forked task returns when task completes */ public void testForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -695,7 +695,7 @@ protected void realCompute() { * get of a forked task returns when task completes */ public void testForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -710,7 +710,7 @@ protected void realCompute() throws Exception { * timed get of a forked task returns when task completes */ public void testForkTimedGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -725,7 +725,7 @@ protected void realCompute() throws Exception { * timed get with null time unit throws NPE */ public void testForkTimedGetNPE() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -741,7 +741,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -757,7 +757,7 @@ protected void realCompute() { * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesce() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -775,7 +775,7 @@ protected void realCompute() { * invoke task throws exception when task completes abnormally */ public void testAbnormalInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); try { @@ -792,7 +792,7 @@ protected void realCompute() { * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); f.quietlyInvoke(); @@ -806,7 +806,7 @@ protected void realCompute() { * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -824,7 +824,7 @@ protected void realCompute() { * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -844,7 +844,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -864,7 +864,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -879,7 +879,7 @@ protected void realCompute() { * invoke task throws exception when task cancelled */ public void testCancelledInvoke() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -897,7 +897,7 @@ protected void realCompute() { * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -916,7 +916,7 @@ protected void realCompute() { * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -935,7 +935,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGet() throws Exception { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -954,7 +954,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoin() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -970,7 +970,7 @@ protected void realCompute() { */ public void testGetPool() { final ForkJoinPool mainPool = mainPool(); - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertSame(mainPool, getPool()); }}; @@ -981,7 +981,7 @@ protected void realCompute() { * getPool of non-FJ task returns null */ public void testGetPool2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertNull(getPool()); }}; @@ -992,7 +992,7 @@ protected void realCompute() { * inForkJoinPool of executing task returns true */ public void testInForkJoinPool() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertTrue(inForkJoinPool()); }}; @@ -1003,7 +1003,7 @@ protected void realCompute() { * inForkJoinPool of non-FJ task returns false */ public void testInForkJoinPool2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertFalse(inForkJoinPool()); }}; @@ -1014,7 +1014,7 @@ protected void realCompute() { * setRawResult(null) succeeds */ public void testSetRawResult() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { setRawResult(null); assertNull(getRawResult()); @@ -1026,7 +1026,7 @@ protected void realCompute() { * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionally2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF n = new LCCF(8); CCF f = new LCCF(n, 8); @@ -1042,7 +1042,7 @@ protected void realCompute() { * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1059,7 +1059,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); invokeAll(f); @@ -1073,7 +1073,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1093,12 +1093,12 @@ protected void realCompute() { * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollection() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1117,7 +1117,7 @@ protected void realCompute() { * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPE() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1134,7 +1134,7 @@ protected void realCompute() { * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1152,7 +1152,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF g = new LFCCF(9); try { @@ -1169,7 +1169,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1188,12 +1188,12 @@ protected void realCompute() { * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollection() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1212,7 +1212,7 @@ protected void realCompute() { * and suppresses execution */ public void testTryUnfork() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1231,7 +1231,7 @@ protected void realCompute() { * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF h = new LCCF(7); assertSame(h, h.fork()); @@ -1253,7 +1253,7 @@ protected void realCompute() { * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1273,7 +1273,7 @@ protected void realCompute() { * executing it */ public void testPollNextLocalTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1292,7 +1292,7 @@ protected void realCompute() { * pollTask returns an unexecuted task without executing it */ public void testPollTask() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1310,7 +1310,7 @@ protected void realCompute() { * peekNextLocalTask returns least recent unexecuted task in async mode */ public void testPeekNextLocalTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1331,7 +1331,7 @@ protected void realCompute() { * executing it, in async mode */ public void testPollNextLocalTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1351,7 +1351,7 @@ protected void realCompute() { * async mode */ public void testPollTaskAsync() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF g = new LCCF(9); assertSame(g, g.fork()); @@ -1374,7 +1374,7 @@ protected void realCompute() { * completed tasks; getRawResult returns null. */ public void testInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertNull(f.invoke()); @@ -1390,7 +1390,7 @@ protected void realCompute() { * completed tasks */ public void testQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); f.quietlyInvoke(); @@ -1404,7 +1404,7 @@ protected void realCompute() { * join of a forked task returns when task completes */ public void testForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1419,7 +1419,7 @@ protected void realCompute() { * get of a forked task returns when task completes */ public void testForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1434,7 +1434,7 @@ protected void realCompute() throws Exception { * timed get of a forked task returns when task completes */ public void testForkTimedGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1449,7 +1449,7 @@ protected void realCompute() throws Exception { * timed get with null time unit throws NPE */ public void testForkTimedGetNPESingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1465,7 +1465,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1481,7 +1481,7 @@ protected void realCompute() { * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesceSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertSame(f, f.fork()); @@ -1497,7 +1497,7 @@ protected void realCompute() { * invoke task throws exception when task completes abnormally */ public void testAbnormalInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); try { @@ -1514,7 +1514,7 @@ protected void realCompute() { * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); f.quietlyInvoke(); @@ -1528,7 +1528,7 @@ protected void realCompute() { * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1546,7 +1546,7 @@ protected void realCompute() { * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1566,7 +1566,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1586,7 +1586,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); @@ -1601,7 +1601,7 @@ protected void realCompute() { * invoke task throws exception when task cancelled */ public void testCancelledInvokeSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1619,7 +1619,7 @@ protected void realCompute() { * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1638,7 +1638,7 @@ protected void realCompute() { * get of a forked task throws exception when task cancelled */ public void testCancelledForkGetSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1657,7 +1657,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGetSingleton() throws Exception { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1676,7 +1676,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); assertTrue(f.cancel(true)); @@ -1691,7 +1691,7 @@ protected void realCompute() { * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionallySingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF n = new LCCF(8); CCF f = new LCCF(n, 8); @@ -1707,7 +1707,7 @@ protected void realCompute() { * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1724,7 +1724,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); invokeAll(f); @@ -1738,7 +1738,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1758,12 +1758,12 @@ protected void realCompute() { * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1782,7 +1782,7 @@ protected void realCompute() { * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPESingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); CCF g = new LCCF(9); @@ -1799,7 +1799,7 @@ protected void realCompute() { * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1817,7 +1817,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF g = new LFCCF(9); try { @@ -1834,7 +1834,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3Singleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(8); FailingCCF g = new LFCCF(9); @@ -1853,12 +1853,12 @@ protected void realCompute() { * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(8); CCF g = new LCCF(9); CCF h = new LCCF(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); diff --git a/test/jdk/java/util/concurrent/tck/DelayQueueTest.java b/test/jdk/java/util/concurrent/tck/DelayQueueTest.java index 4b60b0a8113..814dca744e9 100644 --- a/test/jdk/java/util/concurrent/tck/DelayQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/DelayQueueTest.java @@ -150,9 +150,9 @@ private static DelayQueue populatedQueue(int n) { for (int i = (n & 1); i < n; i += 2) assertTrue(q.offer(new PDelay(i))); assertFalse(q.isEmpty()); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(n, q.size()); - assertEquals(new PDelay(0), q.peek()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(n, q.size()); + mustEqual(new PDelay(0), q.peek()); return q; } @@ -160,7 +160,7 @@ private static DelayQueue populatedQueue(int n) { * A new queue has unbounded capacity */ public void testConstructor1() { - assertEquals(Integer.MAX_VALUE, new DelayQueue().remainingCapacity()); + mustEqual(Integer.MAX_VALUE, new DelayQueue().remainingCapacity()); } /** @@ -168,7 +168,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new DelayQueue(null); + new DelayQueue(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -178,7 +178,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new DelayQueue(Arrays.asList(new PDelay[SIZE])); + new DelayQueue(Arrays.asList(new PDelay[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -191,7 +191,7 @@ public void testConstructor5() { for (int i = 0; i < SIZE - 1; ++i) a[i] = new PDelay(i); try { - new DelayQueue(Arrays.asList(a)); + new DelayQueue(Arrays.asList(a)); shouldThrow(); } catch (NullPointerException success) {} } @@ -200,21 +200,21 @@ public void testConstructor5() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - PDelay[] ints = new PDelay[SIZE]; + PDelay[] items = new PDelay[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new PDelay(i); - DelayQueue q = new DelayQueue(Arrays.asList(ints)); + items[i] = new PDelay(i); + DelayQueue q = new DelayQueue<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); assertTrue(q.isEmpty()); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); q.add(new PDelay(1)); assertFalse(q.isEmpty()); q.add(new PDelay(2)); @@ -227,15 +227,15 @@ public void testEmpty() { * remainingCapacity() always returns Integer.MAX_VALUE */ public void testRemainingCapacity() { - BlockingQueue q = populatedQueue(SIZE); + BlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(SIZE - i, q.size()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(SIZE - i, q.size()); assertTrue(q.remove() instanceof PDelay); } for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(i, q.size()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(i, q.size()); assertTrue(q.add(new PDelay(i))); } } @@ -244,7 +244,7 @@ public void testRemainingCapacity() { * offer non-null succeeds */ public void testOffer() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); assertTrue(q.offer(new PDelay(0))); assertTrue(q.offer(new PDelay(1))); } @@ -253,9 +253,9 @@ public void testOffer() { * add succeeds */ public void testAdd() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); + mustEqual(i, q.size()); assertTrue(q.add(new PDelay(i))); } } @@ -264,7 +264,7 @@ public void testAdd() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -276,7 +276,7 @@ public void testAddAllSelf() { * possibly adding some elements */ public void testAddAll3() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); PDelay[] a = new PDelay[SIZE]; for (int i = 0; i < SIZE - 1; ++i) a[i] = new PDelay(i); @@ -291,34 +291,34 @@ public void testAddAll3() { */ public void testAddAll5() { PDelay[] empty = new PDelay[0]; - PDelay[] ints = new PDelay[SIZE]; + PDelay[] items = new PDelay[SIZE]; for (int i = SIZE - 1; i >= 0; --i) - ints[i] = new PDelay(i); - DelayQueue q = new DelayQueue(); + items[i] = new PDelay(i); + DelayQueue q = new DelayQueue<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * all elements successfully put are contained */ public void testPut() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); for (int i = 0; i < SIZE; ++i) { PDelay x = new PDelay(i); q.put(x); assertTrue(q.contains(x)); } - assertEquals(SIZE, q.size()); + mustEqual(SIZE, q.size()); } /** * put doesn't block waiting for take */ public void testPutWithTake() throws InterruptedException { - final DelayQueue q = new DelayQueue(); + final DelayQueue q = new DelayQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { q.put(new PDelay(0)); @@ -328,14 +328,14 @@ public void realRun() { }}); awaitTermination(t); - assertEquals(4, q.size()); + mustEqual(4, q.size()); } /** * Queue is unbounded, so timed offer never times out */ public void testTimedOffer() throws InterruptedException { - final DelayQueue q = new DelayQueue(); + final DelayQueue q = new DelayQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.put(new PDelay(0)); @@ -351,9 +351,9 @@ public void realRun() throws InterruptedException { * take retrieves elements in priority order */ public void testTake() throws InterruptedException { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.take()); + mustEqual(new PDelay(i), q.take()); } } @@ -361,12 +361,12 @@ public void testTake() throws InterruptedException { * Take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final DelayQueue q = populatedQueue(SIZE); + final DelayQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(new PDelay(i), ((PDelay)q.take())); + mustEqual(new PDelay(i), q.take()); Thread.currentThread().interrupt(); try { @@ -393,9 +393,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.poll()); + mustEqual(new PDelay(i), q.poll()); } assertNull(q.poll()); } @@ -404,9 +404,9 @@ public void testPoll() { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.poll(0, MILLISECONDS)); + mustEqual(new PDelay(i), q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); } @@ -415,10 +415,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(new PDelay(i), q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(new PDelay(i), q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -433,12 +433,12 @@ public void testTimedPoll() throws InterruptedException { */ public void testInterruptedTimedPoll() throws InterruptedException { final CountDownLatch pleaseInterrupt = new CountDownLatch(1); - final DelayQueue q = populatedQueue(SIZE); + final DelayQueue q = populatedQueue(SIZE); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(new PDelay(i), - ((PDelay)q.poll(LONG_DELAY_MS, MILLISECONDS))); + mustEqual(new PDelay(i), + q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -466,10 +466,10 @@ public void realRun() throws InterruptedException { * peek returns next element, or null if empty */ public void testPeek() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.peek()); - assertEquals(new PDelay(i), q.poll()); + mustEqual(new PDelay(i), q.peek()); + mustEqual(new PDelay(i), q.poll()); if (q.isEmpty()) assertNull(q.peek()); else @@ -482,9 +482,9 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.element()); + mustEqual(new PDelay(i), q.element()); q.poll(); } try { @@ -497,9 +497,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), q.remove()); + mustEqual(new PDelay(i), q.remove()); } try { q.remove(); @@ -511,7 +511,7 @@ public void testRemove() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.contains(new PDelay(i))); q.poll(); @@ -523,11 +523,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(0, q.size()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); PDelay x = new PDelay(1); q.add(x); assertFalse(q.isEmpty()); @@ -540,8 +540,8 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = new DelayQueue(); + DelayQueue q = populatedQueue(SIZE); + DelayQueue p = new DelayQueue<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); @@ -554,8 +554,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); + DelayQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -564,7 +564,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -574,13 +574,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = populatedQueue(i); + DelayQueue q = populatedQueue(SIZE); + DelayQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - PDelay x = (PDelay)(p.remove()); - assertFalse(q.contains(x)); + assertFalse(q.contains(p.remove())); } } } @@ -589,7 +588,7 @@ public void testRemoveAll() { * toArray contains all elements */ public void testToArray() throws InterruptedException { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); Arrays.sort(a); @@ -603,11 +602,11 @@ public void testToArray() throws InterruptedException { */ public void testToArray2() { DelayQueue q = populatedQueue(SIZE); - PDelay[] ints = new PDelay[SIZE]; - PDelay[] array = q.toArray(ints); - assertSame(ints, array); - Arrays.sort(ints); - for (PDelay o : ints) + PDelay[] items = new PDelay[SIZE]; + PDelay[] array = q.toArray(items); + assertSame(items, array); + Arrays.sort(items); + for (PDelay o : items) assertSame(o, q.remove()); assertTrue(q.isEmpty()); } @@ -615,8 +614,9 @@ public void testToArray2() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - DelayQueue q = populatedQueue(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + DelayQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -627,14 +627,14 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); int i = 0; - Iterator it = q.iterator(); + Iterator it = q.iterator(); while (it.hasNext()) { assertTrue(q.contains(it.next())); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -642,23 +642,23 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new DelayQueue().iterator()); + assertIteratorExhausted(new DelayQueue().iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final DelayQueue q = new DelayQueue(); + final DelayQueue q = new DelayQueue<>(); q.add(new PDelay(2)); q.add(new PDelay(1)); q.add(new PDelay(3)); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(new PDelay(2), it.next()); - assertEquals(new PDelay(3), it.next()); + mustEqual(new PDelay(2), it.next()); + mustEqual(new PDelay(3), it.next()); assertFalse(it.hasNext()); } @@ -666,7 +666,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - DelayQueue q = populatedQueue(SIZE); + DelayQueue q = populatedQueue(SIZE); String s = q.toString(); for (Object e : q) assertTrue(s.contains(e.toString())); @@ -676,7 +676,7 @@ public void testToString() { * timed poll transfers elements across Executor tasks */ public void testPollInExecutor() { - final DelayQueue q = new DelayQueue(); + final DelayQueue q = new DelayQueue<>(); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -720,7 +720,7 @@ public void testDelay() throws InterruptedException { * peek of a non-empty queue returns non-null even if not expired */ public void testPeekDelayed() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); q.add(new NanoDelay(Long.MAX_VALUE)); assertNotNull(q.peek()); } @@ -729,7 +729,7 @@ public void testPeekDelayed() { * poll of a non-empty queue returns null if no expired elements. */ public void testPollDelayed() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); q.add(new NanoDelay(Long.MAX_VALUE)); assertNull(q.poll()); } @@ -738,7 +738,7 @@ public void testPollDelayed() { * timed poll of a non-empty queue returns null if no expired elements. */ public void testTimedPollDelayed() throws InterruptedException { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); q.add(new NanoDelay(LONG_DELAY_MS * 1000000L)); long startTime = System.nanoTime(); assertNull(q.poll(timeoutMillis(), MILLISECONDS)); @@ -749,17 +749,17 @@ public void testTimedPollDelayed() throws InterruptedException { * drainTo(c) empties queue into another collection c */ public void testDrainTo() { - DelayQueue q = new DelayQueue(); + DelayQueue q = new DelayQueue<>(); PDelay[] elems = new PDelay[SIZE]; for (int i = 0; i < SIZE; ++i) { elems[i] = new PDelay(i); q.add(elems[i]); } - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); + mustEqual(0, q.size()); for (int i = 0; i < SIZE; ++i) - assertEquals(elems[i], l.get(i)); + mustEqual(elems[i], l.get(i)); q.add(elems[0]); q.add(elems[1]); assertFalse(q.isEmpty()); @@ -767,24 +767,24 @@ public void testDrainTo() { assertTrue(q.contains(elems[1])); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) - assertEquals(elems[i], l.get(i)); + mustEqual(elems[i], l.get(i)); } /** * drainTo empties queue */ public void testDrainToWithActivePut() throws InterruptedException { - final DelayQueue q = populatedQueue(SIZE); + final DelayQueue q = populatedQueue(SIZE); Thread t = new Thread(new CheckedRunnable() { public void realRun() { q.put(new PDelay(SIZE + 1)); }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); t.join(); @@ -796,12 +796,12 @@ public void realRun() { */ public void testDrainToN() { for (int i = 0; i < SIZE + 2; ++i) { - DelayQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); + DelayQueue q = populatedQueue(SIZE); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(SIZE - k, q.size()); - assertEquals(k, l.size()); + mustEqual(SIZE - k, q.size()); + mustEqual(k, l.size()); } } diff --git a/test/jdk/java/util/concurrent/tck/ExchangerTest.java b/test/jdk/java/util/concurrent/tck/ExchangerTest.java index 317b6b22584..ef20b58848e 100644 --- a/test/jdk/java/util/concurrent/tck/ExchangerTest.java +++ b/test/jdk/java/util/concurrent/tck/ExchangerTest.java @@ -55,7 +55,7 @@ public static Test suite() { * exchange exchanges objects across two threads */ public void testExchange() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); Thread t1 = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { assertSame(one, e.exchange(two)); @@ -75,7 +75,7 @@ public void realRun() throws InterruptedException { * timed exchange exchanges objects across two threads */ public void testTimedExchange() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); Thread t1 = newStartedThread(new CheckedRunnable() { public void realRun() throws Exception { assertSame(one, e.exchange(two, LONG_DELAY_MS, MILLISECONDS)); @@ -95,7 +95,7 @@ public void realRun() throws Exception { * interrupt during wait for exchange throws InterruptedException */ public void testExchange_InterruptedException() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedInterruptedRunnable() { public void realRun() throws InterruptedException { @@ -112,7 +112,7 @@ public void realRun() throws InterruptedException { * interrupt during wait for timed exchange throws InterruptedException */ public void testTimedExchange_InterruptedException() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedInterruptedRunnable() { public void realRun() throws Exception { @@ -129,7 +129,7 @@ public void realRun() throws Exception { * timeout during wait for timed exchange throws TimeoutException */ public void testExchange_TimeoutException() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws Exception { long startTime = System.nanoTime(); @@ -147,7 +147,7 @@ public void realRun() throws Exception { * If one exchanging thread is interrupted, another succeeds. */ public void testReplacementAfterExchange() { - final Exchanger e = new Exchanger(); + final Exchanger e = new Exchanger<>(); final CountDownLatch exchanged = new CountDownLatch(2); final CountDownLatch interrupted = new CountDownLatch(1); Thread t1 = newStartedThread(new CheckedInterruptedRunnable() { diff --git a/test/jdk/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/test/jdk/java/util/concurrent/tck/ExecutorCompletionService9Test.java index 92e92478cbc..0f09efa8ee9 100644 --- a/test/jdk/java/util/concurrent/tck/ExecutorCompletionService9Test.java +++ b/test/jdk/java/util/concurrent/tck/ExecutorCompletionService9Test.java @@ -98,7 +98,7 @@ void solveAny(Executor e, ArrayList results; void use(Integer x) { - if (results == null) results = new ArrayList(); + if (results == null) results = new ArrayList<>(); results.add(x); } diff --git a/test/jdk/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/test/jdk/java/util/concurrent/tck/ExecutorCompletionServiceTest.java index 2a936940c96..a4b623a6f3e 100644 --- a/test/jdk/java/util/concurrent/tck/ExecutorCompletionServiceTest.java +++ b/test/jdk/java/util/concurrent/tck/ExecutorCompletionServiceTest.java @@ -65,7 +65,7 @@ public static Test suite() { */ public void testConstructorNPE() { try { - new ExecutorCompletionService(null); + new ExecutorCompletionService(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -75,7 +75,7 @@ public void testConstructorNPE() { */ public void testConstructorNPE2() { try { - new ExecutorCompletionService(cachedThreadPool, null); + new ExecutorCompletionService(cachedThreadPool, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -84,9 +84,9 @@ public void testConstructorNPE2() { * ecs.submit(null) throws NullPointerException */ public void testSubmitNullCallable() { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); try { - cs.submit((Callable) null); + cs.submit((Callable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -95,7 +95,7 @@ public void testSubmitNullCallable() { * ecs.submit(null, val) throws NullPointerException */ public void testSubmitNullRunnable() { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); try { cs.submit((Runnable) null, Boolean.TRUE); shouldThrow(); @@ -106,9 +106,9 @@ public void testSubmitNullRunnable() { * A taken submitted task is completed */ public void testTake() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); cs.submit(new StringTask()); - Future f = cs.take(); + Future f = cs.take(); assertTrue(f.isDone()); assertSame(TEST_STRING, f.get()); } @@ -117,9 +117,9 @@ public void testTake() throws Exception { * Take returns the same future object returned by submit */ public void testTake2() throws InterruptedException { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); - Future f1 = cs.submit(new StringTask()); - Future f2 = cs.take(); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); + Future f1 = cs.submit(new StringTask()); + Future f2 = cs.take(); assertSame(f1, f2); } @@ -127,12 +127,12 @@ public void testTake2() throws InterruptedException { * poll returns non-null when the returned task is completed */ public void testPoll1() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); assertNull(cs.poll()); cs.submit(new StringTask()); long startTime = System.nanoTime(); - Future f; + Future f; while ((f = cs.poll()) == null) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) fail("timed out"); @@ -146,12 +146,12 @@ public void testPoll1() throws Exception { * timed poll returns non-null when the returned task is completed */ public void testPoll2() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); assertNull(cs.poll()); cs.submit(new StringTask()); long startTime = System.nanoTime(); - Future f; + Future f; while ((f = cs.poll(timeoutMillis(), MILLISECONDS)) == null) { assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); if (millisElapsedSince(startTime) > LONG_DELAY_MS) @@ -166,9 +166,9 @@ public void testPoll2() throws Exception { * poll returns null before the returned task is completed */ public void testPollReturnsNullBeforeCompletion() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); final CountDownLatch proceed = new CountDownLatch(1); - cs.submit(new Callable() { public String call() throws Exception { + cs.submit(new Callable() { public String call() throws Exception { await(proceed); return TEST_STRING; }}); @@ -186,7 +186,7 @@ public void testPollReturnsNullBeforeCompletion() throws Exception { * successful and failed tasks are both returned */ public void testTaskAssortment() throws Exception { - CompletionService cs = new ExecutorCompletionService(cachedThreadPool); + CompletionService cs = new ExecutorCompletionService<>(cachedThreadPool); ArithmeticException ex = new ArithmeticException(); final int rounds = 2; for (int i = rounds; i--> 0; ) { @@ -231,10 +231,10 @@ protected RunnableFuture newTaskFor(Callable c) { try (PoolCleaner cleaner = cleaner(e)) { assertNull(cs.poll()); Callable c = new StringTask(); - Future f1 = cs.submit(c); + Future f1 = cs.submit(c); assertTrue("submit must return MyCallableFuture", f1 instanceof MyCallableFuture); - Future f2 = cs.take(); + Future f2 = cs.take(); assertSame("submit and take must return same objects", f1, f2); assertTrue("completed task must have set done", done.get()); } @@ -261,10 +261,10 @@ protected RunnableFuture newTaskFor(Runnable t, T r) { try (PoolCleaner cleaner = cleaner(e)) { assertNull(cs.poll()); Runnable r = new NoOpRunnable(); - Future f1 = cs.submit(r, null); + Future f1 = cs.submit(r, null); assertTrue("submit must return MyRunnableFuture", f1 instanceof MyRunnableFuture); - Future f2 = cs.take(); + Future f2 = cs.take(); assertSame("submit and take must return same objects", f1, f2); assertTrue("completed task must have set done", done.get()); } diff --git a/test/jdk/java/util/concurrent/tck/ExecutorsTest.java b/test/jdk/java/util/concurrent/tck/ExecutorsTest.java index faf72c72929..a6d2186d3e6 100644 --- a/test/jdk/java/util/concurrent/tck/ExecutorsTest.java +++ b/test/jdk/java/util/concurrent/tck/ExecutorsTest.java @@ -90,7 +90,7 @@ public void testNewCachedThreadPool2() { */ public void testNewCachedThreadPool3() { try { - ExecutorService e = Executors.newCachedThreadPool(null); + ExecutorService unused = Executors.newCachedThreadPool(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -124,7 +124,7 @@ public void testNewSingleThreadExecutor2() { */ public void testNewSingleThreadExecutor3() { try { - ExecutorService e = Executors.newSingleThreadExecutor(null); + ExecutorService unused = Executors.newSingleThreadExecutor(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -172,7 +172,7 @@ public void testNewFixedThreadPool2() { */ public void testNewFixedThreadPool3() { try { - ExecutorService e = Executors.newFixedThreadPool(2, null); + ExecutorService unused = Executors.newFixedThreadPool(2, null); shouldThrow(); } catch (NullPointerException success) {} } @@ -182,7 +182,7 @@ public void testNewFixedThreadPool3() { */ public void testNewFixedThreadPool4() { try { - ExecutorService e = Executors.newFixedThreadPool(0); + ExecutorService unused = Executors.newFixedThreadPool(0); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -204,7 +204,8 @@ public void testUnconfigurableExecutorService() { */ public void testUnconfigurableExecutorServiceNPE() { try { - ExecutorService e = Executors.unconfigurableExecutorService(null); + ExecutorService unused = + Executors.unconfigurableExecutorService(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -214,7 +215,8 @@ public void testUnconfigurableExecutorServiceNPE() { */ public void testUnconfigurableScheduledExecutorServiceNPE() { try { - ExecutorService e = Executors.unconfigurableScheduledExecutorService(null); + ExecutorService unused = + Executors.unconfigurableScheduledExecutorService(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -231,7 +233,7 @@ public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -255,7 +257,7 @@ public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -281,7 +283,7 @@ public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -304,21 +306,24 @@ public void testTimedCallable() throws Exception { Executors.newScheduledThreadPool(2), }; - final Runnable sleeper = new CheckedInterruptedRunnable() { + final CountDownLatch done = new CountDownLatch(1); + + final Runnable sleeper = new CheckedRunnable() { public void realRun() throws InterruptedException { - delay(LONG_DELAY_MS); + done.await(LONG_DELAY_MS, MILLISECONDS); }}; List threads = new ArrayList<>(); for (final ExecutorService executor : executors) { threads.add(newStartedThread(new CheckedRunnable() { public void realRun() { - Future future = executor.submit(sleeper); + Future future = executor.submit(sleeper); assertFutureTimesOut(future); }})); } for (Thread thread : threads) awaitTermination(thread); + done.countDown(); for (ExecutorService executor : executors) joinPool(executor); } @@ -464,7 +469,7 @@ public void testPrivilegedCallableWithNoPrivs() throws Exception { public void realRun() throws Exception { if (System.getSecurityManager() == null) return; - Callable task = Executors.privilegedCallable(new CheckCCL()); + Callable task = Executors.privilegedCallable(new CheckCCL()); try { task.call(); shouldThrow(); @@ -543,7 +548,7 @@ public void realRun() throws Exception { * callable(Runnable) returns null when called */ public void testCallable1() throws Exception { - Callable c = Executors.callable(new NoOpRunnable()); + Callable c = Executors.callable(new NoOpRunnable()); assertNull(c.call()); } @@ -551,7 +556,7 @@ public void testCallable1() throws Exception { * callable(Runnable, result) returns result when called */ public void testCallable2() throws Exception { - Callable c = Executors.callable(new NoOpRunnable(), one); + Callable c = Executors.callable(new NoOpRunnable(), one); assertSame(one, c.call()); } @@ -559,7 +564,7 @@ public void testCallable2() throws Exception { * callable(PrivilegedAction) returns its result when called */ public void testCallable3() throws Exception { - Callable c = Executors.callable(new PrivilegedAction() { + Callable c = Executors.callable(new PrivilegedAction() { public Object run() { return one; }}); assertSame(one, c.call()); } @@ -568,7 +573,7 @@ public void testCallable3() throws Exception { * callable(PrivilegedExceptionAction) returns its result when called */ public void testCallable4() throws Exception { - Callable c = Executors.callable(new PrivilegedExceptionAction() { + Callable c = Executors.callable(new PrivilegedExceptionAction() { public Object run() { return one; }}); assertSame(one, c.call()); } @@ -578,7 +583,7 @@ public void testCallable4() throws Exception { */ public void testCallableNPE1() { try { - Callable c = Executors.callable((Runnable) null); + Callable unused = Executors.callable((Runnable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -588,7 +593,7 @@ public void testCallableNPE1() { */ public void testCallableNPE2() { try { - Callable c = Executors.callable((Runnable) null, one); + Callable unused = Executors.callable((Runnable) null, one); shouldThrow(); } catch (NullPointerException success) {} } @@ -598,7 +603,7 @@ public void testCallableNPE2() { */ public void testCallableNPE3() { try { - Callable c = Executors.callable((PrivilegedAction) null); + Callable unused = Executors.callable((PrivilegedAction) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -608,7 +613,7 @@ public void testCallableNPE3() { */ public void testCallableNPE4() { try { - Callable c = Executors.callable((PrivilegedExceptionAction) null); + Callable unused = Executors.callable((PrivilegedExceptionAction) null); shouldThrow(); } catch (NullPointerException success) {} } diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java index f8866a5fcfb..9be6ce3d418 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java @@ -86,13 +86,13 @@ public void testCommonPoolShutDown() { * checkInvoke. */ - private void checkInvoke(ForkJoinTask a) { + private void checkInvoke(ForkJoinTask a) { checkNotDone(a); assertNull(a.invoke()); checkCompletedNormally(a); } - void checkNotDone(ForkJoinTask a) { + void checkNotDone(ForkJoinTask a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -123,7 +123,7 @@ void checkNotDone(ForkJoinTask a) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedNormally(ForkJoinTask a) { + void checkCompletedNormally(ForkJoinTask a) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertTrue(a.isCompletedNormally()); @@ -143,7 +143,7 @@ void checkCompletedNormally(ForkJoinTask a) { assertNull(v2); } - void checkCancelled(ForkJoinTask a) { + void checkCancelled(ForkJoinTask a) { assertTrue(a.isDone()); assertTrue(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -170,7 +170,7 @@ void checkCancelled(ForkJoinTask a) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { + void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -766,7 +766,7 @@ protected void realCompute() { FibAction f = new FibAction(8); FibAction g = new FibAction(9); FibAction h = new FibAction(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -864,7 +864,7 @@ protected void realCompute() { FailingFibAction f = new FailingFibAction(8); FibAction g = new FibAction(9); FibAction h = new FibAction(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -880,17 +880,17 @@ protected void realCompute() { // CountedCompleter versions - abstract static class CCF extends CountedCompleter { + abstract static class CCF extends CountedCompleter { int number; int rnumber; - public CCF(CountedCompleter parent, int n) { + public CCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } public final void compute() { - CountedCompleter p; + CountedCompleter p; CCF f = this; int n = number; while (n >= 2) { @@ -907,10 +907,10 @@ public final void compute() { } static final class LCCF extends CCF { - public LCCF(CountedCompleter parent, int n) { + public LCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { CCF p = (CCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -923,7 +923,7 @@ static final class RCCF extends CCF { public RCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { CCF p = (CCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -934,17 +934,17 @@ public final void onCompletion(CountedCompleter caller) { } /** Version of CCF with forced failure in left completions. */ - abstract static class FailingCCF extends CountedCompleter { + abstract static class FailingCCF extends CountedCompleter { int number; int rnumber; - public FailingCCF(CountedCompleter parent, int n) { + public FailingCCF(CountedCompleter parent, int n) { super(parent, 1); this.number = n; } public final void compute() { - CountedCompleter p; + CountedCompleter p; FailingCCF f = this; int n = number; while (n >= 2) { @@ -961,10 +961,10 @@ public final void compute() { } static final class LFCCF extends FailingCCF { - public LFCCF(CountedCompleter parent, int n) { + public LFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { FailingCCF p = (FailingCCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -974,10 +974,10 @@ public final void onCompletion(CountedCompleter caller) { } } static final class RFCCF extends FailingCCF { - public RFCCF(CountedCompleter parent, int n) { + public RFCCF(CountedCompleter parent, int n) { super(parent, n); } - public final void onCompletion(CountedCompleter caller) { + public final void onCompletion(CountedCompleter caller) { completeExceptionally(new FJException()); } } @@ -988,7 +988,7 @@ public final void onCompletion(CountedCompleter caller) { * completed tasks; getRawResult returns null. */ public void testInvokeCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertNull(f.invoke()); @@ -1004,7 +1004,7 @@ protected void realCompute() { * completed tasks */ public void testQuietlyInvokeCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); f.quietlyInvoke(); @@ -1018,7 +1018,7 @@ protected void realCompute() { * join of a forked task returns when task completes */ public void testForkJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertSame(f, f.fork()); @@ -1033,7 +1033,7 @@ protected void realCompute() { * get of a forked task returns when task completes */ public void testForkGetCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(null, 8); assertSame(f, f.fork()); @@ -1048,7 +1048,7 @@ protected void realCompute() throws Exception { * timed get of a forked task returns when task completes */ public void testForkTimedGetCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(null, 8); assertSame(f, f.fork()); @@ -1063,7 +1063,7 @@ protected void realCompute() throws Exception { * timed get with null time unit throws NPE */ public void testForkTimedGetNPECC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(null, 8); assertSame(f, f.fork()); @@ -1079,7 +1079,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertSame(f, f.fork()); @@ -1094,7 +1094,7 @@ protected void realCompute() { * invoke task throws exception when task completes abnormally */ public void testAbnormalInvokeCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(null, 8); try { @@ -1111,7 +1111,7 @@ protected void realCompute() { * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvokeCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(null, 8); f.quietlyInvoke(); @@ -1125,7 +1125,7 @@ protected void realCompute() { * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(null, 8); assertSame(f, f.fork()); @@ -1143,7 +1143,7 @@ protected void realCompute() { * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGetCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(null, 8); assertSame(f, f.fork()); @@ -1163,7 +1163,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGetCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { FailingCCF f = new LFCCF(null, 8); assertSame(f, f.fork()); @@ -1183,7 +1183,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(null, 8); assertSame(f, f.fork()); @@ -1198,7 +1198,7 @@ protected void realCompute() { * invoke task throws exception when task cancelled */ public void testCancelledInvokeCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertTrue(f.cancel(true)); @@ -1216,7 +1216,7 @@ protected void realCompute() { * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertTrue(f.cancel(true)); @@ -1235,7 +1235,7 @@ protected void realCompute() { * get of a forked task throws exception when task cancelled */ public void testCancelledForkGetCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(null, 8); assertTrue(f.cancel(true)); @@ -1254,7 +1254,7 @@ protected void realCompute() throws Exception { * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGetCC() throws Exception { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws Exception { CCF f = new LCCF(null, 8); assertTrue(f.cancel(true)); @@ -1273,7 +1273,7 @@ protected void realCompute() throws Exception { * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoinCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); assertTrue(f.cancel(true)); @@ -1288,7 +1288,7 @@ protected void realCompute() { * getPool of non-FJ task returns null */ public void testGetPool2CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertNull(getPool()); }}; @@ -1299,7 +1299,7 @@ protected void realCompute() { * inForkJoinPool of non-FJ task returns false */ public void testInForkJoinPool2CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { assertFalse(inForkJoinPool()); }}; @@ -1310,7 +1310,7 @@ protected void realCompute() { * setRawResult(null) succeeds */ public void testSetRawResultCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { setRawResult(null); assertNull(getRawResult()); @@ -1322,7 +1322,7 @@ protected void realCompute() { * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionally2CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); f.completeExceptionally(new FJException()); @@ -1340,7 +1340,7 @@ protected void realCompute() { * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); CCF g = new LCCF(null, 9); @@ -1357,7 +1357,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); invokeAll(f); @@ -1371,7 +1371,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); CCF g = new LCCF(null, 9); @@ -1391,12 +1391,12 @@ protected void realCompute() { * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollectionCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); CCF g = new LCCF(null, 9); CCF h = new LCCF(null, 7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1415,7 +1415,7 @@ protected void realCompute() { * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPECC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); CCF g = new LCCF(null, 9); @@ -1432,7 +1432,7 @@ protected void realCompute() { * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); FailingCCF g = new LFCCF(null, 9); @@ -1450,7 +1450,7 @@ protected void realCompute() { * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF g = new LFCCF(null, 9); try { @@ -1467,7 +1467,7 @@ protected void realCompute() { * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3CC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { CCF f = new LCCF(null, 8); FailingCCF g = new LFCCF(null, 9); @@ -1486,12 +1486,12 @@ protected void realCompute() { * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollectionCC() { - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FailingCCF f = new LFCCF(null, 8); CCF g = new LCCF(null, 9); CCF h = new LCCF(null, 7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1514,7 +1514,7 @@ public void testAwaitQuiescence1() throws Exception { try (PoolCleaner cleaner = cleaner(p)) { final long startTime = System.nanoTime(); assertTrue(p.isQuiescent()); - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertSame(f, f.fork()); @@ -1573,7 +1573,7 @@ public void testAwaitQuiescence2() throws Exception { try (PoolCleaner cleaner = cleaner(p)) { assertTrue(p.isQuiescent()); final long startTime = System.nanoTime(); - ForkJoinTask a = new CheckedRecursiveAction() { + CheckedRecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); assertSame(f, f.fork()); diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPoolTest.java b/test/jdk/java/util/concurrent/tck/ForkJoinPoolTest.java index 56ffd3c4a7b..781b7bffe6d 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPoolTest.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPoolTest.java @@ -375,7 +375,7 @@ public void testSubmitAfterShutdown() { p.shutdown(); assertTrue(p.isShutdown()); try { - ForkJoinTask f = p.submit(new FibTask(8)); + ForkJoinTask unused = p.submit(new FibTask(8)); shouldThrow(); } catch (RejectedExecutionException success) {} } @@ -404,10 +404,10 @@ public void testPollSubmission() { final CountDownLatch done = new CountDownLatch(1); SubFJP p = new SubFJP(); try (PoolCleaner cleaner = cleaner(p)) { - ForkJoinTask a = p.submit(awaiter(done)); - ForkJoinTask b = p.submit(awaiter(done)); - ForkJoinTask c = p.submit(awaiter(done)); - ForkJoinTask r = p.pollSubmission(); + ForkJoinTask a = p.submit(awaiter(done)); + ForkJoinTask b = p.submit(awaiter(done)); + ForkJoinTask c = p.submit(awaiter(done)); + ForkJoinTask r = p.pollSubmission(); assertTrue(r == a || r == b || r == c); assertFalse(r.isDone()); done.countDown(); @@ -421,13 +421,13 @@ public void testDrainTasksTo() { final CountDownLatch done = new CountDownLatch(1); SubFJP p = new SubFJP(); try (PoolCleaner cleaner = cleaner(p)) { - ForkJoinTask a = p.submit(awaiter(done)); - ForkJoinTask b = p.submit(awaiter(done)); - ForkJoinTask c = p.submit(awaiter(done)); - ArrayList al = new ArrayList(); + ForkJoinTask a = p.submit(awaiter(done)); + ForkJoinTask b = p.submit(awaiter(done)); + ForkJoinTask c = p.submit(awaiter(done)); + ArrayList> al = new ArrayList<>(); p.drainTasksTo(al); assertTrue(al.size() > 0); - for (ForkJoinTask r : al) { + for (ForkJoinTask r : al) { assertTrue(r == a || r == b || r == c); assertFalse(r.isDone()); } @@ -499,13 +499,13 @@ public void testSubmitRunnable2() throws Throwable { * A submitted privileged action runs to completion */ public void testSubmitPrivilegedAction() throws Exception { - final Callable callable = Executors.callable(new PrivilegedAction() { + final Callable callable = Executors.callable(new PrivilegedAction() { public Object run() { return TEST_STRING; }}); Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(e)) { - Future future = e.submit(callable); + Future future = e.submit(callable); assertSame(TEST_STRING, future.get()); } }}; @@ -517,14 +517,14 @@ public void realRun() throws Exception { * A submitted privileged exception action runs to completion */ public void testSubmitPrivilegedExceptionAction() throws Exception { - final Callable callable = - Executors.callable(new PrivilegedExceptionAction() { + final Callable callable = + Executors.callable(new PrivilegedExceptionAction() { public Object run() { return TEST_STRING; }}); Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(e)) { - Future future = e.submit(callable); + Future future = e.submit(callable); assertSame(TEST_STRING, future.get()); } }}; @@ -536,14 +536,14 @@ public void realRun() throws Exception { * A submitted failed privileged exception action reports exception */ public void testSubmitFailedPrivilegedExceptionAction() throws Exception { - final Callable callable = - Executors.callable(new PrivilegedExceptionAction() { + final Callable callable = + Executors.callable(new PrivilegedExceptionAction() { public Object run() { throw new IndexOutOfBoundsException(); }}); Runnable r = new CheckedRunnable() { public void realRun() throws Exception { ExecutorService e = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(e)) { - Future future = e.submit(callable); + Future future = e.submit(callable); try { future.get(); shouldThrow(); @@ -563,7 +563,7 @@ public void testExecuteNullRunnable() { ExecutorService e = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(e)) { try { - Future future = e.submit((Runnable) null); + Future unused = e.submit((Runnable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -576,7 +576,7 @@ public void testSubmitNullCallable() { ExecutorService e = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(e)) { try { - Future future = e.submit((Callable) null); + Future unused = e.submit((Callable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -588,7 +588,7 @@ public void testSubmitNullCallable() { public void testInterruptedSubmit() throws InterruptedException { final CountDownLatch submitted = new CountDownLatch(1); final CountDownLatch quittingTime = new CountDownLatch(1); - final Callable awaiter = new CheckedCallable() { + final Callable awaiter = new CheckedCallable<>() { public Void realCall() throws InterruptedException { assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS)); return null; @@ -616,7 +616,7 @@ public void testSubmitEE() throws Throwable { ForkJoinPool p = new ForkJoinPool(1); try (PoolCleaner cleaner = cleaner(p)) { try { - p.submit(new Callable() { + p.submit(new Callable() { public Object call() { throw new ArithmeticException(); }}) .get(); shouldThrow(); diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinTask8Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinTask8Test.java index 633a01463c8..9c64f35a8f3 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinTask8Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinTask8Test.java @@ -118,7 +118,7 @@ private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) { } } - void checkNotDone(ForkJoinTask a) { + void checkNotDone(ForkJoinTask a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -179,7 +179,7 @@ void checkCompletedNormally(ForkJoinTask a, T expectedValue) { assertSame(expectedValue, v2); } - void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { + void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -950,7 +950,7 @@ public void testAbnormalInvokeAll2(ForkJoinPool pool) { protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); - ForkJoinTask[] tasks = { f, g }; + ForkJoinTask[] tasks = { f, g }; shuffle(tasks); try { invokeAll(tasks[0], tasks[1]); @@ -977,7 +977,7 @@ protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(tasks[0], tasks[1], tasks[2]); @@ -1004,7 +1004,7 @@ protected void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(Arrays.asList(tasks)); @@ -1199,9 +1199,9 @@ protected void realCompute() { */ public void testPollSubmission() { final CountDownLatch done = new CountDownLatch(1); - final ForkJoinTask a = ForkJoinTask.adapt(awaiter(done)); - final ForkJoinTask b = ForkJoinTask.adapt(awaiter(done)); - final ForkJoinTask c = ForkJoinTask.adapt(awaiter(done)); + final ForkJoinTask a = ForkJoinTask.adapt(awaiter(done)); + final ForkJoinTask b = ForkJoinTask.adapt(awaiter(done)); + final ForkJoinTask c = ForkJoinTask.adapt(awaiter(done)); final ForkJoinPool p = singletonPool(); try (PoolCleaner cleaner = cleaner(p, done)) { Thread external = new Thread(new CheckedRunnable() { @@ -1220,7 +1220,7 @@ protected void realCompute() { } assertTrue(p.hasQueuedSubmissions()); assertTrue(Thread.currentThread() instanceof ForkJoinWorkerThread); - ForkJoinTask r = ForkJoinTask.pollSubmission(); + ForkJoinTask r = ForkJoinTask.pollSubmission(); assertTrue(r == a || r == b || r == c); assertFalse(r.isDone()); }}; diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java b/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java index 16a043cd9d7..bc9dcf895ba 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java @@ -95,7 +95,7 @@ private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) { } } - void checkNotDone(ForkJoinTask a) { + void checkNotDone(ForkJoinTask a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -150,7 +150,7 @@ void checkCompletedNormally(ForkJoinTask a, T expectedValue) { assertSame(expectedValue, v2); } - void checkCancelled(ForkJoinTask a) { + void checkCancelled(ForkJoinTask a) { assertTrue(a.isDone()); assertTrue(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -187,7 +187,7 @@ void checkCancelled(ForkJoinTask a) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { + void checkCompletedAbnormally(ForkJoinTask a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -885,7 +885,7 @@ protected void realCompute() { AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -925,7 +925,7 @@ public void testAbnormalInvokeAll2() { protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); - ForkJoinTask[] tasks = { f, g }; + ForkJoinTask[] tasks = { f, g }; shuffle(tasks); try { invokeAll(tasks); @@ -963,7 +963,7 @@ protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(tasks); @@ -984,7 +984,7 @@ protected void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(Arrays.asList(tasks)); @@ -1554,7 +1554,7 @@ protected void realCompute() { AsyncFib f = new AsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1594,7 +1594,7 @@ public void testAbnormalInvokeAll2Singleton() { protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); - ForkJoinTask[] tasks = { f, g }; + ForkJoinTask[] tasks = { f, g }; shuffle(tasks); try { invokeAll(tasks); @@ -1632,7 +1632,7 @@ protected void realCompute() { AsyncFib f = new AsyncFib(8); FailingAsyncFib g = new FailingAsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(tasks); @@ -1653,7 +1653,7 @@ protected void realCompute() { FailingAsyncFib f = new FailingAsyncFib(8); AsyncFib g = new AsyncFib(9); AsyncFib h = new AsyncFib(7); - ForkJoinTask[] tasks = { f, g, h }; + ForkJoinTask[] tasks = { f, g, h }; shuffle(tasks); try { invokeAll(Arrays.asList(tasks)); @@ -1720,4 +1720,20 @@ public void testAdapt_Callable_toString() { task.toString()); } } + + // adaptInterruptible deferred to its own independent change + // https://bugs.openjdk.java.net/browse/JDK-8246587 + +// /** +// * adaptInterruptible(callable).toString() contains toString of wrapped task +// */ +// public void testAdaptInterruptible_Callable_toString() { +// if (testImplementationDetails) { +// Callable c = () -> ""; +// ForkJoinTask task = ForkJoinTask.adaptInterruptible(c); +// assertEquals( +// identityString(task) + "[Wrapped task = " + c.toString() + "]", +// task.toString()); +// } +// } } diff --git a/test/jdk/java/util/concurrent/tck/FutureTaskTest.java b/test/jdk/java/util/concurrent/tck/FutureTaskTest.java index 54025ec12bd..1d15380ecf9 100644 --- a/test/jdk/java/util/concurrent/tck/FutureTaskTest.java +++ b/test/jdk/java/util/concurrent/tck/FutureTaskTest.java @@ -117,7 +117,7 @@ void checkNotDone(Future f) { void checkIsRunning(Future f) { checkNotDone(f); if (f instanceof FutureTask) { - FutureTask ft = (FutureTask) f; + FutureTask ft = (FutureTask) f; // Check that run methods do nothing ft.run(); if (f instanceof PublicFutureTask) { @@ -191,7 +191,7 @@ void checkCompletedAbnormally(Future f, Throwable t) { /** * Subclass to expose protected methods */ - static class PublicFutureTask extends FutureTask { + static class PublicFutureTask extends FutureTask { private final AtomicInteger runCount; private final AtomicInteger doneCount = new AtomicInteger(0); private final AtomicInteger runAndResetCount = new AtomicInteger(0); @@ -218,12 +218,12 @@ public void run() { }}, result); this.runCount = runCount; } - PublicFutureTask(Callable callable) { + PublicFutureTask(Callable callable) { this(callable, new AtomicInteger(0)); } - private PublicFutureTask(final Callable callable, + private PublicFutureTask(final Callable callable, final AtomicInteger runCount) { - super(new Callable() { + super(new Callable() { public Object call() throws Exception { runCount.getAndIncrement(); return callable.call(); @@ -262,7 +262,7 @@ public void realRun() { */ public void testConstructor() { try { - new FutureTask(null); + new FutureTask(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -272,7 +272,7 @@ public void testConstructor() { */ public void testConstructor2() { try { - new FutureTask(null, Boolean.TRUE); + new FutureTask(null, Boolean.TRUE); shouldThrow(); } catch (NullPointerException success) {} } @@ -656,8 +656,7 @@ public void testTimedGet_Cancellation_interrupt() { public void testTimedGet_Cancellation(final boolean mayInterruptIfRunning) { final CountDownLatch pleaseCancel = new CountDownLatch(3); final CountDownLatch cancelled = new CountDownLatch(1); - final Callable callable = - new CheckedCallable() { + final Callable callable = new CheckedCallable<>() { public Object realCall() throws InterruptedException { pleaseCancel.countDown(); if (mayInterruptIfRunning) { @@ -704,7 +703,7 @@ public void realRun() throws Exception { */ public void testGet_ExecutionException() throws InterruptedException { final ArithmeticException e = new ArithmeticException(); - final PublicFutureTask task = new PublicFutureTask(new Callable() { + final PublicFutureTask task = new PublicFutureTask(new Callable() { public Object call() { throw e; }}); @@ -728,7 +727,7 @@ public Object call() { */ public void testTimedGet_ExecutionException2() throws Exception { final ArithmeticException e = new ArithmeticException(); - final PublicFutureTask task = new PublicFutureTask(new Callable() { + final PublicFutureTask task = new PublicFutureTask(new Callable() { public Object call() { throw e; }}); @@ -749,7 +748,7 @@ public Object call() { */ public void testGet_Interruptible() { final CountDownLatch pleaseInterrupt = new CountDownLatch(1); - final FutureTask task = new FutureTask(new NoOpCallable()); + final FutureTask task = new FutureTask<>(new NoOpCallable()); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws Exception { Thread.currentThread().interrupt(); @@ -778,7 +777,7 @@ public void realRun() throws Exception { */ public void testTimedGet_Interruptible() { final CountDownLatch pleaseInterrupt = new CountDownLatch(1); - final FutureTask task = new FutureTask(new NoOpCallable()); + final FutureTask task = new FutureTask<>(new NoOpCallable()); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws Exception { Thread.currentThread().interrupt(); @@ -807,7 +806,7 @@ public void realRun() throws Exception { * A timed out timed get throws TimeoutException */ public void testGet_TimeoutException() throws Exception { - FutureTask task = new FutureTask(new NoOpCallable()); + FutureTask task = new FutureTask<>(new NoOpCallable()); long startTime = System.nanoTime(); try { task.get(timeoutMillis(), MILLISECONDS); @@ -821,7 +820,7 @@ public void testGet_TimeoutException() throws Exception { * timed get with null TimeUnit throws NullPointerException */ public void testGet_NullTimeUnit() throws Exception { - FutureTask task = new FutureTask(new NoOpCallable()); + FutureTask task = new FutureTask<>(new NoOpCallable()); long[] timeouts = { Long.MIN_VALUE, 0L, Long.MAX_VALUE }; for (long timeout : timeouts) { diff --git a/test/jdk/java/util/concurrent/tck/Item.java b/test/jdk/java/util/concurrent/tck/Item.java new file mode 100644 index 00000000000..346407fc926 --- /dev/null +++ b/test/jdk/java/util/concurrent/tck/Item.java @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +import java.util.Comparator; +import java.io.Serializable; + +/** + * A simple element class for collections etc + */ +public final class Item extends Number implements Comparable, Serializable { + public final int value; + public Item(int v) { value = v; } + public Item(Item i) { value = i.value; } + public Item(Integer i) { value = i.intValue(); } + public static Item valueOf(int i) { return new Item(i); } + + public int intValue() { return value; } + public long longValue() { return (long)value; } + public float floatValue() { return (float)value; } + public double doubleValue() { return (double)value; } + + public boolean equals(Object x) { + return (x instanceof Item) && ((Item)x).value == value; + } + public boolean equals(int b) { + return value == b; + } + public int compareTo(Item x) { + return Integer.compare(this.value, x.value); + } + public int compareTo(int b) { + return Integer.compare(this.value, b); + } + + public int hashCode() { return value; } + public String toString() { return Integer.toString(value); } + public static int compare(Item x, Item y) { + return Integer.compare(x.value, y.value); + } + public static int compare(Item x, int b) { + return Integer.compare(x.value, b); + } + + public static Comparator comparator() { return new Cpr(); } + public static class Cpr implements Comparator { + public int compare(Item x, Item y) { + return Integer.compare(x.value, y.value); + } + } +} diff --git a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java index f10204afa58..1a5904832f8 100644 --- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java +++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java @@ -101,6 +101,7 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.PropertyPermission; +import java.util.Queue; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; @@ -177,6 +178,11 @@ * but even so, if there is ever any doubt, they can all be increased * in one spot to rerun tests on slower platforms. * + * Class Item is used for elements of collections and related + * purposes. Many tests rely on their keys being equal to ints. To + * check these, methods mustEqual, mustContain, etc adapt the JUnit + * assert methods to intercept ints. + * *
    8. All threads generated must be joined inside each test case * method (or {@code fail} to do so) before returning from the * method. The {@code joinPool} method can be used to do this when @@ -738,6 +744,7 @@ T chooseRandomly(List choices) { /** * Returns a random element from given choices. */ + @SuppressWarnings("unchecked") T chooseRandomly(T... choices) { return choices[ThreadLocalRandom.current().nextInt(choices.length)]; } @@ -1212,14 +1219,14 @@ String blockerClassName(Thread thread) { * Checks that future.get times out, with the default timeout of * {@code timeoutMillis()}. */ - void assertFutureTimesOut(Future future) { + void assertFutureTimesOut(Future future) { assertFutureTimesOut(future, timeoutMillis()); } /** * Checks that future.get times out, with the given millisecond timeout. */ - void assertFutureTimesOut(Future future, long timeoutMillis) { + void assertFutureTimesOut(Future future, long timeoutMillis) { long startTime = System.nanoTime(); try { future.get(timeoutMillis, MILLISECONDS); @@ -1227,8 +1234,9 @@ void assertFutureTimesOut(Future future, long timeoutMillis) { } catch (TimeoutException success) { } catch (Exception fail) { threadUnexpectedException(fail); - } finally { future.cancel(true); } + } assertTrue(millisElapsedSince(startTime) >= timeoutMillis); + assertFalse(future.isDone()); } /** @@ -1253,28 +1261,137 @@ public void shouldThrow(String exceptionName) { /** * The number of elements to place in collections, arrays, etc. - */ - public static final int SIZE = 20; - - // Some convenient Integer constants - - public static final Integer zero = new Integer(0); - public static final Integer one = new Integer(1); - public static final Integer two = new Integer(2); - public static final Integer three = new Integer(3); - public static final Integer four = new Integer(4); - public static final Integer five = new Integer(5); - public static final Integer six = new Integer(6); - public static final Integer seven = new Integer(7); - public static final Integer eight = new Integer(8); - public static final Integer nine = new Integer(9); - public static final Integer m1 = new Integer(-1); - public static final Integer m2 = new Integer(-2); - public static final Integer m3 = new Integer(-3); - public static final Integer m4 = new Integer(-4); - public static final Integer m5 = new Integer(-5); - public static final Integer m6 = new Integer(-6); - public static final Integer m10 = new Integer(-10); + * Must be at least ten; + */ + public static final int SIZE = 32; + + static Item[] seqItems(int size) { + Item[] s = new Item[size]; + for (int i = 0; i < size; ++i) + s[i] = new Item(i); + return s; + } + static Item[] negativeSeqItems(int size) { + Item[] s = new Item[size]; + for (int i = 0; i < size; ++i) + s[i] = new Item(-i); + return s; + } + + // Many tests rely on defaultItems all being sequential nonnegative + public static final Item[] defaultItems = seqItems(SIZE); + + static Item itemFor(int i) { // check cache for defaultItems + Item[] items = defaultItems; + return (i >= 0 && i < items.length) ? items[i] : new Item(i); + } + + public static final Item zero = defaultItems[0]; + public static final Item one = defaultItems[1]; + public static final Item two = defaultItems[2]; + public static final Item three = defaultItems[3]; + public static final Item four = defaultItems[4]; + public static final Item five = defaultItems[5]; + public static final Item six = defaultItems[6]; + public static final Item seven = defaultItems[7]; + public static final Item eight = defaultItems[8]; + public static final Item nine = defaultItems[9]; + public static final Item ten = defaultItems[10]; + + public static final Item[] negativeItems = negativeSeqItems(SIZE); + + public static final Item minusOne = negativeItems[1]; + public static final Item minusTwo = negativeItems[2]; + public static final Item minusThree = negativeItems[3]; + public static final Item minusFour = negativeItems[4]; + public static final Item minusFive = negativeItems[5]; + public static final Item minusSix = negativeItems[6]; + public static final Item minusSeven = negativeItems[7]; + public static final Item minusEight = negativeItems[8]; + public static final Item minusNone = negativeItems[9]; + public static final Item minusTen = negativeItems[10]; + + // elements expected to be missing + public static final Item fortytwo = new Item(42); + public static final Item eightysix = new Item(86); + public static final Item ninetynine = new Item(99); + + // Interop across Item, int + + static void mustEqual(Item x, Item y) { + if (x != y) + assertEquals(x.value, y.value); + } + static void mustEqual(Item x, int y) { + assertEquals(x.value, y); + } + static void mustEqual(int x, Item y) { + assertEquals(x, y.value); + } + static void mustEqual(int x, int y) { + assertEquals(x, y); + } + static void mustEqual(Object x, Object y) { + if (x != y) + assertEquals(x, y); + } + static void mustEqual(int x, Object y) { + if (y instanceof Item) + assertEquals(x, ((Item)y).value); + else fail(); + } + static void mustEqual(Object x, int y) { + if (x instanceof Item) + assertEquals(((Item)x).value, y); + else fail(); + } + static void mustEqual(boolean x, boolean y) { + assertEquals(x, y); + } + static void mustEqual(long x, long y) { + assertEquals(x, y); + } + static void mustEqual(double x, double y) { + assertEquals(x, y); + } + static void mustContain(Collection c, int i) { + assertTrue(c.contains(itemFor(i))); + } + static void mustContain(Collection c, Item i) { + assertTrue(c.contains(i)); + } + static void mustNotContain(Collection c, int i) { + assertFalse(c.contains(itemFor(i))); + } + static void mustNotContain(Collection c, Item i) { + assertFalse(c.contains(i)); + } + static void mustRemove(Collection c, int i) { + assertTrue(c.remove(itemFor(i))); + } + static void mustRemove(Collection c, Item i) { + assertTrue(c.remove(i)); + } + static void mustNotRemove(Collection c, int i) { + Item[] items = defaultItems; + Item x = (i >= 0 && i < items.length) ? items[i] : new Item(i); + assertFalse(c.remove(x)); + } + static void mustNotRemove(Collection c, Item i) { + assertFalse(c.remove(i)); + } + static void mustAdd(Collection c, int i) { + assertTrue(c.add(itemFor(i))); + } + static void mustAdd(Collection c, Item i) { + assertTrue(c.add(i)); + } + static void mustOffer(Queue c, int i) { + assertTrue(c.offer(itemFor(i))); + } + static void mustOffer(Queue c, Item i) { + assertTrue(c.offer(i)); + } /** * Runs Runnable r with a security policy that permits precisely @@ -1622,7 +1739,7 @@ public static class NoOpRunnable implements Runnable { public void run() {} } - public static class NoOpCallable implements Callable { + public static class NoOpCallable implements Callable { public Object call() { return Boolean.TRUE; } } @@ -1815,7 +1932,7 @@ public int await() { } } - void checkEmpty(BlockingQueue q) { + void checkEmpty(BlockingQueue q) { try { assertTrue(q.isEmpty()); assertEquals(0, q.size()); @@ -1862,6 +1979,7 @@ byte[] serialBytes(Object o) { } } + @SuppressWarnings("unchecked") void assertImmutable(Object o) { if (o instanceof Collection) { assertThrows( @@ -2011,7 +2129,7 @@ void assertNullTaskSubmissionThrowsNullPointerException(Executor e) { shouldThrow(); } catch (NullPointerException success) {} try { - es.submit((Callable) null); + es.submit((Callable) null); shouldThrow(); } catch (NullPointerException success) {} @@ -2023,7 +2141,7 @@ void assertNullTaskSubmissionThrowsNullPointerException(Executor e) { shouldThrow(); } catch (NullPointerException success) {} try { - ses.schedule((Callable) null, + ses.schedule((Callable) null, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (NullPointerException success) {} @@ -2182,7 +2300,7 @@ void assertCollectionsEquivalent(Collection x, Collection y) { else { assertEquals(x.isEmpty(), y.isEmpty()); assertEquals(x.size(), y.size()); - assertEquals(new HashSet(x), new HashSet(y)); + assertEquals(new HashSet(x), new HashSet(y)); if (x instanceof Deque) { assertTrue(Arrays.equals(x.toArray(), y.toArray())); assertTrue(Arrays.equals(x.toArray(new Object[0]), diff --git a/test/jdk/java/util/concurrent/tck/LinkedBlockingDeque8Test.java b/test/jdk/java/util/concurrent/tck/LinkedBlockingDeque8Test.java index cdcc7a27334..e6916cf85f2 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedBlockingDeque8Test.java +++ b/test/jdk/java/util/concurrent/tck/LinkedBlockingDeque8Test.java @@ -51,22 +51,22 @@ public static Test suite() { */ public void testSpliterator_getComparator() { assertThrows(IllegalStateException.class, - () -> new LinkedBlockingDeque().spliterator().getComparator()); + () -> new LinkedBlockingDeque().spliterator().getComparator()); } /** * Spliterator characteristics are as advertised */ public void testSpliterator_characteristics() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); - Spliterator s = q.spliterator(); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); + Spliterator s = q.spliterator(); int characteristics = s.characteristics(); int required = Spliterator.CONCURRENT | Spliterator.NONNULL | Spliterator.ORDERED; - assertEquals(required, characteristics & required); + mustEqual(required, characteristics & required); assertTrue(s.hasCharacteristics(required)); - assertEquals(0, characteristics + mustEqual(0, characteristics & (Spliterator.DISTINCT | Spliterator.IMMUTABLE | Spliterator.SORTED)); diff --git a/test/jdk/java/util/concurrent/tck/LinkedBlockingDequeTest.java b/test/jdk/java/util/concurrent/tck/LinkedBlockingDequeTest.java index 4bd098cd652..02b1b67d643 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedBlockingDequeTest.java +++ b/test/jdk/java/util/concurrent/tck/LinkedBlockingDequeTest.java @@ -71,7 +71,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return LinkedBlockingDeque.class; } public Collection emptyCollection() { return new LinkedBlockingDeque(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -83,19 +83,18 @@ class Implementation implements CollectionImplementation { /** * Returns a new deque of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static LinkedBlockingDeque populatedDeque(int n) { - LinkedBlockingDeque q = - new LinkedBlockingDeque(n); + private static LinkedBlockingDeque populatedDeque(int n) { + LinkedBlockingDeque q = new LinkedBlockingDeque<>(n); assertTrue(q.isEmpty()); for (int i = 0; i < n; i++) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peekFirst()); - assertEquals((Integer) (n - 1), q.peekLast()); + mustEqual(0, q.remainingCapacity()); + mustEqual(n, q.size()); + mustEqual(0, q.peekFirst()); + mustEqual((n - 1), q.peekLast()); return q; } @@ -103,11 +102,11 @@ private static LinkedBlockingDeque populatedDeque(int n) { * isEmpty is true before add, false after */ public void testEmpty() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + q.add(one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + q.add(two); q.removeFirst(); q.removeFirst(); assertTrue(q.isEmpty()); @@ -117,14 +116,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.removeFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, one); } } @@ -132,7 +131,7 @@ public void testSize() { * offerFirst(null) throws NullPointerException */ public void testOfferFirstNull() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); try { q.offerFirst(null); shouldThrow(); @@ -143,7 +142,7 @@ public void testOfferFirstNull() { * offerLast(null) throws NullPointerException */ public void testOfferLastNull() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); try { q.offerLast(null); shouldThrow(); @@ -154,27 +153,27 @@ public void testOfferLastNull() { * OfferFirst succeeds */ public void testOfferFirst() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); - assertTrue(q.offerFirst(new Integer(0))); - assertTrue(q.offerFirst(new Integer(1))); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); + assertTrue(q.offerFirst(zero)); + assertTrue(q.offerFirst(two)); } /** * OfferLast succeeds */ public void testOfferLast() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); - assertTrue(q.offerLast(new Integer(0))); - assertTrue(q.offerLast(new Integer(1))); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); + assertTrue(q.offerLast(zero)); + assertTrue(q.offerLast(one)); } /** * pollFirst succeeds unless empty */ public void testPollFirst() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -183,9 +182,9 @@ public void testPollFirst() { * pollLast succeeds unless empty */ public void testPollLast() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollLast()); } @@ -194,10 +193,10 @@ public void testPollLast() { * peekFirst returns next element, or null if empty */ public void testPeekFirst() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peekFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.peekFirst()); + mustEqual(i, q.pollFirst()); assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i)); } @@ -208,10 +207,10 @@ public void testPeekFirst() { * peek returns next element, or null if empty */ public void testPeek() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.peek()); + mustEqual(i, q.pollFirst()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -222,10 +221,10 @@ public void testPeek() { * peekLast returns next element, or null if empty */ public void testPeekLast() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.peekLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.peekLast()); + mustEqual(i, q.pollLast()); assertTrue(q.peekLast() == null || !q.peekLast().equals(i)); } @@ -236,10 +235,10 @@ public void testPeekLast() { * getFirst() returns first element, or throws NSEE if empty */ public void testFirstElement() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.getFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.getFirst()); + mustEqual(i, q.pollFirst()); } try { q.getFirst(); @@ -252,10 +251,10 @@ public void testFirstElement() { * getLast() returns last element, or throws NSEE if empty */ public void testLastElement() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.getLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.getLast()); + mustEqual(i, q.pollLast()); } try { q.getLast(); @@ -268,9 +267,9 @@ public void testLastElement() { * removeFirst() removes first element, or throws NSEE if empty */ public void testRemoveFirst() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.removeFirst()); + mustEqual(i, q.removeFirst()); } try { q.removeFirst(); @@ -283,9 +282,9 @@ public void testRemoveFirst() { * removeLast() removes last element, or throws NSEE if empty */ public void testRemoveLast() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.removeLast()); + mustEqual(i, q.removeLast()); } try { q.removeLast(); @@ -298,9 +297,9 @@ public void testRemoveLast() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -312,13 +311,13 @@ public void testRemove() { * removeFirstOccurrence(x) removes x and returns true if present */ public void testRemoveFirstOccurrence() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); - assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); + assertFalse(q.removeFirstOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } @@ -327,13 +326,13 @@ public void testRemoveFirstOccurrence() { * removeLastOccurrence(x) removes x and returns true if present */ public void testRemoveLastOccurrence() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); + assertTrue(q.removeLastOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); - assertFalse(q.removeLastOccurrence(new Integer(i + 1))); + assertTrue(q.removeLastOccurrence(itemFor(i))); + assertFalse(q.removeLastOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } @@ -342,7 +341,7 @@ public void testRemoveLastOccurrence() { * peekFirst returns element inserted with addFirst */ public void testAddFirst() { - LinkedBlockingDeque q = populatedDeque(3); + LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); q.addFirst(four); assertSame(four, q.peekFirst()); @@ -352,7 +351,7 @@ public void testAddFirst() { * peekLast returns element inserted with addLast */ public void testAddLast() { - LinkedBlockingDeque q = populatedDeque(3); + LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); q.addLast(four); assertSame(four, q.peekLast()); @@ -363,8 +362,8 @@ public void testAddLast() { * none given */ public void testConstructor1() { - assertEquals(SIZE, new LinkedBlockingDeque(SIZE).remainingCapacity()); - assertEquals(Integer.MAX_VALUE, new LinkedBlockingDeque().remainingCapacity()); + mustEqual(SIZE, new LinkedBlockingDeque(SIZE).remainingCapacity()); + mustEqual(Integer.MAX_VALUE, new LinkedBlockingDeque().remainingCapacity()); } /** @@ -372,7 +371,7 @@ public void testConstructor1() { */ public void testConstructor2() { try { - new LinkedBlockingDeque(0); + new LinkedBlockingDeque(0); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -382,7 +381,7 @@ public void testConstructor2() { */ public void testConstructor3() { try { - new LinkedBlockingDeque(null); + new LinkedBlockingDeque(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -391,9 +390,9 @@ public void testConstructor3() { * Initializing from Collection of null elements throws NullPointerException */ public void testConstructor4() { - Collection elements = Arrays.asList(new Integer[SIZE]); + Collection elements = Arrays.asList(new Item[SIZE]); try { - new LinkedBlockingDeque(elements); + new LinkedBlockingDeque(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -403,12 +402,11 @@ public void testConstructor4() { * NullPointerException */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = i; - Collection elements = Arrays.asList(ints); + Item[] items = new Item[2]; + items[0] = zero; + Collection elements = Arrays.asList(items); try { - new LinkedBlockingDeque(elements); + new LinkedBlockingDeque(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -417,26 +415,24 @@ public void testConstructor5() { * Deque contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = i; - LinkedBlockingDeque q = new LinkedBlockingDeque(Arrays.asList(ints)); + Item[] items = defaultItems; + LinkedBlockingDeque q = new LinkedBlockingDeque<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * Deque transitions from empty to full when elements added */ public void testEmptyFull() { - LinkedBlockingDeque q = new LinkedBlockingDeque(2); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); assertTrue(q.isEmpty()); - assertEquals("should have room for 2", 2, q.remainingCapacity()); + mustEqual(2, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); q.add(two); assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); assertFalse(q.offer(three)); } @@ -444,16 +440,16 @@ public void testEmptyFull() { * remainingCapacity decreases on add, increases on remove */ public void testRemainingCapacity() { - BlockingQueue q = populatedDeque(SIZE); + BlockingQueue q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remainingCapacity()); - assertEquals(SIZE, q.size() + q.remainingCapacity()); - assertEquals(i, q.remove()); + mustEqual(i, q.remainingCapacity()); + mustEqual(SIZE, q.size() + q.remainingCapacity()); + mustEqual(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.remainingCapacity()); - assertEquals(SIZE, q.size() + q.remainingCapacity()); - assertTrue(q.add(i)); + mustEqual(SIZE - i, q.remainingCapacity()); + mustEqual(SIZE, q.size() + q.remainingCapacity()); + mustAdd(q, i); } } @@ -461,7 +457,7 @@ public void testRemainingCapacity() { * push(null) throws NPE */ public void testPushNull() { - LinkedBlockingDeque q = new LinkedBlockingDeque(1); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(1); try { q.push(null); shouldThrow(); @@ -472,15 +468,15 @@ public void testPushNull() { * push succeeds if not full; throws IllegalStateException if full */ public void testPush() { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.push(x); - assertEquals(x, q.peek()); + mustEqual(x, q.peek()); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); try { - q.push(new Integer(SIZE)); + q.push(itemFor(SIZE)); shouldThrow(); } catch (IllegalStateException success) {} } @@ -489,7 +485,7 @@ public void testPush() { * peekFirst returns element inserted with push */ public void testPushWithPeek() { - LinkedBlockingDeque q = populatedDeque(3); + LinkedBlockingDeque q = populatedDeque(3); q.pollLast(); q.push(four); assertSame(four, q.peekFirst()); @@ -499,9 +495,9 @@ public void testPushWithPeek() { * pop removes next element, or throws NSEE if empty */ public void testPop() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pop()); + mustEqual(i, q.pop()); } try { q.pop(); @@ -513,7 +509,7 @@ public void testPop() { * Offer succeeds if not full; fails if full */ public void testOffer() { - LinkedBlockingDeque q = new LinkedBlockingDeque(1); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(1); assertTrue(q.offer(zero)); assertFalse(q.offer(one)); } @@ -522,12 +518,12 @@ public void testOffer() { * add succeeds if not full; throws IllegalStateException if full */ public void testAdd() { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) - assertTrue(q.add(new Integer(i))); - assertEquals(0, q.remainingCapacity()); + mustAdd(q, i); + mustEqual(0, q.remainingCapacity()); try { - q.add(new Integer(SIZE)); + q.add(itemFor(SIZE)); shouldThrow(); } catch (IllegalStateException success) {} } @@ -536,7 +532,7 @@ public void testAdd() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); try { q.addAll(q); shouldThrow(); @@ -548,11 +544,9 @@ public void testAddAllSelf() { * possibly adding some elements */ public void testAddAll3() { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); - Collection elements = Arrays.asList(ints); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); + Item[] items = new Item[2]; items[0] = zero; + Collection elements = Arrays.asList(items); try { q.addAll(elements); shouldThrow(); @@ -563,11 +557,9 @@ public void testAddAll3() { * addAll throws IllegalStateException if not enough room */ public void testAddAll4() { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE - 1); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - Collection elements = Arrays.asList(ints); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE - 1); + Item[] items = defaultItems; + Collection elements = Arrays.asList(items); try { q.addAll(elements); shouldThrow(); @@ -578,53 +570,51 @@ public void testAddAll4() { * Deque contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * all elements successfully put are contained */ public void testPut() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.put(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * put blocks interruptibly if full */ public void testBlockingPut() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) - q.put(i); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + q.put(itemFor(i)); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -634,8 +624,8 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); } /** @@ -643,67 +633,67 @@ public void realRun() throws InterruptedException { */ public void testPutWithTake() throws InterruptedException { final int capacity = 2; - final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(capacity); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < capacity; i++) - q.put(i); + q.put(itemFor(i)); pleaseTake.countDown(); - q.put(86); + q.put(eightysix); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); - assertEquals(0, q.take()); + mustEqual(0, q.remainingCapacity()); + mustEqual(0, q.take()); await(pleaseInterrupt); if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * timed offer times out if full and elements not taken */ public void testTimedOffer() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Object()); - q.put(new Object()); + q.put(zero); + q.put(one); long startTime = System.nanoTime(); - assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offer(two, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offer(new Object(), randomTimeout(), randomTimeUnit()); + q.offer(three, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.offer(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offer(four, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -719,9 +709,9 @@ public void realRun() throws InterruptedException { * take retrieves elements in FIFO order */ public void testTake() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.take()); + mustEqual(i, q.take()); } } @@ -729,11 +719,11 @@ public void testTake() throws InterruptedException { * take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.take()); Thread.currentThread().interrupt(); try { @@ -760,9 +750,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -771,9 +761,9 @@ public void testPoll() { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll(0, MILLISECONDS)); + mustEqual(i, q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); } @@ -782,10 +772,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -799,12 +789,12 @@ public void testTimedPoll() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - final BlockingQueue q = populatedDeque(SIZE); + final BlockingQueue q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -832,7 +822,7 @@ public void realRun() throws InterruptedException { * putFirst(null) throws NPE */ public void testPutFirstNull() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); try { q.putFirst(null); shouldThrow(); @@ -843,38 +833,38 @@ public void testPutFirstNull() throws InterruptedException { * all elements successfully putFirst are contained */ public void testPutFirst() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.putFirst(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * putFirst blocks interruptibly if full */ public void testBlockingPutFirst() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) - q.putFirst(i); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + q.putFirst(itemFor(i)); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); Thread.currentThread().interrupt(); try { - q.putFirst(99); + q.putFirst(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.putFirst(99); + q.putFirst(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -884,8 +874,8 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); } /** @@ -893,60 +883,60 @@ public void realRun() throws InterruptedException { */ public void testPutFirstWithTake() throws InterruptedException { final int capacity = 2; - final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(capacity); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < capacity; i++) - q.putFirst(i); + q.putFirst(itemFor(i)); pleaseTake.countDown(); - q.putFirst(86); + q.putFirst(eightysix); pleaseInterrupt.countDown(); try { - q.putFirst(99); + q.putFirst(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); - assertEquals(capacity - 1, q.take()); + mustEqual(0, q.remainingCapacity()); + mustEqual(capacity - 1, q.take()); await(pleaseInterrupt); if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * timed offerFirst times out if full and elements not taken */ public void testTimedOfferFirst() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.putFirst(new Object()); - q.putFirst(new Object()); + q.putFirst(zero); + q.putFirst(one); long startTime = System.nanoTime(); - assertFalse(q.offerFirst(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offerFirst(two, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offerFirst(new Object(), randomTimeout(), randomTimeUnit()); + q.offerFirst(three, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.offerFirst(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offerFirst(four, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -962,9 +952,9 @@ public void realRun() throws InterruptedException { * take retrieves elements in FIFO order */ public void testTakeFirst() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.takeFirst()); + mustEqual(i, q.takeFirst()); } } @@ -972,7 +962,7 @@ public void testTakeFirst() throws InterruptedException { * takeFirst() blocks interruptibly when empty */ public void testTakeFirstFromEmptyBlocksInterruptibly() { - final BlockingDeque q = new LinkedBlockingDeque(); + final BlockingDeque q = new LinkedBlockingDeque<>(); final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { @@ -995,7 +985,7 @@ public void realRun() { * before waiting */ public void testTakeFirstFromEmptyAfterInterrupt() { - final BlockingDeque q = new LinkedBlockingDeque(); + final BlockingDeque q = new LinkedBlockingDeque<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { Thread.currentThread().interrupt(); @@ -1013,7 +1003,7 @@ public void realRun() { * takeLast() blocks interruptibly when empty */ public void testTakeLastFromEmptyBlocksInterruptibly() { - final BlockingDeque q = new LinkedBlockingDeque(); + final BlockingDeque q = new LinkedBlockingDeque<>(); final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { @@ -1036,7 +1026,7 @@ public void realRun() { * before waiting */ public void testTakeLastFromEmptyAfterInterrupt() { - final BlockingDeque q = new LinkedBlockingDeque(); + final BlockingDeque q = new LinkedBlockingDeque<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { Thread.currentThread().interrupt(); @@ -1054,11 +1044,11 @@ public void realRun() { * takeFirst removes existing elements until empty, then blocks interruptibly */ public void testBlockingTakeFirst() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.takeFirst()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.takeFirst()); Thread.currentThread().interrupt(); try { @@ -1085,9 +1075,9 @@ public void realRun() throws InterruptedException { * timed pollFirst with zero timeout succeeds when non-empty, else times out */ public void testTimedPollFirst0() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst(0, MILLISECONDS)); + mustEqual(i, q.pollFirst(0, MILLISECONDS)); } assertNull(q.pollFirst(0, MILLISECONDS)); } @@ -1096,10 +1086,10 @@ public void testTimedPollFirst0() throws InterruptedException { * timed pollFirst with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPollFirst() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -1113,12 +1103,12 @@ public void testTimedPollFirst() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPollFirst() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -1146,7 +1136,7 @@ public void realRun() throws InterruptedException { * on interruption throws */ public void testTimedPollFirstWithOfferFirst() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CheckedBarrier barrier = new CheckedBarrier(2); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -1188,7 +1178,7 @@ public void realRun() throws InterruptedException { * putLast(null) throws NPE */ public void testPutLastNull() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); try { q.putLast(null); shouldThrow(); @@ -1199,38 +1189,38 @@ public void testPutLastNull() throws InterruptedException { * all elements successfully putLast are contained */ public void testPutLast() throws InterruptedException { - LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.putLast(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * putLast blocks interruptibly if full */ public void testBlockingPutLast() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) - q.putLast(i); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + q.putLast(itemFor(i)); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); Thread.currentThread().interrupt(); try { - q.putLast(99); + q.putLast(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.putLast(99); + q.putLast(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -1240,8 +1230,8 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); } /** @@ -1249,66 +1239,66 @@ public void realRun() throws InterruptedException { */ public void testPutLastWithTake() throws InterruptedException { final int capacity = 2; - final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(capacity); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < capacity; i++) - q.putLast(i); + q.putLast(itemFor(i)); pleaseTake.countDown(); - q.putLast(86); + q.putLast(eightysix); Thread.currentThread().interrupt(); try { - q.putLast(99); + q.putLast(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.putLast(99); + q.putLast(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); - assertEquals(0, q.take()); + mustEqual(0, q.remainingCapacity()); + mustEqual(0, q.take()); await(pleaseInterrupt); if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * timed offerLast times out if full and elements not taken */ public void testTimedOfferLast() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.putLast(new Object()); - q.putLast(new Object()); + q.putLast(zero); + q.putLast(one); long startTime = System.nanoTime(); - assertFalse(q.offerLast(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offerLast(two, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offerLast(new Object(), randomTimeout(), randomTimeUnit()); + q.offerLast(three, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} pleaseInterrupt.countDown(); try { - q.offerLast(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offerLast(four, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} }}); @@ -1323,9 +1313,9 @@ public void realRun() throws InterruptedException { * takeLast retrieves elements in FIFO order */ public void testTakeLast() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i - 1, q.takeLast()); + mustEqual(SIZE - i - 1, q.takeLast()); } } @@ -1333,12 +1323,12 @@ public void testTakeLast() throws InterruptedException { * takeLast removes existing elements until empty, then blocks interruptibly */ public void testBlockingTakeLast() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(SIZE - i - 1, q.takeLast()); + mustEqual(SIZE - i - 1, q.takeLast()); Thread.currentThread().interrupt(); try { @@ -1365,9 +1355,9 @@ public void realRun() throws InterruptedException { * timed pollLast with zero timeout succeeds when non-empty, else times out */ public void testTimedPollLast0() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i - 1, q.pollLast(0, MILLISECONDS)); + mustEqual(SIZE - i - 1, q.pollLast(0, MILLISECONDS)); } assertNull(q.pollLast(0, MILLISECONDS)); } @@ -1376,10 +1366,10 @@ public void testTimedPollLast0() throws InterruptedException { * timed pollLast with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPollLast() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(SIZE - i - 1, q.pollLast(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(SIZE - i - 1, q.pollLast(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -1393,12 +1383,12 @@ public void testTimedPollLast() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPollLast() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(SIZE - i - 1, + mustEqual(SIZE - i - 1, q.pollLast(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); @@ -1428,7 +1418,7 @@ public void realRun() throws InterruptedException { * on interruption throws */ public void testTimedPollWithOfferLast() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CheckedBarrier barrier = new CheckedBarrier(2); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -1472,9 +1462,9 @@ public void realRun() throws InterruptedException { * element returns next element, or throws NSEE if empty */ public void testElement() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); + mustEqual(i, q.element()); q.poll(); } try { @@ -1487,11 +1477,11 @@ public void testElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -1499,14 +1489,14 @@ public void testContains() { * clear removes all elements */ public void testClear() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(SIZE, q.remainingCapacity()); + mustEqual(0, q.size()); + mustEqual(SIZE, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); + mustContain(q, one); q.clear(); assertTrue(q.isEmpty()); } @@ -1515,12 +1505,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - LinkedBlockingDeque q = populatedDeque(SIZE); - LinkedBlockingDeque p = new LinkedBlockingDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque p = new LinkedBlockingDeque<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -1529,8 +1519,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - LinkedBlockingDeque q = populatedDeque(SIZE); - LinkedBlockingDeque p = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque p = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -1539,7 +1529,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -1549,13 +1539,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - LinkedBlockingDeque q = populatedDeque(SIZE); - LinkedBlockingDeque p = populatedDeque(i); + LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque p = populatedDeque(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + mustNotContain(q, p.remove()); } } } @@ -1564,7 +1553,7 @@ public void testRemoveAll() { * toArray contains all elements in FIFO order */ public void testToArray() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -1576,11 +1565,11 @@ public void testToArray() throws InterruptedException { * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - LinkedBlockingDeque q = populatedDeque(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + LinkedBlockingDeque q = populatedDeque(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.remove()); assertTrue(q.isEmpty()); } @@ -1588,8 +1577,9 @@ public void testToArray2() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - LinkedBlockingDeque q = populatedDeque(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + LinkedBlockingDeque q = populatedDeque(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -1600,18 +1590,18 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() throws InterruptedException { - LinkedBlockingDeque q = populatedDeque(SIZE); - Iterator it = q.iterator(); + LinkedBlockingDeque q = populatedDeque(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); it = q.iterator(); for (i = 0; it.hasNext(); i++) - assertEquals(it.next(), q.take()); - assertEquals(i, SIZE); + mustEqual(it.next(), q.take()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -1619,7 +1609,7 @@ public void testIterator() throws InterruptedException { * iterator of empty collection has no elements */ public void testEmptyIterator() { - Deque c = new LinkedBlockingDeque(); + Deque c = new LinkedBlockingDeque<>(); assertIteratorExhausted(c.iterator()); assertIteratorExhausted(c.descendingIterator()); } @@ -1628,12 +1618,12 @@ public void testEmptyIterator() { * iterator.remove removes current element */ public void testIteratorRemove() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(3); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(3); q.add(two); q.add(one); q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); @@ -1647,45 +1637,45 @@ public void testIteratorRemove() { * iterator ordering is FIFO */ public void testIteratorOrdering() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(3); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(3); q.add(one); q.add(two); q.add(three); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(3); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(3); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals(0, q.size()); + mustEqual(0, q.size()); } /** * Descending iterator iterates through all elements */ public void testDescendingIterator() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); int i = 0; - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertFalse(it.hasNext()); try { it.next(); @@ -1697,17 +1687,18 @@ public void testDescendingIterator() { * Descending iterator ordering is reverse FIFO */ public void testDescendingIteratorOrdering() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(); for (int iters = 0; iters < 100; ++iters) { - q.add(new Integer(3)); - q.add(new Integer(2)); - q.add(new Integer(1)); + mustAdd(q, three); + mustAdd(q, two); + mustAdd(q, one); + int k = 0; - for (Iterator it = q.descendingIterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.descendingIterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); q.remove(); q.remove(); q.remove(); @@ -1718,18 +1709,18 @@ public void testDescendingIteratorOrdering() { * descendingIterator.remove removes current element */ public void testDescendingIteratorRemove() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(); for (int iters = 0; iters < 100; ++iters) { - q.add(new Integer(3)); - q.add(new Integer(2)); - q.add(new Integer(1)); - Iterator it = q.descendingIterator(); - assertEquals(it.next(), new Integer(1)); + mustAdd(q, three); + mustAdd(q, two); + mustAdd(q, one); + Iterator it = q.descendingIterator(); + mustEqual(it.next(), one); it.remove(); - assertEquals(it.next(), new Integer(2)); + mustEqual(it.next(), two); it = q.descendingIterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); it.remove(); assertFalse(it.hasNext()); q.remove(); @@ -1740,7 +1731,7 @@ public void testDescendingIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - LinkedBlockingDeque q = populatedDeque(SIZE); + LinkedBlockingDeque q = populatedDeque(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -1751,7 +1742,7 @@ public void testToString() { * offer transfers elements across Executor tasks */ public void testOfferInExecutor() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); q.add(one); q.add(two); final CheckedBarrier threadsStarted = new CheckedBarrier(2); @@ -1762,7 +1753,7 @@ public void realRun() throws InterruptedException { assertFalse(q.offer(three)); threadsStarted.await(); assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); }}); executor.execute(new CheckedRunnable() { @@ -1777,7 +1768,7 @@ public void realRun() throws InterruptedException { * timed poll retrieves elements across Executor threads */ public void testPollInExecutor() { - final LinkedBlockingDeque q = new LinkedBlockingDeque(2); + final LinkedBlockingDeque q = new LinkedBlockingDeque<>(2); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -1801,16 +1792,16 @@ public void realRun() throws InterruptedException { * A deserialized/reserialized deque has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedDeque(SIZE); - Queue y = serialClone(x); + Queue x = populatedDeque(SIZE); + Queue y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -1819,42 +1810,42 @@ public void testSerialization() throws Exception { * drainTo(c) empties deque into another collection c */ public void testDrainTo() { - LinkedBlockingDeque q = populatedDeque(SIZE); - ArrayList l = new ArrayList(); + LinkedBlockingDeque q = populatedDeque(SIZE); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(SIZE, l.size()); + mustEqual(0, q.size()); + mustEqual(SIZE, l.size()); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); q.add(zero); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); + mustContain(q, zero); + mustContain(q, one); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); } /** * drainTo empties full deque, unblocking a waiting put. */ public void testDrainToWithActivePut() throws InterruptedException { - final LinkedBlockingDeque q = populatedDeque(SIZE); + final LinkedBlockingDeque q = populatedDeque(SIZE); Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Integer(SIZE + 1)); + q.put(new Item(SIZE + 1)); }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); t.join(); assertTrue(q.size() + l.size() >= SIZE); } @@ -1863,17 +1854,17 @@ public void realRun() throws InterruptedException { * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - LinkedBlockingDeque q = new LinkedBlockingDeque(); + LinkedBlockingDeque q = new LinkedBlockingDeque<>(); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); + mustOffer(q, j); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(k, l.size()); - assertEquals(SIZE - k, q.size()); + mustEqual(k, l.size()); + mustEqual(SIZE - k, q.size()); for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); + mustEqual(l.get(j), j); do {} while (q.poll() != null); } } @@ -1883,7 +1874,7 @@ public void testDrainToN() { */ public void testNeverContainsNull() { Deque[] qs = { - new LinkedBlockingDeque(), + new LinkedBlockingDeque<>(), populatedDeque(2), }; diff --git a/test/jdk/java/util/concurrent/tck/LinkedBlockingQueue8Test.java b/test/jdk/java/util/concurrent/tck/LinkedBlockingQueue8Test.java index 2c3e498aeaa..4c789615b4e 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedBlockingQueue8Test.java +++ b/test/jdk/java/util/concurrent/tck/LinkedBlockingQueue8Test.java @@ -51,22 +51,22 @@ public static Test suite() { */ public void testSpliterator_getComparator() { assertThrows(IllegalStateException.class, - () -> new LinkedBlockingQueue().spliterator().getComparator()); + () -> new LinkedBlockingQueue().spliterator().getComparator()); } /** * Spliterator characteristics are as advertised */ public void testSpliterator_characteristics() { - LinkedBlockingQueue q = new LinkedBlockingQueue(); - Spliterator s = q.spliterator(); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(); + Spliterator s = q.spliterator(); int characteristics = s.characteristics(); int required = Spliterator.CONCURRENT | Spliterator.NONNULL | Spliterator.ORDERED; - assertEquals(required, characteristics & required); + mustEqual(required, characteristics & required); assertTrue(s.hasCharacteristics(required)); - assertEquals(0, characteristics + mustEqual(0, characteristics & (Spliterator.DISTINCT | Spliterator.IMMUTABLE | Spliterator.SORTED)); diff --git a/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java b/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java index 709b7eac122..c42f5384187 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java @@ -71,7 +71,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return LinkedBlockingQueue.class; } public Collection emptyCollection() { return new LinkedBlockingQueue(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -83,17 +83,17 @@ class Implementation implements CollectionImplementation { /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static LinkedBlockingQueue populatedQueue(int n) { - LinkedBlockingQueue q = new LinkedBlockingQueue<>(n); + private static LinkedBlockingQueue populatedQueue(int n) { + LinkedBlockingQueue q = new LinkedBlockingQueue<>(n); assertTrue(q.isEmpty()); for (int i = 0; i < n; i++) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peek()); + mustEqual(0, q.remainingCapacity()); + mustEqual(n, q.size()); + mustEqual(0, q.peek()); return q; } @@ -102,8 +102,8 @@ private static LinkedBlockingQueue populatedQueue(int n) { * none given */ public void testConstructor1() { - assertEquals(SIZE, new LinkedBlockingQueue(SIZE).remainingCapacity()); - assertEquals(Integer.MAX_VALUE, new LinkedBlockingQueue().remainingCapacity()); + mustEqual(SIZE, new LinkedBlockingQueue(SIZE).remainingCapacity()); + mustEqual(Integer.MAX_VALUE, new LinkedBlockingQueue().remainingCapacity()); } /** @@ -111,7 +111,7 @@ public void testConstructor1() { */ public void testConstructor2() { try { - new LinkedBlockingQueue(0); + new LinkedBlockingQueue(0); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -121,7 +121,7 @@ public void testConstructor2() { */ public void testConstructor3() { try { - new LinkedBlockingQueue(null); + new LinkedBlockingQueue(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -130,9 +130,9 @@ public void testConstructor3() { * Initializing from Collection of null elements throws NullPointerException */ public void testConstructor4() { - Collection elements = Arrays.asList(new Integer[SIZE]); + Collection elements = Arrays.asList(new Item[SIZE]); try { - new LinkedBlockingQueue(elements); + new LinkedBlockingQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -142,12 +142,11 @@ public void testConstructor4() { * NullPointerException */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); - Collection elements = Arrays.asList(ints); + Item[] items = new Item[2]; + items[0] = zero; + Collection elements = Arrays.asList(items); try { - new LinkedBlockingQueue(elements); + new LinkedBlockingQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -156,26 +155,24 @@ public void testConstructor5() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + LinkedBlockingQueue q = new LinkedBlockingQueue<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * Queue transitions from empty to full when elements added */ public void testEmptyFull() { - LinkedBlockingQueue q = new LinkedBlockingQueue(2); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(2); assertTrue(q.isEmpty()); - assertEquals("should have room for 2", 2, q.remainingCapacity()); + mustEqual(2, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); q.add(two); assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); assertFalse(q.offer(three)); } @@ -183,16 +180,16 @@ public void testEmptyFull() { * remainingCapacity decreases on add, increases on remove */ public void testRemainingCapacity() { - BlockingQueue q = populatedQueue(SIZE); + BlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remainingCapacity()); - assertEquals(SIZE, q.size() + q.remainingCapacity()); - assertEquals(i, q.remove()); + mustEqual(i, q.remainingCapacity()); + mustEqual(SIZE, q.size() + q.remainingCapacity()); + mustEqual(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.remainingCapacity()); - assertEquals(SIZE, q.size() + q.remainingCapacity()); - assertTrue(q.add(i)); + mustEqual(SIZE - i, q.remainingCapacity()); + mustEqual(SIZE, q.size() + q.remainingCapacity()); + mustAdd(q, i); } } @@ -200,7 +197,7 @@ public void testRemainingCapacity() { * Offer succeeds if not full; fails if full */ public void testOffer() { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(1); assertTrue(q.offer(zero)); assertFalse(q.offer(one)); } @@ -209,12 +206,12 @@ public void testOffer() { * add succeeds if not full; throws IllegalStateException if full */ public void testAdd() { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) - assertTrue(q.add(new Integer(i))); - assertEquals(0, q.remainingCapacity()); + mustAdd(q, i); + mustEqual(0, q.remainingCapacity()); try { - q.add(new Integer(SIZE)); + q.add(new Item(SIZE)); shouldThrow(); } catch (IllegalStateException success) {} } @@ -223,7 +220,7 @@ public void testAdd() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -235,11 +232,9 @@ public void testAddAllSelf() { * possibly adding some elements */ public void testAddAll3() { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); - Collection elements = Arrays.asList(ints); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE); + Item[] items = new Item[2]; items[0] = zero; + Collection elements = Arrays.asList(items); try { q.addAll(elements); shouldThrow(); @@ -250,11 +245,9 @@ public void testAddAll3() { * addAll throws IllegalStateException if not enough room */ public void testAddAll4() { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE - 1); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - Collection elements = Arrays.asList(ints); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE - 1); + Item[] items = defaultItems; + Collection elements = Arrays.asList(items); try { q.addAll(elements); shouldThrow(); @@ -265,53 +258,51 @@ public void testAddAll4() { * Queue contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * all elements successfully put are contained */ public void testPut() throws InterruptedException { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.put(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * put blocks interruptibly if full */ public void testBlockingPut() throws InterruptedException { - final LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; ++i) - q.put(i); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + q.put(itemFor(i)); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -321,8 +312,8 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(SIZE, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(SIZE, q.size()); + mustEqual(0, q.remainingCapacity()); } /** @@ -330,67 +321,67 @@ public void realRun() throws InterruptedException { */ public void testPutWithTake() throws InterruptedException { final int capacity = 2; - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(2); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < capacity; i++) - q.put(i); + q.put(itemFor(i)); pleaseTake.countDown(); - q.put(86); + q.put(eightysix); Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); - assertEquals(0, q.take()); + mustEqual(0, q.remainingCapacity()); + mustEqual(0, q.take()); await(pleaseInterrupt); if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** * timed offer times out if full and elements not taken */ public void testTimedOffer() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Object()); - q.put(new Object()); + q.put(zero); + q.put(one); long startTime = System.nanoTime(); - assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offer(two, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offer(new Object(), randomTimeout(), randomTimeUnit()); + q.offer(three, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.offer(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offer(two, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -406,9 +397,9 @@ public void realRun() throws InterruptedException { * take retrieves elements in FIFO order */ public void testTake() throws InterruptedException { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.take()); + mustEqual(i, q.take()); } } @@ -416,11 +407,11 @@ public void testTake() throws InterruptedException { * Take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.take()); Thread.currentThread().interrupt(); try { @@ -447,9 +438,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -458,9 +449,9 @@ public void testPoll() { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll(0, MILLISECONDS)); + mustEqual(i, q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); } @@ -469,10 +460,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -486,12 +477,12 @@ public void testTimedPoll() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -519,10 +510,10 @@ public void realRun() throws InterruptedException { * peek returns next element, or null if empty */ public void testPeek() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -533,10 +524,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -548,9 +539,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -562,12 +553,12 @@ public void testRemove() { * An add following remove(x) succeeds */ public void testRemoveElementAndAdd() throws InterruptedException { - LinkedBlockingQueue q = new LinkedBlockingQueue(); - assertTrue(q.add(new Integer(1))); - assertTrue(q.add(new Integer(2))); - assertTrue(q.remove(new Integer(1))); - assertTrue(q.remove(new Integer(2))); - assertTrue(q.add(new Integer(3))); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(); + assertTrue(q.add(one)); + assertTrue(q.add(two)); + mustRemove(q, one); + mustRemove(q, two); + mustAdd(q, three); assertNotNull(q.take()); } @@ -575,11 +566,11 @@ public void testRemoveElementAndAdd() throws InterruptedException { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -587,11 +578,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(SIZE, q.remainingCapacity()); + mustEqual(0, q.size()); + mustEqual(SIZE, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); assertTrue(q.contains(one)); @@ -603,12 +594,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = new LinkedBlockingQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue p = new LinkedBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -617,8 +608,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -627,7 +618,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -637,13 +628,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = populatedQueue(i); + LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + mustNotContain(q, p.remove()); } } } @@ -652,7 +642,7 @@ public void testRemoveAll() { * toArray contains all elements in FIFO order */ public void testToArray() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -664,11 +654,11 @@ public void testToArray() { * toArray(a) contains all elements in FIFO order */ public void testToArray2() throws InterruptedException { - LinkedBlockingQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + LinkedBlockingQueue q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -676,8 +666,9 @@ public void testToArray2() throws InterruptedException { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - LinkedBlockingQueue q = populatedQueue(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + LinkedBlockingQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -688,18 +679,18 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() throws InterruptedException { - LinkedBlockingQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + LinkedBlockingQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); it = q.iterator(); for (i = 0; it.hasNext(); i++) - assertEquals(it.next(), q.take()); - assertEquals(i, SIZE); + mustEqual(it.next(), q.take()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -707,19 +698,19 @@ public void testIterator() throws InterruptedException { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new LinkedBlockingQueue().iterator()); + assertIteratorExhausted(new LinkedBlockingQueue().iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(3); q.add(two); q.add(one); q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); @@ -733,38 +724,38 @@ public void testIteratorRemove() { * iterator ordering is FIFO */ public void testIteratorOrdering() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals(0, q.size()); + mustEqual(0, q.size()); } /** * toString contains toStrings of elements */ public void testToString() { - LinkedBlockingQueue q = populatedQueue(SIZE); + LinkedBlockingQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -775,7 +766,7 @@ public void testToString() { * offer transfers elements across Executor tasks */ public void testOfferInExecutor() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(2); q.add(one); q.add(two); final CheckedBarrier threadsStarted = new CheckedBarrier(2); @@ -786,7 +777,7 @@ public void realRun() throws InterruptedException { assertFalse(q.offer(three)); threadsStarted.await(); assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); }}); executor.execute(new CheckedRunnable() { @@ -801,7 +792,7 @@ public void realRun() throws InterruptedException { * timed poll retrieves elements across Executor threads */ public void testPollInExecutor() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); + final LinkedBlockingQueue q = new LinkedBlockingQueue<>(2); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -825,16 +816,16 @@ public void realRun() throws InterruptedException { * A deserialized/reserialized queue has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -843,42 +834,42 @@ public void testSerialization() throws Exception { * drainTo(c) empties queue into another collection c */ public void testDrainTo() { - LinkedBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); + LinkedBlockingQueue q = populatedQueue(SIZE); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(SIZE, l.size()); + mustEqual(0, q.size()); + mustEqual(SIZE, l.size()); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); q.add(zero); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); + mustContain(q, zero); + mustContain(q, one); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); } /** * drainTo empties full queue, unblocking a waiting put. */ public void testDrainToWithActivePut() throws InterruptedException { - final LinkedBlockingQueue q = populatedQueue(SIZE); + final LinkedBlockingQueue q = populatedQueue(SIZE); Thread t = new Thread(new CheckedRunnable() { public void realRun() throws InterruptedException { - q.put(new Integer(SIZE + 1)); + q.put(new Item(SIZE + 1)); }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); t.join(); assertTrue(q.size() + l.size() >= SIZE); } @@ -887,17 +878,17 @@ public void realRun() throws InterruptedException { * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - LinkedBlockingQueue q = new LinkedBlockingQueue(); + LinkedBlockingQueue q = new LinkedBlockingQueue<>(); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); + mustOffer(q, j); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(k, l.size()); - assertEquals(SIZE - k, q.size()); + mustEqual(k, l.size()); + mustEqual(SIZE - k, q.size()); for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); + mustEqual(l.get(j), j); do {} while (q.poll() != null); } } @@ -907,7 +898,7 @@ public void testDrainToN() { */ public void testNeverContainsNull() { Collection[] qs = { - new LinkedBlockingQueue(), + new LinkedBlockingQueue<>(), populatedQueue(2), }; diff --git a/test/jdk/java/util/concurrent/tck/LinkedListTest.java b/test/jdk/java/util/concurrent/tck/LinkedListTest.java index d0ced2831e7..945d463e3dc 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedListTest.java +++ b/test/jdk/java/util/concurrent/tck/LinkedListTest.java @@ -52,11 +52,12 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return LinkedList.class; } public List emptyCollection() { return new LinkedList(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return true; } } class SubListImplementation extends Implementation { + @SuppressWarnings("unchecked") public List emptyCollection() { List list = super.emptyCollection(); ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -74,17 +75,17 @@ public List emptyCollection() { /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static LinkedList populatedQueue(int n) { - LinkedList q = new LinkedList<>(); + private static LinkedList populatedQueue(int n) { + LinkedList q = new LinkedList<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peekFirst()); - assertEquals((Integer) (n - 1), q.peekLast()); + mustEqual(n, q.size()); + mustEqual(0, q.peekFirst()); + mustEqual((n - 1), q.peekLast()); return q; } @@ -92,7 +93,7 @@ private static LinkedList populatedQueue(int n) { * new queue is empty */ public void testConstructor1() { - assertEquals(0, new LinkedList().size()); + mustEqual(0, new LinkedList().size()); } /** @@ -100,7 +101,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new LinkedList((Collection)null); + new LinkedList((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -109,23 +110,21 @@ public void testConstructor3() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + LinkedList q = new LinkedList<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = i; - LinkedList q = new LinkedList(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - LinkedList q = new LinkedList(); + LinkedList q = new LinkedList<>(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + q.add(one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + q.add(two); q.remove(); q.remove(); assertTrue(q.isEmpty()); @@ -135,14 +134,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.remove(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -150,7 +149,7 @@ public void testSize() { * offer(null) succeeds */ public void testOfferNull() { - LinkedList q = new LinkedList(); + LinkedList q = new LinkedList<>(); q.offer(null); assertNull(q.get(0)); assertTrue(q.contains(null)); @@ -160,19 +159,19 @@ public void testOfferNull() { * Offer succeeds */ public void testOffer() { - LinkedList q = new LinkedList(); - assertTrue(q.offer(new Integer(0))); - assertTrue(q.offer(new Integer(1))); + LinkedList q = new LinkedList<>(); + mustOffer(q, zero); + mustOffer(q, one); } /** * add succeeds */ public void testAdd() { - LinkedList q = new LinkedList(); + LinkedList q = new LinkedList<>(); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -180,7 +179,7 @@ public void testAdd() { * addAll(null) throws NPE */ public void testAddAll1() { - LinkedList q = new LinkedList(); + LinkedList q = new LinkedList<>(); try { q.addAll(null); shouldThrow(); @@ -191,25 +190,23 @@ public void testAddAll1() { * Queue contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = i; - LinkedList q = new LinkedList(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + LinkedList q = new LinkedList<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * addAll with too large an index throws IOOBE */ public void testAddAll2_IndexOutOfBoundsException() { - LinkedList l = new LinkedList(); - l.add(new Object()); - LinkedList m = new LinkedList(); - m.add(new Object()); + LinkedList l = new LinkedList<>(); + l.add(zero); + LinkedList m = new LinkedList<>(); + m.add(one); try { l.addAll(4,m); shouldThrow(); @@ -220,10 +217,10 @@ public void testAddAll2_IndexOutOfBoundsException() { * addAll with negative index throws IOOBE */ public void testAddAll4_BadIndex() { - LinkedList l = new LinkedList(); - l.add(new Object()); - LinkedList m = new LinkedList(); - m.add(new Object()); + LinkedList l = new LinkedList<>(); + l.add(zero); + LinkedList m = new LinkedList<>(); + m.add(one); try { l.addAll(-1,m); shouldThrow(); @@ -234,9 +231,9 @@ public void testAddAll4_BadIndex() { * poll succeeds unless empty */ public void testPoll() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -245,10 +242,10 @@ public void testPoll() { * peek returns next element, or null if empty */ public void testPeek() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -259,10 +256,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -274,9 +271,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -288,19 +285,19 @@ public void testRemove() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove((Integer)i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove((Integer)i)); - assertFalse(q.contains(i)); - assertFalse(q.remove((Integer)(i + 1))); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -309,11 +306,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -321,11 +318,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertTrue(q.add(new Integer(1))); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -335,12 +332,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - LinkedList q = populatedQueue(SIZE); - LinkedList p = new LinkedList(); + LinkedList q = populatedQueue(SIZE); + LinkedList p = new LinkedList<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - assertTrue(p.add(new Integer(i))); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -349,8 +346,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - LinkedList q = populatedQueue(SIZE); - LinkedList p = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); + LinkedList p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -359,7 +356,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -369,13 +366,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - LinkedList q = populatedQueue(SIZE); - LinkedList p = populatedQueue(i); + LinkedList q = populatedQueue(SIZE); + LinkedList p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + mustNotContain(q, p.remove()); } } } @@ -384,7 +380,7 @@ public void testRemoveAll() { * toArray contains all elements in FIFO order */ public void testToArray() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -396,11 +392,11 @@ public void testToArray() { * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - LinkedList q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + LinkedList q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -409,10 +405,10 @@ public void testToArray2() { * toArray(null) throws NullPointerException */ public void testToArray_NullArg() { - LinkedList l = new LinkedList(); - l.add(new Object()); + LinkedList l = new LinkedList<>(); + l.add(zero); try { - l.toArray((Object[])null); + l.toArray((Item[])null); shouldThrow(); } catch (NullPointerException success) {} } @@ -420,9 +416,10 @@ public void testToArray_NullArg() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - LinkedList l = new LinkedList(); - l.add(new Integer(5)); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + LinkedList l = new LinkedList<>(); + l.add(five); try { l.toArray(new String[10]); shouldThrow(); @@ -433,12 +430,12 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() { - LinkedList q = populatedQueue(SIZE); - Iterator it = q.iterator(); + LinkedList q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -446,39 +443,39 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new LinkedList().iterator()); + assertIteratorExhausted(new LinkedList<>().iterator()); } /** * iterator ordering is FIFO */ public void testIteratorOrdering() { - final LinkedList q = new LinkedList(); - q.add(new Integer(1)); - q.add(new Integer(2)); - q.add(new Integer(3)); + final LinkedList q = new LinkedList<>(); + q.add(one); + q.add(two); + q.add(three); int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.iterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final LinkedList q = new LinkedList(); - q.add(new Integer(1)); - q.add(new Integer(2)); - q.add(new Integer(3)); - Iterator it = q.iterator(); - assertEquals(1, it.next()); + final LinkedList q = new LinkedList<>(); + q.add(one); + q.add(two); + q.add(three); + Iterator it = q.iterator(); + mustEqual(1, it.next()); it.remove(); it = q.iterator(); - assertEquals(2, it.next()); - assertEquals(3, it.next()); + mustEqual(2, it.next()); + mustEqual(3, it.next()); assertFalse(it.hasNext()); } @@ -486,14 +483,14 @@ public void testIteratorRemove() { * Descending iterator iterates through all elements */ public void testDescendingIterator() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); int i = 0; - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertFalse(it.hasNext()); try { it.next(); @@ -505,27 +502,27 @@ public void testDescendingIterator() { * Descending iterator ordering is reverse FIFO */ public void testDescendingIteratorOrdering() { - final LinkedList q = new LinkedList(); - q.add(new Integer(3)); - q.add(new Integer(2)); - q.add(new Integer(1)); + final LinkedList q = new LinkedList<>(); + q.add(three); + q.add(two); + q.add(one); int k = 0; - for (Iterator it = q.descendingIterator(); it.hasNext();) { - assertEquals(++k, it.next()); + for (Iterator it = q.descendingIterator(); it.hasNext();) { + mustEqual(++k, it.next()); } - assertEquals(3, k); + mustEqual(3, k); } /** * descendingIterator.remove removes current element */ public void testDescendingIteratorRemove() { - final LinkedList q = new LinkedList(); + final LinkedList q = new LinkedList<>(); q.add(three); q.add(two); q.add(one); - Iterator it = q.descendingIterator(); + Iterator it = q.descendingIterator(); it.next(); it.remove(); it = q.descendingIterator(); @@ -538,7 +535,7 @@ public void testDescendingIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -549,7 +546,7 @@ public void testToString() { * peek returns element inserted with addFirst */ public void testAddFirst() { - LinkedList q = populatedQueue(3); + LinkedList q = populatedQueue(3); q.addFirst(four); assertSame(four, q.peek()); } @@ -558,7 +555,7 @@ public void testAddFirst() { * peekFirst returns element inserted with push */ public void testPush() { - LinkedList q = populatedQueue(3); + LinkedList q = populatedQueue(3); q.push(four); assertSame(four, q.peekFirst()); } @@ -567,9 +564,9 @@ public void testPush() { * pop removes next element, or throws NSEE if empty */ public void testPop() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pop()); + mustEqual(i, q.pop()); } try { q.pop(); @@ -581,27 +578,27 @@ public void testPop() { * OfferFirst succeeds */ public void testOfferFirst() { - LinkedList q = new LinkedList(); - assertTrue(q.offerFirst(new Integer(0))); - assertTrue(q.offerFirst(new Integer(1))); + LinkedList q = new LinkedList<>(); + assertTrue(q.offerFirst(zero)); + assertTrue(q.offerFirst(one)); } /** * OfferLast succeeds */ public void testOfferLast() { - LinkedList q = new LinkedList(); - assertTrue(q.offerLast(new Integer(0))); - assertTrue(q.offerLast(new Integer(1))); + LinkedList q = new LinkedList<>(); + assertTrue(q.offerLast(zero)); + assertTrue(q.offerLast(one)); } /** * pollLast succeeds unless empty */ public void testPollLast() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollLast()); } @@ -610,10 +607,10 @@ public void testPollLast() { * peekFirst returns next element, or null if empty */ public void testPeekFirst() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peekFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.peekFirst()); + mustEqual(i, q.pollFirst()); assertTrue(q.peekFirst() == null || !q.peekFirst().equals(i)); } @@ -624,10 +621,10 @@ public void testPeekFirst() { * peekLast returns next element, or null if empty */ public void testPeekLast() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.peekLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.peekLast()); + mustEqual(i, q.pollLast()); assertTrue(q.peekLast() == null || !q.peekLast().equals(i)); } @@ -635,10 +632,10 @@ public void testPeekLast() { } public void testFirstElement() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.getFirst()); - assertEquals(i, q.pollFirst()); + mustEqual(i, q.getFirst()); + mustEqual(i, q.pollFirst()); } try { q.getFirst(); @@ -650,10 +647,10 @@ public void testFirstElement() { * getLast returns next element, or throws NSEE if empty */ public void testLastElement() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.getLast()); - assertEquals(i, q.pollLast()); + mustEqual(i, q.getLast()); + mustEqual(i, q.pollLast()); } try { q.getLast(); @@ -666,13 +663,13 @@ public void testLastElement() { * removeFirstOccurrence(x) removes x and returns true if present */ public void testRemoveFirstOccurrence() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeFirstOccurrence(new Integer(i))); - assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); + assertTrue(q.removeFirstOccurrence(itemFor(i))); + assertFalse(q.removeFirstOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } @@ -681,13 +678,13 @@ public void testRemoveFirstOccurrence() { * removeLastOccurrence(x) removes x and returns true if present */ public void testRemoveLastOccurrence() { - LinkedList q = populatedQueue(SIZE); + LinkedList q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); + assertTrue(q.removeLastOccurrence(itemFor(i))); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.removeLastOccurrence(new Integer(i))); - assertFalse(q.removeLastOccurrence(new Integer(i + 1))); + assertTrue(q.removeLastOccurrence(itemFor(i))); + assertFalse(q.removeLastOccurrence(itemFor(i + 1))); } assertTrue(q.isEmpty()); } diff --git a/test/jdk/java/util/concurrent/tck/LinkedTransferQueueTest.java b/test/jdk/java/util/concurrent/tck/LinkedTransferQueueTest.java index 9acbf5bdf35..cecc7eaf7f6 100644 --- a/test/jdk/java/util/concurrent/tck/LinkedTransferQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/LinkedTransferQueueTest.java @@ -66,7 +66,7 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return LinkedTransferQueue.class; } public Collection emptyCollection() { return new LinkedTransferQueue(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -80,7 +80,7 @@ class Implementation implements CollectionImplementation { * being true */ public void testConstructor1() { - assertEquals(0, new LinkedTransferQueue().size()); + mustEqual(0, new LinkedTransferQueue().size()); assertTrue(new LinkedTransferQueue().isEmpty()); } @@ -100,7 +100,7 @@ public void testConstructor2() { * NullPointerException */ public void testConstructor3() { - Collection elements = Arrays.asList(new Integer[SIZE]); + Collection elements = Arrays.asList(new Item[SIZE]); try { new LinkedTransferQueue(elements); shouldThrow(); @@ -112,10 +112,9 @@ public void testConstructor3() { * throws NullPointerException */ public void testConstructor4() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = i; - Collection elements = Arrays.asList(ints); + Item[] items = new Item[2]; + items[0] = zero; + Collection elements = Arrays.asList(items); try { new LinkedTransferQueue(elements); shouldThrow(); @@ -126,15 +125,11 @@ public void testConstructor4() { * Queue contains all elements of the collection it is initialized by */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) { - ints[i] = i; - } - List intList = Arrays.asList(ints); - LinkedTransferQueue q - = new LinkedTransferQueue(intList); - assertEquals(q.size(), intList.size()); - assertEquals(q.toString(), intList.toString()); + Item[] items = defaultItems; + List intList = Arrays.asList(items); + LinkedTransferQueue q = new LinkedTransferQueue<>(intList); + mustEqual(q.size(), intList.size()); + mustEqual(q.toString(), intList.toString()); assertTrue(Arrays.equals(q.toArray(), intList.toArray())); assertTrue(Arrays.equals(q.toArray(new Object[0]), @@ -142,7 +137,7 @@ public void testConstructor5() { assertTrue(Arrays.equals(q.toArray(new Object[SIZE]), intList.toArray(new Object[SIZE]))); for (int i = 0; i < SIZE; ++i) { - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } } @@ -150,16 +145,16 @@ public void testConstructor5() { * remainingCapacity() always returns Integer.MAX_VALUE */ public void testRemainingCapacity() { - BlockingQueue q = populatedQueue(SIZE); + BlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(SIZE - i, q.size()); - assertEquals(i, q.remove()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(SIZE - i, q.size()); + mustEqual(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(i, q.size()); - assertTrue(q.add(i)); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -167,7 +162,7 @@ public void testRemainingCapacity() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -179,12 +174,10 @@ public void testAddAllSelf() { * NullPointerException after possibly adding some elements */ public void testAddAll3() { - LinkedTransferQueue q = new LinkedTransferQueue(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = i; + LinkedTransferQueue q = new LinkedTransferQueue<>(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -193,16 +186,13 @@ public void testAddAll3() { * Queue contains all elements, in traversal order, of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) { - ints[i] = i; - } + Item[] empty = new Item[0]; + Item[] items = defaultItems; LinkedTransferQueue q = new LinkedTransferQueue(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) { - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } } @@ -210,11 +200,12 @@ public void testAddAll5() { * all elements successfully put are contained */ public void testPut() { - LinkedTransferQueue q = new LinkedTransferQueue<>(); + LinkedTransferQueue q = new LinkedTransferQueue<>(); + Item[] items = defaultItems; for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.put(i); - assertTrue(q.contains(i)); + mustEqual(i, q.size()); + q.put(items[i]); + mustContain(q, items[i]); } } @@ -222,9 +213,9 @@ public void testPut() { * take retrieves elements in FIFO order */ public void testTake() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.take()); + mustEqual(i, q.take()); } } @@ -232,11 +223,11 @@ public void testTake() throws InterruptedException { * take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.take()); Thread.currentThread().interrupt(); try { @@ -263,9 +254,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); checkEmpty(q); @@ -275,9 +266,9 @@ public void testPoll() throws InterruptedException { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.poll(0, MILLISECONDS)); + mustEqual(i, q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); checkEmpty(q); @@ -287,10 +278,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); long startTime = System.nanoTime(); for (int i = 0; i < SIZE; ++i) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); startTime = System.nanoTime(); @@ -304,12 +295,12 @@ public void testTimedPoll() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -338,12 +329,12 @@ public void realRun() throws InterruptedException { * instead of returning timeout status */ public void testTimedPollAfterInterrupt() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { Thread.currentThread().interrupt(); for (int i = 0; i < SIZE; ++i) - assertEquals(i, (int) q.poll(randomTimeout(), randomTimeUnit())); + mustEqual(i, q.poll(randomTimeout(), randomTimeUnit())); try { q.poll(randomTimeout(), randomTimeUnit()); shouldThrow(); @@ -359,12 +350,12 @@ public void realRun() throws InterruptedException { * peek returns next element, or null if empty */ public void testPeek() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.peek()); - assertEquals(i, (int) q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || - i != (int) q.peek()); + i != q.peek().value); } assertNull(q.peek()); checkEmpty(q); @@ -374,10 +365,10 @@ public void testPeek() throws InterruptedException { * element returns next element, or throws NoSuchElementException if empty */ public void testElement() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.element()); - assertEquals(i, (int) q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -390,9 +381,9 @@ public void testElement() throws InterruptedException { * remove removes next element, or throws NoSuchElementException if empty */ public void testRemove() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, (int) q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -405,24 +396,24 @@ public void testRemove() throws InterruptedException { * An add following remove(x) succeeds */ public void testRemoveElementAndAdd() throws InterruptedException { - LinkedTransferQueue q = new LinkedTransferQueue(); - assertTrue(q.add(one)); - assertTrue(q.add(two)); - assertTrue(q.remove(one)); - assertTrue(q.remove(two)); - assertTrue(q.add(three)); - assertSame(q.take(), three); + LinkedTransferQueue q = new LinkedTransferQueue<>(); + mustAdd(q, one); + mustAdd(q, two); + mustRemove(q, one); + mustRemove(q, two); + mustAdd(q, three); + mustEqual(q.take(), three); } /** * contains(x) reports true when elements added but not yet removed */ public void testContains() { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(i)); - assertEquals(i, (int) q.poll()); - assertFalse(q.contains(i)); + mustContain(q, i); + mustEqual(i, q.poll()); + mustNotContain(q, i); } } @@ -430,14 +421,14 @@ public void testContains() { * clear removes all elements */ public void testClear() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); q.clear(); checkEmpty(q); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); - assertEquals(1, q.size()); - assertTrue(q.contains(one)); + mustEqual(1, q.size()); + mustContain(q, one); q.clear(); checkEmpty(q); } @@ -446,12 +437,12 @@ public void testClear() throws InterruptedException { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - LinkedTransferQueue q = populatedQueue(SIZE); - LinkedTransferQueue p = new LinkedTransferQueue<>(); + LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue p = new LinkedTransferQueue<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(i); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -461,8 +452,8 @@ public void testContainsAll() { * if changed */ public void testRetainAll() { - LinkedTransferQueue q = populatedQueue(SIZE); - LinkedTransferQueue p = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) { @@ -471,7 +462,7 @@ public void testRetainAll() { assertTrue(changed); } assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -482,12 +473,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - LinkedTransferQueue q = populatedQueue(SIZE); - LinkedTransferQueue p = populatedQueue(i); + LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - assertFalse(q.contains(p.remove())); + mustNotContain(q, p.remove()); } } } @@ -496,7 +487,7 @@ public void testRemoveAll() { * toArray() contains all elements in FIFO order */ public void testToArray() { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -508,11 +499,11 @@ public void testToArray() { * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - LinkedTransferQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + LinkedTransferQueue q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -520,8 +511,9 @@ public void testToArray2() { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - LinkedTransferQueue q = populatedQueue(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + LinkedTransferQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -532,18 +524,18 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() throws InterruptedException { - LinkedTransferQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + LinkedTransferQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); it = q.iterator(); for (i = 0; it.hasNext(); i++) - assertEquals(it.next(), q.take()); - assertEquals(i, SIZE); + mustEqual(it.next(), q.take()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -558,12 +550,12 @@ public void testEmptyIterator() { * iterator.remove() removes current element */ public void testIteratorRemove() { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); q.add(two); q.add(one); q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); @@ -577,39 +569,39 @@ public void testIteratorRemove() { * iterator ordering is FIFO */ public void testIteratorOrdering() { - final LinkedTransferQueue q = new LinkedTransferQueue<>(); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); q.add(one); q.add(two); q.add(three); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); int k = 0; - for (Integer n : q) { - assertEquals(++k, (int) n); + for (Item n : q) { + mustEqual(++k, n); } - assertEquals(3, k); + mustEqual(3, k); } /** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); q.add(one); q.add(two); q.add(three); - for (Iterator it = q.iterator(); it.hasNext();) { + for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } - assertEquals(0, q.size()); + mustEqual(0, q.size()); } /** * toString contains toStrings of elements */ public void testToString() { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -620,7 +612,7 @@ public void testToString() { * offer transfers elements across Executor tasks */ public void testOfferInExecutor() { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -646,7 +638,7 @@ public void realRun() throws InterruptedException { * timed poll retrieves elements across Executor threads */ public void testPollInExecutor() { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -673,16 +665,16 @@ public void realRun() throws InterruptedException { * A deserialized/reserialized queue has same elements in same order */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(y, x); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -691,25 +683,25 @@ public void testSerialization() throws Exception { * drainTo(c) empties queue into another collection c */ public void testDrainTo() { - LinkedTransferQueue q = populatedQueue(SIZE); + LinkedTransferQueue q = populatedQueue(SIZE); ArrayList l = new ArrayList(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(SIZE, l.size()); + mustEqual(0, q.size()); + mustEqual(SIZE, l.size()); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, l.get(i)); + mustEqual(i, l.get(i)); } q.add(zero); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); + mustContain(q, zero); + mustContain(q, one); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) { - assertEquals(i, l.get(i)); + mustEqual(i, l.get(i)); } } @@ -717,16 +709,16 @@ public void testDrainTo() { * drainTo(c) empties full queue, unblocking a waiting put. */ public void testDrainToWithActivePut() throws InterruptedException { - final LinkedTransferQueue q = populatedQueue(SIZE); + final LinkedTransferQueue q = populatedQueue(SIZE); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { - q.put(SIZE + 1); + q.put(new Item(SIZE + 1)); }}); ArrayList l = new ArrayList(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) - assertEquals(i, l.get(i)); + mustEqual(i, l.get(i)); awaitTermination(t); assertTrue(q.size() + l.size() >= SIZE); } @@ -735,18 +727,18 @@ public void realRun() { * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - LinkedTransferQueue q = new LinkedTransferQueue(); + LinkedTransferQueue q = new LinkedTransferQueue<>(); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) { - assertTrue(q.offer(j)); + mustOffer(q, j); } ArrayList l = new ArrayList(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(k, l.size()); - assertEquals(SIZE - k, q.size()); + mustEqual(k, l.size()); + mustEqual(SIZE - k, q.size()); for (int j = 0; j < k; ++j) - assertEquals(j, l.get(j)); + mustEqual(j, l.get(j)); do {} while (q.poll() != null); } } @@ -756,8 +748,8 @@ public void testDrainToN() { * offer(e) decrements the waiting consumer count */ public void testWaitingConsumer() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); - assertEquals(0, q.getWaitingConsumerCount()); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); + mustEqual(0, q.getWaitingConsumerCount()); assertFalse(q.hasWaitingConsumer()); final CountDownLatch threadStarted = new CountDownLatch(1); @@ -766,20 +758,20 @@ public void realRun() throws InterruptedException { threadStarted.countDown(); long startTime = System.nanoTime(); assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.getWaitingConsumerCount()); + mustEqual(0, q.getWaitingConsumerCount()); assertFalse(q.hasWaitingConsumer()); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); threadStarted.await(); - Callable oneConsumer - = new Callable() { public Boolean call() { + Callable oneConsumer = new Callable<>() { + public Boolean call() { return q.hasWaitingConsumer() && q.getWaitingConsumerCount() == 1; }}; waitForThreadToEnterWaitState(t, oneConsumer); assertTrue(q.offer(one)); - assertEquals(0, q.getWaitingConsumerCount()); + mustEqual(0, q.getWaitingConsumerCount()); assertFalse(q.hasWaitingConsumer()); awaitTermination(t); @@ -790,7 +782,7 @@ public void realRun() throws InterruptedException { */ public void testTransfer1() throws InterruptedException { try { - LinkedTransferQueue q = new LinkedTransferQueue(); + LinkedTransferQueue q = new LinkedTransferQueue<>(); q.transfer(null); shouldThrow(); } catch (NullPointerException success) {} @@ -801,7 +793,7 @@ public void testTransfer1() throws InterruptedException { * is returned by the associated poll. */ public void testTransfer2() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue<>(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { @@ -812,8 +804,8 @@ public void realRun() throws InterruptedException { }}); threadStarted.await(); - Callable oneElement - = new Callable() { public Boolean call() { + Callable oneElement = new Callable<>() { + public Boolean call() { return !q.isEmpty() && q.size() == 1; }}; waitForThreadToEnterWaitState(t, oneElement); @@ -826,13 +818,13 @@ public void realRun() throws InterruptedException { * transfer waits until a poll occurs, and then transfers in fifo order */ public void testTransfer3() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue<>(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread first = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.transfer(four); - assertFalse(q.contains(four)); - assertEquals(1, q.size()); + mustNotContain(q, four); + mustEqual(1, q.size()); }}); Thread interruptedThread = newStartedThread( @@ -845,10 +837,10 @@ public void realRun() throws InterruptedException { while (q.size() < 2) Thread.yield(); - assertEquals(2, q.size()); + mustEqual(2, q.size()); assertSame(four, q.poll()); first.join(); - assertEquals(1, q.size()); + mustEqual(1, q.size()); interruptedThread.interrupt(); interruptedThread.join(); checkEmpty(q); @@ -859,19 +851,19 @@ public void realRun() throws InterruptedException { * thread returns the element */ public void testTransfer4() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.transfer(four); - assertFalse(q.contains(four)); + mustNotContain(q, four); assertSame(three, q.poll()); }}); while (q.isEmpty()) Thread.yield(); assertFalse(q.isEmpty()); - assertEquals(1, q.size()); + mustEqual(1, q.size()); assertTrue(q.offer(three)); assertSame(four, q.poll()); awaitTermination(t); @@ -882,7 +874,7 @@ public void realRun() throws InterruptedException { * is returned by the associated take. */ public void testTransfer5() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue<>(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -893,7 +885,7 @@ public void realRun() throws InterruptedException { while (q.isEmpty()) Thread.yield(); assertFalse(q.isEmpty()); - assertEquals(1, q.size()); + mustEqual(1, q.size()); assertSame(four, q.take()); checkEmpty(q); awaitTermination(t); @@ -903,7 +895,7 @@ public void realRun() throws InterruptedException { * tryTransfer(null) throws NullPointerException */ public void testTryTransfer1() { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); try { q.tryTransfer(null); shouldThrow(); @@ -915,7 +907,7 @@ public void testTryTransfer1() { * consumers waiting to poll or take. */ public void testTryTransfer2() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); assertFalse(q.tryTransfer(new Object())); assertFalse(q.hasWaitingConsumer()); checkEmpty(q); @@ -927,7 +919,7 @@ public void testTryTransfer2() throws InterruptedException { */ public void testTryTransfer3() throws InterruptedException { final Object hotPotato = new Object(); - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { @@ -951,7 +943,7 @@ public void realRun() { */ public void testTryTransfer4() throws InterruptedException { final Object hotPotato = new Object(); - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { @@ -971,7 +963,7 @@ public void realRun() { * tryTransfer blocks interruptibly if no takers */ public void testTryTransfer5() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); assertTrue(q.isEmpty()); @@ -1003,7 +995,7 @@ public void realRun() throws InterruptedException { * tryTransfer gives up after the timeout and returns false */ public void testTryTransfer6() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -1023,7 +1015,7 @@ public void realRun() throws InterruptedException { * before transfering to a poll or take */ public void testTryTransfer7() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); assertTrue(q.offer(four)); Thread t = newStartedThread(new CheckedRunnable() { @@ -1036,7 +1028,7 @@ public void realRun() throws InterruptedException { while (q.size() != 2) Thread.yield(); - assertEquals(2, q.size()); + mustEqual(2, q.size()); assertSame(four, q.poll()); assertSame(five, q.poll()); checkEmpty(q); @@ -1048,25 +1040,25 @@ public void realRun() throws InterruptedException { * returning false not enqueueing and the successive poll is null */ public void testTryTransfer8() throws InterruptedException { - final LinkedTransferQueue q = new LinkedTransferQueue(); + final LinkedTransferQueue q = new LinkedTransferQueue<>(); assertTrue(q.offer(four)); - assertEquals(1, q.size()); + mustEqual(1, q.size()); long startTime = System.nanoTime(); assertFalse(q.tryTransfer(five, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); - assertEquals(1, q.size()); + mustEqual(1, q.size()); assertSame(four, q.poll()); assertNull(q.poll()); checkEmpty(q); } - private LinkedTransferQueue populatedQueue(int n) { - LinkedTransferQueue q = new LinkedTransferQueue<>(); + private LinkedTransferQueue populatedQueue(int n) { + LinkedTransferQueue q = new LinkedTransferQueue<>(); checkEmpty(q); for (int i = 0; i < n; i++) { - assertEquals(i, q.size()); - assertTrue(q.offer(i)); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(i, q.size()); + mustOffer(q, i); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); } assertFalse(q.isEmpty()); return q; @@ -1077,7 +1069,7 @@ private LinkedTransferQueue populatedQueue(int n) { */ public void testNeverContainsNull() { Collection[] qs = { - new LinkedTransferQueue(), + new LinkedTransferQueue<>(), populatedQueue(2), }; diff --git a/test/jdk/java/util/concurrent/tck/MapTest.java b/test/jdk/java/util/concurrent/tck/MapTest.java index 3a37624daa3..61579f3e7c3 100644 --- a/test/jdk/java/util/concurrent/tck/MapTest.java +++ b/test/jdk/java/util/concurrent/tck/MapTest.java @@ -47,6 +47,7 @@ /** * Contains tests applicable to all Map implementations. */ +@SuppressWarnings("unchecked") public class MapTest extends JSR166TestCase { final MapImplementation impl; @@ -68,12 +69,12 @@ public void testImplSanity() { { Map m = impl.emptyMap(); assertTrue(m.isEmpty()); - assertEquals(0, m.size()); + mustEqual(0, m.size()); Object k = impl.makeKey(rnd.nextInt()); Object v = impl.makeValue(rnd.nextInt()); m.put(k, v); assertFalse(m.isEmpty()); - assertEquals(1, m.size()); + mustEqual(1, m.size()); assertTrue(m.containsKey(k)); assertTrue(m.containsValue(v)); } @@ -168,7 +169,7 @@ public int compareTo(Key x) { assertFalse(m.containsValue(v1)); assertTrue(m.containsValue(v2)); assertTrue(m.containsKey(keyToFrob)); - assertEquals(1, m.size()); + mustEqual(1, m.size()); } /** @@ -199,10 +200,10 @@ public void testBug8210280() { m1.putAll(m2); for (Object elt : m2.keySet()) - assertEquals(m2.get(elt), m1.get(elt)); + mustEqual(m2.get(elt), m1.get(elt)); for (Object elt : m1Copy.keySet()) assertSame(m1Copy.get(elt), m1.get(elt)); - assertEquals(size1 + size2, m1.size()); + mustEqual(size1 + size2, m1.size()); } /** @@ -217,17 +218,17 @@ public void testClone() { final Map clone = cloneableClone(map); if (clone == null) return; // not cloneable? - assertEquals(size, map.size()); - assertEquals(size, clone.size()); - assertEquals(map.isEmpty(), clone.isEmpty()); + mustEqual(size, map.size()); + mustEqual(size, clone.size()); + mustEqual(map.isEmpty(), clone.isEmpty()); clone.put(impl.makeKey(-1), impl.makeValue(-1)); - assertEquals(size, map.size()); - assertEquals(size + 1, clone.size()); + mustEqual(size, map.size()); + mustEqual(size + 1, clone.size()); clone.clear(); - assertEquals(size, map.size()); - assertEquals(0, clone.size()); + mustEqual(size, map.size()); + mustEqual(0, clone.size()); assertTrue(clone.isEmpty()); } @@ -261,7 +262,7 @@ public void testConcurrentAccess() throws Throwable { map.compute(key, incValue); } if (remappingFunctionCalledAtMostOnce) - assertEquals(invocations[0], invocations[1]); + mustEqual(invocations[0], invocations[1]); expectedSum.getAndAdd(invocations[0]); }, // repeatedly increment values using computeIfPresent() @@ -279,7 +280,7 @@ public void testConcurrentAccess() throws Throwable { invocations[0]++; } if (remappingFunctionCalledAtMostOnce) - assertEquals(invocations[0], invocations[1]); + mustEqual(invocations[0], invocations[1]); expectedSum.getAndAdd(invocations[0]); }, }; @@ -293,7 +294,7 @@ public void testConcurrentAccess() throws Throwable { checkTimedGet(future, null); long sum = map.values().stream().mapToLong(x -> (int) x).sum(); - assertEquals(expectedSum.get(), sum); + mustEqual(expectedSum.get(), sum); } // public void testFailsIntentionallyForDebugging() { diff --git a/test/jdk/java/util/concurrent/tck/NonNestmates.java b/test/jdk/java/util/concurrent/tck/NonNestmates.java index 9aac8d31298..d9f3adafc62 100644 --- a/test/jdk/java/util/concurrent/tck/NonNestmates.java +++ b/test/jdk/java/util/concurrent/tck/NonNestmates.java @@ -70,12 +70,12 @@ public void checkPackageAccess(AtomicLongFieldUpdaterTest obj) { } public void checkPackageAccess(AtomicReferenceFieldUpdaterTest obj) { - Integer one = new Integer(1); - Integer two = new Integer(2); + Item one = new Item(1); + Item two = new Item(2); obj.x = one; - AtomicReferenceFieldUpdater a = + AtomicReferenceFieldUpdater a = AtomicReferenceFieldUpdater.newUpdater( - AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); + AtomicReferenceFieldUpdaterTest.class, Item.class, "x"); assertSame(one, a.get(obj)); assertTrue(a.compareAndSet(obj, one, two)); assertSame(two, a.get(obj)); @@ -189,17 +189,17 @@ public void checkPrivateAccess() { } public void checkCompareAndSetProtectedSub() { - AtomicReferenceFieldUpdater a = + AtomicReferenceFieldUpdater a = AtomicReferenceFieldUpdater.newUpdater( AtomicReferenceFieldUpdaterTest.class, - Integer.class, "protectedField"); + Item.class, "protectedField"); this.protectedField = one; assertTrue(a.compareAndSet(this, one, two)); - assertTrue(a.compareAndSet(this, two, m4)); - assertSame(m4, a.get(this)); - assertFalse(a.compareAndSet(this, m5, seven)); + assertTrue(a.compareAndSet(this, two, minusFour)); + assertSame(minusFour, a.get(this)); + assertFalse(a.compareAndSet(this, minusFive, seven)); assertNotSame(seven, a.get(this)); - assertTrue(a.compareAndSet(this, m4, seven)); + assertTrue(a.compareAndSet(this, minusFour, seven)); assertSame(seven, a.get(this)); } } diff --git a/test/jdk/java/util/concurrent/tck/PhaserTest.java b/test/jdk/java/util/concurrent/tck/PhaserTest.java index 6a9f4566254..07b0f82d81d 100644 --- a/test/jdk/java/util/concurrent/tck/PhaserTest.java +++ b/test/jdk/java/util/concurrent/tck/PhaserTest.java @@ -288,7 +288,7 @@ public void testBulkRegister3() { * the phase number increments correctly when tripping the barrier */ public void testPhaseIncrement1() { - for (int size = 1; size < nine; size++) { + for (int size = 1; size < 9; size++) { final Phaser phaser = new Phaser(size); for (int index = 0; index <= (1 << size); index++) { int phase = phaser.arrive(); diff --git a/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java b/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java index af29a2f6a51..c0f8db9ab5d 100644 --- a/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/PriorityBlockingQueueTest.java @@ -77,19 +77,20 @@ class Implementation implements CollectionImplementation { public Collection emptyCollection() { return new PriorityBlockingQueue(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } class ComparatorImplementation implements CollectionImplementation { public Class klazz() { return PriorityBlockingQueue.class; } + @SuppressWarnings("unchecked") public Collection emptyCollection() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); int initialCapacity = rnd.nextInt(1, 10); return new PriorityBlockingQueue( initialCapacity, new MyReverseComparator()); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return true; } public boolean permitsNulls() { return false; } } @@ -103,6 +104,7 @@ public Collection emptyCollection() { /** Sample Comparator */ static class MyReverseComparator implements Comparator, java.io.Serializable { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -110,20 +112,19 @@ public int compare(Object x, Object y) { /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static PriorityBlockingQueue populatedQueue(int n) { - PriorityBlockingQueue q = - new PriorityBlockingQueue(n); + private static PriorityBlockingQueue populatedQueue(int n) { + PriorityBlockingQueue q = new PriorityBlockingQueue<>(n); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peek()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(n, q.size()); + mustEqual(0, q.peek()); return q; } @@ -131,8 +132,8 @@ private static PriorityBlockingQueue populatedQueue(int n) { * A new queue has unbounded capacity */ public void testConstructor1() { - assertEquals(Integer.MAX_VALUE, - new PriorityBlockingQueue(SIZE).remainingCapacity()); + mustEqual(Integer.MAX_VALUE, + new PriorityBlockingQueue(SIZE).remainingCapacity()); } /** @@ -140,7 +141,7 @@ public void testConstructor1() { */ public void testConstructor2() { try { - new PriorityBlockingQueue(0); + new PriorityBlockingQueue(0); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -150,7 +151,7 @@ public void testConstructor2() { */ public void testConstructor3() { try { - new PriorityBlockingQueue(null); + new PriorityBlockingQueue(null); shouldThrow(); } catch (NullPointerException success) {} } @@ -159,9 +160,9 @@ public void testConstructor3() { * Initializing from Collection of null elements throws NPE */ public void testConstructor4() { - Collection elements = Arrays.asList(new Integer[SIZE]); + Collection elements = Arrays.asList(new Item[SIZE]); try { - new PriorityBlockingQueue(elements); + new PriorityBlockingQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -170,12 +171,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = i; - Collection elements = Arrays.asList(ints); + Item[] items = new Item[2]; items[0] = zero; + Collection elements = Arrays.asList(items); try { - new PriorityBlockingQueue(elements); + new PriorityBlockingQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -184,12 +183,10 @@ public void testConstructor5() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + PriorityBlockingQueue q = new PriorityBlockingQueue<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = i; - PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** @@ -197,23 +194,22 @@ public void testConstructor6() { */ public void testConstructor7() { MyReverseComparator cmp = new MyReverseComparator(); - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE, cmp); - assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); + @SuppressWarnings("unchecked") + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE, cmp); + mustEqual(cmp, q.comparator()); + Item[] items = defaultItems; + q.addAll(Arrays.asList(items)); for (int i = SIZE - 1; i >= 0; --i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - PriorityBlockingQueue q = new PriorityBlockingQueue(2); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(2); assertTrue(q.isEmpty()); - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); q.add(two); @@ -226,16 +222,16 @@ public void testEmpty() { * remainingCapacity() always returns Integer.MAX_VALUE */ public void testRemainingCapacity() { - BlockingQueue q = populatedQueue(SIZE); + BlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(SIZE - i, q.size()); - assertEquals(i, q.remove()); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(SIZE - i, q.size()); + mustEqual(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { - assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); - assertEquals(i, q.size()); - assertTrue(q.add(i)); + mustEqual(Integer.MAX_VALUE, q.remainingCapacity()); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -243,7 +239,7 @@ public void testRemainingCapacity() { * Offer of comparable element succeeds */ public void testOffer() { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(1); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); } @@ -252,13 +248,13 @@ public void testOffer() { * Offer of non-Comparable throws CCE */ public void testOfferNonComparable() { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(1); try { q.offer(new Object()); shouldThrow(); } catch (ClassCastException success) { assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); assertNull(q.poll()); } } @@ -267,10 +263,10 @@ public void testOfferNonComparable() { * add of comparable succeeds */ public void testAdd() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -278,7 +274,7 @@ public void testAdd() { * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); try { q.addAll(q); shouldThrow(); @@ -290,12 +286,11 @@ public void testAddAllSelf() { * possibly adding some elements */ public void testAddAll3() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE); + Item[] items = new Item[2]; + items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -304,44 +299,42 @@ public void testAddAll3() { * Queue contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = SIZE - 1; i >= 0; --i) - ints[i] = new Integer(i); - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * all elements successfully put are contained */ public void testPut() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { - Integer x = new Integer(i); + Item x = itemFor(i); q.put(x); - assertTrue(q.contains(x)); + mustContain(q, x); } - assertEquals(SIZE, q.size()); + mustEqual(SIZE, q.size()); } /** * put doesn't block waiting for take */ public void testPutWithTake() throws InterruptedException { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); + final PriorityBlockingQueue q = new PriorityBlockingQueue<>(2); final int size = 4; Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { for (int i = 0; i < size; i++) - q.put(new Integer(0)); + q.put(zero); }}); awaitTermination(t); - assertEquals(size, q.size()); + mustEqual(size, q.size()); q.take(); } @@ -349,13 +342,13 @@ public void realRun() { * Queue is unbounded, so timed offer never times out */ public void testTimedOffer() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); + final PriorityBlockingQueue q = new PriorityBlockingQueue<>(2); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { - q.put(new Integer(0)); - q.put(new Integer(0)); - assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); - assertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); + q.put(one); + q.put(two); + assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); + assertTrue(q.offer(zero, LONG_DELAY_MS, MILLISECONDS)); }}); awaitTermination(t); @@ -365,9 +358,9 @@ public void realRun() { * take retrieves elements in priority order */ public void testTake() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.take()); + mustEqual(i, q.take()); } } @@ -375,11 +368,11 @@ public void testTake() throws InterruptedException { * Take removes existing elements until empty, then blocks interruptibly */ public void testBlockingTake() throws InterruptedException { - final PriorityBlockingQueue q = populatedQueue(SIZE); + final PriorityBlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); + for (int i = 0; i < SIZE; i++) mustEqual(i, q.take()); Thread.currentThread().interrupt(); try { @@ -406,9 +399,9 @@ public void realRun() throws InterruptedException { * poll succeeds unless empty */ public void testPoll() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -417,9 +410,9 @@ public void testPoll() { * timed poll with zero timeout succeeds when non-empty, else times out */ public void testTimedPoll0() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll(0, MILLISECONDS)); + mustEqual(i, q.poll(0, MILLISECONDS)); } assertNull(q.poll(0, MILLISECONDS)); } @@ -428,10 +421,10 @@ public void testTimedPoll0() throws InterruptedException { * timed poll with nonzero timeout succeeds when non-empty, else times out */ public void testTimedPoll() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { long startTime = System.nanoTime(); - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); } long startTime = System.nanoTime(); @@ -445,12 +438,12 @@ public void testTimedPoll() throws InterruptedException { * returning timeout status */ public void testInterruptedTimedPoll() throws InterruptedException { - final BlockingQueue q = populatedQueue(SIZE); + final BlockingQueue q = populatedQueue(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { for (int i = 0; i < SIZE; i++) - assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); + mustEqual(i, q.poll(LONG_DELAY_MS, MILLISECONDS)); Thread.currentThread().interrupt(); try { @@ -477,10 +470,10 @@ public void realRun() throws InterruptedException { * peek returns next element, or null if empty */ public void testPeek() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -491,10 +484,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -506,9 +499,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -520,11 +513,11 @@ public void testRemove() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -532,13 +525,13 @@ public void testContains() { * clear removes all elements */ public void testClear() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); + mustContain(q, one); q.clear(); assertTrue(q.isEmpty()); } @@ -547,12 +540,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = new PriorityBlockingQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue p = new PriorityBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -561,8 +554,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -571,7 +564,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -581,13 +574,13 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = populatedQueue(i); + PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + Item x = p.remove(); + mustNotContain(q, x); } } } @@ -596,7 +589,7 @@ public void testRemoveAll() { * toArray contains all elements */ public void testToArray() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); Arrays.sort(a); @@ -609,12 +602,12 @@ public void testToArray() throws InterruptedException { * toArray(a) contains all elements */ public void testToArray2() throws InterruptedException { - PriorityBlockingQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - Arrays.sort(ints); - for (Integer o : ints) + PriorityBlockingQueue q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + Arrays.sort(items); + for (Item o : items) assertSame(o, q.take()); assertTrue(q.isEmpty()); } @@ -622,8 +615,9 @@ public void testToArray2() throws InterruptedException { /** * toArray(incompatible array type) throws ArrayStoreException */ - public void testToArray1_BadArg() { - PriorityBlockingQueue q = populatedQueue(SIZE); + @SuppressWarnings("CollectionToArraySafeParameter") + public void testToArray_incompatibleArrayType() { + PriorityBlockingQueue q = populatedQueue(SIZE); try { q.toArray(new String[10]); shouldThrow(); @@ -634,12 +628,12 @@ public void testToArray1_BadArg() { * iterator iterates through all elements */ public void testIterator() { - PriorityBlockingQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + PriorityBlockingQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -647,25 +641,25 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new PriorityBlockingQueue().iterator()); + assertIteratorExhausted(new PriorityBlockingQueue<>().iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(3); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final PriorityBlockingQueue q = new PriorityBlockingQueue<>(3); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -673,7 +667,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - PriorityBlockingQueue q = populatedQueue(SIZE); + PriorityBlockingQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -684,7 +678,7 @@ public void testToString() { * timed poll transfers elements across Executor tasks */ public void testPollInExecutor() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); + final PriorityBlockingQueue q = new PriorityBlockingQueue<>(2); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -708,14 +702,14 @@ public void realRun() throws InterruptedException { * A deserialized/reserialized queue has same elements */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); + mustEqual(x.size(), y.size()); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } @@ -724,42 +718,41 @@ public void testSerialization() throws Exception { * drainTo(c) empties queue into another collection c */ public void testDrainTo() { - PriorityBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); + PriorityBlockingQueue q = populatedQueue(SIZE); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(SIZE, l.size()); + mustEqual(0, q.size()); + mustEqual(SIZE, l.size()); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); q.add(zero); q.add(one); assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); + mustContain(q, one); l.clear(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(2, l.size()); + mustEqual(0, q.size()); + mustEqual(2, l.size()); for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); } /** * drainTo empties queue */ public void testDrainToWithActivePut() throws InterruptedException { - final PriorityBlockingQueue q = populatedQueue(SIZE); + final PriorityBlockingQueue q = populatedQueue(SIZE); Thread t = new Thread(new CheckedRunnable() { public void realRun() { - q.put(new Integer(SIZE + 1)); + q.put(new Item(SIZE + 1)); }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); + mustEqual(l.get(i), i); t.join(); assertTrue(q.size() + l.size() >= SIZE); } @@ -768,17 +761,17 @@ public void realRun() { * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE * 2); + PriorityBlockingQueue q = new PriorityBlockingQueue<>(SIZE * 2); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); + mustOffer(q, j); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; - assertEquals(k, l.size()); - assertEquals(SIZE - k, q.size()); + mustEqual(k, l.size()); + mustEqual(SIZE - k, q.size()); for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); + mustEqual(l.get(j), j); do {} while (q.poll() != null); } } @@ -788,7 +781,7 @@ public void testDrainToN() { */ public void testNeverContainsNull() { Collection[] qs = { - new PriorityBlockingQueue(), + new PriorityBlockingQueue<>(), populatedQueue(2), }; diff --git a/test/jdk/java/util/concurrent/tck/PriorityQueueTest.java b/test/jdk/java/util/concurrent/tck/PriorityQueueTest.java index fd8783ac9d2..690c056e23b 100644 --- a/test/jdk/java/util/concurrent/tck/PriorityQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/PriorityQueueTest.java @@ -51,16 +51,17 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return PriorityQueue.class; } public Collection emptyCollection() { return new PriorityQueue(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return false; } } class ComparatorImplementation implements CollectionImplementation { public Class klazz() { return PriorityQueue.class; } + @SuppressWarnings("unchecked") public Collection emptyCollection() { return new PriorityQueue(new MyReverseComparator()); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return false; } } @@ -71,6 +72,7 @@ public Collection emptyCollection() { } static class MyReverseComparator implements Comparator, java.io.Serializable { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -78,18 +80,18 @@ public int compare(Object x, Object y) { /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static PriorityQueue populatedQueue(int n) { - PriorityQueue q = new PriorityQueue<>(n); + private static PriorityQueue populatedQueue(int n) { + PriorityQueue q = new PriorityQueue<>(n); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.offer(new Integer(i))); + mustOffer(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - assertEquals((Integer) 0, q.peek()); + mustEqual(n, q.size()); + mustEqual(0, q.peek()); return q; } @@ -97,7 +99,7 @@ private static PriorityQueue populatedQueue(int n) { * A new queue has unbounded capacity */ public void testConstructor1() { - assertEquals(0, new PriorityQueue(SIZE).size()); + mustEqual(0, new PriorityQueue(SIZE).size()); } /** @@ -105,7 +107,7 @@ public void testConstructor1() { */ public void testConstructor2() { try { - new PriorityQueue(0); + new PriorityQueue(0); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -115,7 +117,7 @@ public void testConstructor2() { */ public void testConstructor3() { try { - new PriorityQueue((Collection)null); + new PriorityQueue((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -125,7 +127,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new PriorityQueue(Arrays.asList(new Integer[SIZE])); + new PriorityQueue(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -134,11 +136,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; + items[0] = zero; try { - new PriorityQueue(Arrays.asList(ints)); + new PriorityQueue(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -147,12 +148,10 @@ public void testConstructor5() { * Queue contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + PriorityQueue q = new PriorityQueue<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** @@ -160,25 +159,24 @@ public void testConstructor6() { */ public void testConstructor7() { MyReverseComparator cmp = new MyReverseComparator(); - PriorityQueue q = new PriorityQueue(SIZE, cmp); + @SuppressWarnings("unchecked") + PriorityQueue q = new PriorityQueue<>(SIZE, cmp); assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); + Item[] items = seqItems(SIZE); + q.addAll(Arrays.asList(items)); for (int i = SIZE - 1; i >= 0; --i) - assertEquals(ints[i], q.poll()); + mustEqual(items[i], q.poll()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - PriorityQueue q = new PriorityQueue(2); + PriorityQueue q = new PriorityQueue<>(2); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + q.add(one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + q.add(two); q.remove(); q.remove(); assertTrue(q.isEmpty()); @@ -188,14 +186,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.remove(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -203,7 +201,7 @@ public void testSize() { * offer(null) throws NPE */ public void testOfferNull() { - PriorityQueue q = new PriorityQueue(1); + PriorityQueue q = new PriorityQueue<>(1); try { q.offer(null); shouldThrow(); @@ -214,7 +212,7 @@ public void testOfferNull() { * add(null) throws NPE */ public void testAddNull() { - PriorityQueue q = new PriorityQueue(1); + PriorityQueue q = new PriorityQueue<>(1); try { q.add(null); shouldThrow(); @@ -225,7 +223,7 @@ public void testAddNull() { * Offer of comparable element succeeds */ public void testOffer() { - PriorityQueue q = new PriorityQueue(1); + PriorityQueue q = new PriorityQueue<>(1); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); } @@ -234,13 +232,13 @@ public void testOffer() { * Offer of non-Comparable throws CCE */ public void testOfferNonComparable() { - PriorityQueue q = new PriorityQueue(1); + PriorityQueue q = new PriorityQueue<>(1); try { q.offer(new Object()); shouldThrow(); } catch (ClassCastException success) { assertTrue(q.isEmpty()); - assertEquals(0, q.size()); + mustEqual(0, q.size()); assertNull(q.poll()); } } @@ -249,10 +247,10 @@ public void testOfferNonComparable() { * add of comparable succeeds */ public void testAdd() { - PriorityQueue q = new PriorityQueue(SIZE); + PriorityQueue q = new PriorityQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -260,7 +258,7 @@ public void testAdd() { * addAll(null) throws NPE */ public void testAddAll1() { - PriorityQueue q = new PriorityQueue(1); + PriorityQueue q = new PriorityQueue<>(1); try { q.addAll(null); shouldThrow(); @@ -271,9 +269,9 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - PriorityQueue q = new PriorityQueue(SIZE); + PriorityQueue q = new PriorityQueue<>(SIZE); try { - q.addAll(Arrays.asList(new Integer[SIZE])); + q.addAll(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -283,12 +281,11 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - PriorityQueue q = new PriorityQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + PriorityQueue q = new PriorityQueue<>(SIZE); + Item[] items = new Item[2]; + items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -297,24 +294,24 @@ public void testAddAll3() { * Queue contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; + Item[] empty = new Item[0]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - PriorityQueue q = new PriorityQueue(SIZE); + items[i] = itemFor(SIZE - 1 - i); + PriorityQueue q = new PriorityQueue<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.poll()); + mustEqual(i, q.poll()); } /** * poll succeeds unless empty */ public void testPoll() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.poll()); + mustEqual(i, q.poll()); } assertNull(q.poll()); } @@ -323,10 +320,10 @@ public void testPoll() { * peek returns next element, or null if empty */ public void testPeek() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.peek()); - assertEquals(i, q.poll()); + mustEqual(i, q.peek()); + mustEqual(i, q.poll()); assertTrue(q.peek() == null || !q.peek().equals(i)); } @@ -337,10 +334,10 @@ public void testPeek() { * element returns next element, or throws NSEE if empty */ public void testElement() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.element()); - assertEquals(i, q.poll()); + mustEqual(i, q.element()); + mustEqual(i, q.poll()); } try { q.element(); @@ -352,9 +349,9 @@ public void testElement() { * remove removes next element, or throws NSEE if empty */ public void testRemove() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remove()); + mustEqual(i, q.remove()); } try { q.remove(); @@ -366,19 +363,19 @@ public void testRemove() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -387,11 +384,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.poll(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -399,11 +396,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); + mustEqual(0, q.size()); + q.add(one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -413,12 +410,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = new PriorityQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); + PriorityQueue p = new PriorityQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -427,8 +424,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); + PriorityQueue p = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -437,7 +434,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.remove(); } } @@ -447,13 +444,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = populatedQueue(i); + PriorityQueue q = populatedQueue(SIZE); + PriorityQueue p = populatedQueue(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.remove()); - assertFalse(q.contains(x)); + mustNotContain(q, p.remove()); } } } @@ -462,7 +458,7 @@ public void testRemoveAll() { * toArray contains all elements */ public void testToArray() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); Arrays.sort(a); @@ -475,12 +471,12 @@ public void testToArray() { * toArray(a) contains all elements */ public void testToArray2() { - PriorityQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - Arrays.sort(ints); - for (Integer o : ints) + PriorityQueue q = populatedQueue(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + Arrays.sort(items); + for (Item o : items) assertSame(o, q.poll()); assertTrue(q.isEmpty()); } @@ -489,12 +485,12 @@ public void testToArray2() { * iterator iterates through all elements */ public void testIterator() { - PriorityQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); + PriorityQueue q = populatedQueue(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -502,25 +498,25 @@ public void testIterator() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new PriorityQueue().iterator()); + assertIteratorExhausted(new PriorityQueue().iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final PriorityQueue q = new PriorityQueue(3); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final PriorityQueue q = new PriorityQueue<>(3); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -528,7 +524,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -539,14 +535,14 @@ public void testToString() { * A deserialized/reserialized queue has same elements */ public void testSerialization() throws Exception { - Queue x = populatedQueue(SIZE); - Queue y = serialClone(x); + Queue x = populatedQueue(SIZE); + Queue y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); + mustEqual(x.size(), y.size()); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(), y.remove()); + mustEqual(x.remove(), y.remove()); } assertTrue(y.isEmpty()); } diff --git a/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java b/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java index 45fe2106735..64115eec1c9 100644 --- a/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java +++ b/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java @@ -947,7 +947,7 @@ protected void realCompute() { FibAction f = new FibAction(8); FibAction g = new FibAction(9); FibAction h = new FibAction(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -1045,7 +1045,7 @@ protected void realCompute() { FailingFibAction f = new FailingFibAction(8); FibAction g = new FibAction(9); FibAction h = new FibAction(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); diff --git a/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java b/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java index d6dae5ed345..66745f4a199 100644 --- a/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java +++ b/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java @@ -78,7 +78,7 @@ private T testInvokeOnPool(ForkJoinPool pool, RecursiveTask a) { } } - void checkNotDone(RecursiveTask a) { + void checkNotDone(RecursiveTask a) { assertFalse(a.isDone()); assertFalse(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); @@ -149,7 +149,7 @@ void checkCompletedNormally(RecursiveTask a, int expectedValue) { checkCompletedNormally(a, r); } - void checkCancelled(RecursiveTask a) { + void checkCancelled(RecursiveTask a) { assertTrue(a.isDone()); assertTrue(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -176,7 +176,7 @@ void checkCancelled(RecursiveTask a) { } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedAbnormally(RecursiveTask a, Throwable t) { + void checkCompletedAbnormally(RecursiveTask a, Throwable t) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); @@ -255,7 +255,7 @@ public Integer compute() { * returns value; */ public void testInvoke() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); Integer r = f.invoke(); @@ -272,7 +272,7 @@ public Integer realCompute() { * completed tasks */ public void testQuietlyInvoke() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); f.quietlyInvoke(); @@ -286,7 +286,7 @@ public Integer realCompute() { * join of a forked task returns when task completes */ public void testForkJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertSame(f, f.fork()); @@ -302,7 +302,7 @@ public Integer realCompute() { * get of a forked task returns when task completes */ public void testForkGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FibTask f = new FibTask(8); assertSame(f, f.fork()); @@ -318,7 +318,7 @@ public Integer realCompute() throws Exception { * timed get of a forked task returns when task completes */ public void testForkTimedGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FibTask f = new FibTask(8); assertSame(f, f.fork()); @@ -334,7 +334,7 @@ public Integer realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertSame(f, f.fork()); @@ -352,7 +352,7 @@ public Integer realCompute() { * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesce() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertSame(f, f.fork()); @@ -370,7 +370,7 @@ public Integer realCompute() { * invoke task throws exception when task completes abnormally */ public void testAbnormalInvoke() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); try { @@ -388,7 +388,7 @@ public Integer realCompute() { * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvoke() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); f.quietlyInvoke(); @@ -403,12 +403,12 @@ public Integer realCompute() { * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); assertSame(f, f.fork()); try { - Integer r = f.join(); + f.join(); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success); @@ -422,12 +422,12 @@ public Integer realCompute() { * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FailingFibTask f = new FailingFibTask(8); assertSame(f, f.fork()); try { - Integer r = f.get(); + f.get(); shouldThrow(); } catch (ExecutionException success) { Throwable cause = success.getCause(); @@ -443,12 +443,12 @@ public Integer realCompute() throws Exception { * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FailingFibTask f = new FailingFibTask(8); assertSame(f, f.fork()); try { - Integer r = f.get(LONG_DELAY_MS, MILLISECONDS); + f.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (ExecutionException success) { Throwable cause = success.getCause(); @@ -464,7 +464,7 @@ public Integer realCompute() throws Exception { * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); assertSame(f, f.fork()); @@ -480,12 +480,12 @@ public Integer realCompute() { * invoke task throws exception when task cancelled */ public void testCancelledInvoke() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertTrue(f.cancel(true)); try { - Integer r = f.invoke(); + f.invoke(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); @@ -499,13 +499,13 @@ public Integer realCompute() { * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { - Integer r = f.join(); + f.join(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); @@ -519,13 +519,13 @@ public Integer realCompute() { * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FibTask f = new FibTask(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { - Integer r = f.get(); + f.get(); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); @@ -539,13 +539,13 @@ public Integer realCompute() throws Exception { * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGet() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() throws Exception { FibTask f = new FibTask(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { - Integer r = f.get(LONG_DELAY_MS, MILLISECONDS); + f.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (CancellationException success) { checkCancelled(f); @@ -559,7 +559,7 @@ public Integer realCompute() throws Exception { * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoin() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); assertTrue(f.cancel(true)); @@ -576,7 +576,7 @@ public Integer realCompute() { */ public void testGetPool() { final ForkJoinPool mainPool = mainPool(); - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { assertSame(mainPool, getPool()); return NoResult; @@ -588,7 +588,7 @@ public Integer realCompute() { * getPool of non-FJ task returns null */ public void testGetPool2() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { assertNull(getPool()); return NoResult; @@ -600,7 +600,7 @@ public Integer realCompute() { * inForkJoinPool of executing task returns true */ public void testInForkJoinPool() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { assertTrue(inForkJoinPool()); return NoResult; @@ -612,7 +612,7 @@ public Integer realCompute() { * inForkJoinPool of non-FJ task returns false */ public void testInForkJoinPool2() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { assertFalse(inForkJoinPool()); return NoResult; @@ -624,7 +624,7 @@ public Integer realCompute() { * The value set by setRawResult is returned by getRawResult */ public void testSetRawResult() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { setRawResult(NoResult); assertSame(NoResult, getRawResult()); @@ -638,7 +638,7 @@ public Integer realCompute() { * A reinitialized normally completed task may be re-invoked */ public void testReinitialize() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); checkNotDone(f); @@ -660,7 +660,7 @@ public Integer realCompute() { * A reinitialized abnormally completed task may be re-invoked */ public void testReinitializeAbnormal() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); checkNotDone(f); @@ -684,12 +684,12 @@ public Integer realCompute() { * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionally() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); f.completeExceptionally(new FJException()); try { - Integer r = f.invoke(); + f.invoke(); shouldThrow(); } catch (FJException success) { checkCompletedAbnormally(f, success); @@ -703,7 +703,7 @@ public Integer realCompute() { * invoke task suppresses execution invoking complete */ public void testComplete() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); f.complete(NoResult); @@ -719,7 +719,7 @@ public Integer realCompute() { * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FibTask g = new FibTask(9); @@ -735,7 +735,7 @@ public Integer realCompute() { * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); invokeAll(f); @@ -749,7 +749,7 @@ public Integer realCompute() { * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FibTask g = new FibTask(9); @@ -770,12 +770,12 @@ public Integer realCompute() { * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollection() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FibTask g = new FibTask(9); FibTask h = new FibTask(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -795,7 +795,7 @@ public Integer realCompute() { * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPE() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FibTask g = new FibTask(9); @@ -813,7 +813,7 @@ public Integer realCompute() { * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FailingFibTask g = new FailingFibTask(9); @@ -832,7 +832,7 @@ public Integer realCompute() { * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask g = new FailingFibTask(9); try { @@ -850,7 +850,7 @@ public Integer realCompute() { * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask f = new FibTask(8); FailingFibTask g = new FailingFibTask(9); @@ -870,12 +870,12 @@ public Integer realCompute() { * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollection() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FailingFibTask f = new FailingFibTask(8); FibTask g = new FibTask(9); FibTask h = new FibTask(7); - HashSet set = new HashSet(); + HashSet> set = new HashSet<>(); set.add(f); set.add(g); set.add(h); @@ -895,7 +895,7 @@ public Integer realCompute() { * and suppresses execution */ public void testTryUnfork() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -915,7 +915,7 @@ public Integer realCompute() { * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask h = new FibTask(7); assertSame(h, h.fork()); @@ -938,7 +938,7 @@ public Integer realCompute() { * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -958,7 +958,7 @@ public Integer realCompute() { * without executing it */ public void testPollNextLocalTask() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -977,7 +977,7 @@ public Integer realCompute() { * pollTask returns an unexecuted task without executing it */ public void testPollTask() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -996,7 +996,7 @@ public Integer realCompute() { * peekNextLocalTask returns least recent unexecuted task in async mode */ public void testPeekNextLocalTaskAsync() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -1017,7 +1017,7 @@ public Integer realCompute() { * executing it, in async mode */ public void testPollNextLocalTaskAsync() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); @@ -1037,7 +1037,7 @@ public Integer realCompute() { * async mode */ public void testPollTaskAsync() { - RecursiveTask a = new CheckedRecursiveTask() { + RecursiveTask a = new CheckedRecursiveTask<>() { public Integer realCompute() { FibTask g = new FibTask(9); assertSame(g, g.fork()); diff --git a/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java b/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java index 804f1fb8374..43091f9e8f7 100644 --- a/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java +++ b/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java @@ -150,13 +150,13 @@ public void testSchedule1() throws Exception { final CustomExecutor p = new CustomExecutor(1); try (PoolCleaner cleaner = cleaner(p, done)) { final long startTime = System.nanoTime(); - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); return Boolean.TRUE; }}; - Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); + Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); assertSame(Boolean.TRUE, f.get()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } @@ -175,7 +175,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); + Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); await(done); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); @@ -195,7 +195,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - ScheduledFuture f = + ScheduledFuture f = p.scheduleAtFixedRate(task, timeoutMillis(), LONG_DELAY_MS, MILLISECONDS); await(done); @@ -217,7 +217,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - ScheduledFuture f = + ScheduledFuture f = p.scheduleWithFixedDelay(task, timeoutMillis(), LONG_DELAY_MS, MILLISECONDS); await(done); @@ -245,7 +245,7 @@ public void testFixedRateSequence() throws InterruptedException { final CountDownLatch done = new CountDownLatch(cycles); final Runnable task = new CheckedRunnable() { public void realRun() { done.countDown(); }}; - final ScheduledFuture periodicTask = + final ScheduledFuture periodicTask = p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS); final int totalDelayMillis = (cycles - 1) * delay; await(done, totalDelayMillis + LONG_DELAY_MS); @@ -291,7 +291,7 @@ public void realRun() { previous.set(now); done.countDown(); }}; - final ScheduledFuture periodicTask = + final ScheduledFuture periodicTask = p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS); final int totalDelayMillis = (cycles - 1) * delay; await(done, totalDelayMillis + cycles * LONG_DELAY_MS); @@ -618,7 +618,8 @@ public void testGetQueue() throws InterruptedException { final ScheduledThreadPoolExecutor p = new CustomExecutor(1); try (PoolCleaner cleaner = cleaner(p, done)) { final CountDownLatch threadStarted = new CountDownLatch(1); - ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; for (int i = 0; i < tasks.length; i++) { Runnable r = new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -641,7 +642,8 @@ public void testRemove() throws InterruptedException { final CountDownLatch done = new CountDownLatch(1); final ScheduledThreadPoolExecutor p = new CustomExecutor(1); try (PoolCleaner cleaner = cleaner(p, done)) { - ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; final CountDownLatch threadStarted = new CountDownLatch(1); for (int i = 0; i < tasks.length; i++) { Runnable r = new CheckedRunnable() { @@ -669,9 +671,10 @@ public void realRun() throws InterruptedException { * purge removes cancelled tasks from the queue */ public void testPurge() throws InterruptedException { - final ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; final Runnable releaser = new Runnable() { public void run() { - for (ScheduledFuture task : tasks) + for (ScheduledFuture task : tasks) if (task != null) task.cancel(true); }}; final CustomExecutor p = new CustomExecutor(1); try (PoolCleaner cleaner = cleaner(p, releaser)) { @@ -737,7 +740,7 @@ public void testShutdownNow() throws InterruptedException { */ public void testShutdownNow_delayedTasks() throws InterruptedException { final CustomExecutor p = new CustomExecutor(1); - List tasks = new ArrayList<>(); + List> tasks = new ArrayList<>(); for (int i = 0; i < 3; i++) { Runnable r = new NoOpRunnable(); tasks.add(p.schedule(r, 9, SECONDS)); @@ -745,7 +748,7 @@ public void testShutdownNow_delayedTasks() throws InterruptedException { tasks.add(p.scheduleWithFixedDelay(r, 9, 9, SECONDS)); } if (testImplementationDetails) - assertEquals(new HashSet(tasks), new HashSet(p.getQueue())); + assertEquals(new HashSet(tasks), new HashSet(p.getQueue())); final List queuedTasks; try { queuedTasks = p.shutdownNow(); @@ -755,9 +758,9 @@ public void testShutdownNow_delayedTasks() throws InterruptedException { assertTrue(p.isShutdown()); assertTrue(p.getQueue().isEmpty()); if (testImplementationDetails) - assertEquals(new HashSet(tasks), new HashSet(queuedTasks)); + assertEquals(new HashSet(tasks), new HashSet(queuedTasks)); assertEquals(tasks.size(), queuedTasks.size()); - for (ScheduledFuture task : tasks) { + for (ScheduledFuture task : tasks) { assertFalse(((CustomTask)task).ran); assertFalse(task.isDone()); assertFalse(task.isCancelled()); @@ -1340,7 +1343,7 @@ public void testTimedInvokeAll5() throws Exception { public void testTimedInvokeAll6() throws Exception { for (long timeout = timeoutMillis();;) { final CountDownLatch done = new CountDownLatch(1); - final Callable waiter = new CheckedCallable() { + final Callable waiter = new CheckedCallable<>() { public String realCall() { try { done.await(LONG_DELAY_MS, MILLISECONDS); } catch (InterruptedException ok) {} @@ -1356,7 +1359,7 @@ public String realCall() { p.invokeAll(tasks, timeout, MILLISECONDS); assertEquals(tasks.size(), futures.size()); assertTrue(millisElapsedSince(startTime) >= timeout); - for (Future future : futures) + for (Future future : futures) assertTrue(future.isDone()); assertTrue(futures.get(1).isCancelled()); try { diff --git a/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java b/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java index 074f3201d99..c100ea0e8f0 100644 --- a/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java +++ b/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java @@ -93,13 +93,13 @@ public void testSchedule1() throws Exception { try (PoolCleaner cleaner = cleaner(p)) { final long startTime = System.nanoTime(); final CountDownLatch done = new CountDownLatch(1); - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); return Boolean.TRUE; }}; - Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); + Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); assertSame(Boolean.TRUE, f.get()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); assertEquals(0L, done.getCount()); @@ -119,7 +119,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); + Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); await(done); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); @@ -139,7 +139,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - ScheduledFuture f = + ScheduledFuture f = p.scheduleAtFixedRate(task, timeoutMillis(), LONG_DELAY_MS, MILLISECONDS); await(done); @@ -161,7 +161,7 @@ public void realRun() { done.countDown(); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); }}; - ScheduledFuture f = + ScheduledFuture f = p.scheduleWithFixedDelay(task, timeoutMillis(), LONG_DELAY_MS, MILLISECONDS); await(done); @@ -189,7 +189,7 @@ public void testFixedRateSequence() throws InterruptedException { final CountDownLatch done = new CountDownLatch(cycles); final Runnable task = new CheckedRunnable() { public void realRun() { done.countDown(); }}; - final ScheduledFuture periodicTask = + final ScheduledFuture periodicTask = p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS); final int totalDelayMillis = (cycles - 1) * delay; await(done, totalDelayMillis + LONG_DELAY_MS); @@ -235,7 +235,7 @@ public void realRun() { previous.set(now); done.countDown(); }}; - final ScheduledFuture periodicTask = + final ScheduledFuture periodicTask = p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS); final int totalDelayMillis = (cycles - 1) * delay; await(done, totalDelayMillis + cycles * LONG_DELAY_MS); @@ -576,7 +576,8 @@ public void testGetQueue() throws InterruptedException { final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); try (PoolCleaner cleaner = cleaner(p, done)) { final CountDownLatch threadStarted = new CountDownLatch(1); - ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; for (int i = 0; i < tasks.length; i++) { Runnable r = new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -599,7 +600,8 @@ public void testRemove() throws InterruptedException { final CountDownLatch done = new CountDownLatch(1); final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); try (PoolCleaner cleaner = cleaner(p, done)) { - ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; final CountDownLatch threadStarted = new CountDownLatch(1); for (int i = 0; i < tasks.length; i++) { Runnable r = new CheckedRunnable() { @@ -627,9 +629,10 @@ public void realRun() throws InterruptedException { * purge eventually removes cancelled tasks from the queue */ public void testPurge() throws InterruptedException { - final ScheduledFuture[] tasks = new ScheduledFuture[5]; + @SuppressWarnings("unchecked") + ScheduledFuture[] tasks = (ScheduledFuture[])new ScheduledFuture[5]; final Runnable releaser = new Runnable() { public void run() { - for (ScheduledFuture task : tasks) + for (ScheduledFuture task : tasks) if (task != null) task.cancel(true); }}; final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); try (PoolCleaner cleaner = cleaner(p, releaser)) { @@ -696,7 +699,7 @@ public void testShutdownNow() throws InterruptedException { */ public void testShutdownNow_delayedTasks() throws InterruptedException { final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); - List tasks = new ArrayList<>(); + List> tasks = new ArrayList<>(); for (int i = 0; i < 3; i++) { Runnable r = new NoOpRunnable(); tasks.add(p.schedule(r, 9, SECONDS)); @@ -704,7 +707,7 @@ public void testShutdownNow_delayedTasks() throws InterruptedException { tasks.add(p.scheduleWithFixedDelay(r, 9, 9, SECONDS)); } if (testImplementationDetails) - assertEquals(new HashSet(tasks), new HashSet(p.getQueue())); + assertEquals(new HashSet(tasks), new HashSet(p.getQueue())); final List queuedTasks; try { queuedTasks = p.shutdownNow(); @@ -714,9 +717,9 @@ public void testShutdownNow_delayedTasks() throws InterruptedException { assertTrue(p.isShutdown()); assertTrue(p.getQueue().isEmpty()); if (testImplementationDetails) - assertEquals(new HashSet(tasks), new HashSet(queuedTasks)); + assertEquals(new HashSet(tasks), new HashSet(queuedTasks)); assertEquals(tasks.size(), queuedTasks.size()); - for (ScheduledFuture task : tasks) { + for (ScheduledFuture task : tasks) { assertFalse(task.isDone()); assertFalse(task.isCancelled()); } @@ -1299,7 +1302,7 @@ public void testTimedInvokeAll5() throws Exception { public void testTimedInvokeAll6() throws Exception { for (long timeout = timeoutMillis();;) { final CountDownLatch done = new CountDownLatch(1); - final Callable waiter = new CheckedCallable() { + final Callable waiter = new CheckedCallable<>() { public String realCall() { try { done.await(LONG_DELAY_MS, MILLISECONDS); } catch (InterruptedException ok) {} @@ -1315,7 +1318,7 @@ public String realCall() { p.invokeAll(tasks, timeout, MILLISECONDS); assertEquals(tasks.size(), futures.size()); assertTrue(millisElapsedSince(startTime) >= timeout); - for (Future future : futures) + for (Future future : futures) assertTrue(future.isDone()); assertTrue(futures.get(1).isCancelled()); try { diff --git a/test/jdk/java/util/concurrent/tck/SplittableRandomTest.java b/test/jdk/java/util/concurrent/tck/SplittableRandomTest.java index f9544c9c903..38f4fecefc1 100644 --- a/test/jdk/java/util/concurrent/tck/SplittableRandomTest.java +++ b/test/jdk/java/util/concurrent/tck/SplittableRandomTest.java @@ -39,6 +39,9 @@ import java.lang.reflect.Method; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; import junit.framework.Test; import junit.framework.TestSuite; @@ -357,12 +360,12 @@ public void testBadStreamSize() { SplittableRandom r = new SplittableRandom(); assertThrows( IllegalArgumentException.class, - () -> { java.util.stream.IntStream x = r.ints(-1L); }, - () -> { java.util.stream.IntStream x = r.ints(-1L, 2, 3); }, - () -> { java.util.stream.LongStream x = r.longs(-1L); }, - () -> { java.util.stream.LongStream x = r.longs(-1L, -1L, 1L); }, - () -> { java.util.stream.DoubleStream x = r.doubles(-1L); }, - () -> { java.util.stream.DoubleStream x = r.doubles(-1L, .5, .6); }); + () -> { IntStream unused = r.ints(-1L); }, + () -> { IntStream unused = r.ints(-1L, 2, 3); }, + () -> { LongStream unused = r.longs(-1L); }, + () -> { LongStream unused = r.longs(-1L, -1L, 1L); }, + () -> { DoubleStream unused = r.doubles(-1L); }, + () -> { DoubleStream unused = r.doubles(-1L, .5, .6); }); } /** @@ -373,12 +376,12 @@ public void testBadStreamBounds() { SplittableRandom r = new SplittableRandom(); assertThrows( IllegalArgumentException.class, - () -> { java.util.stream.IntStream x = r.ints(2, 1); }, - () -> { java.util.stream.IntStream x = r.ints(10, 42, 42); }, - () -> { java.util.stream.LongStream x = r.longs(-1L, -1L); }, - () -> { java.util.stream.LongStream x = r.longs(10, 1L, -2L); }, - () -> { java.util.stream.DoubleStream x = r.doubles(0.0, 0.0); }, - () -> { java.util.stream.DoubleStream x = r.doubles(10, .5, .4); }); + () -> { IntStream unused = r.ints(2, 1); }, + () -> { IntStream unused = r.ints(10, 42, 42); }, + () -> { LongStream unused = r.longs(-1L, -1L); }, + () -> { LongStream unused = r.longs(10, 1L, -2L); }, + () -> { DoubleStream unused = r.doubles(0.0, 0.0); }, + () -> { DoubleStream unused = r.doubles(10, .5, .4); }); } /** diff --git a/test/jdk/java/util/concurrent/tck/StampedLockTest.java b/test/jdk/java/util/concurrent/tck/StampedLockTest.java index a1ef302d998..673047ccf12 100644 --- a/test/jdk/java/util/concurrent/tck/StampedLockTest.java +++ b/test/jdk/java/util/concurrent/tck/StampedLockTest.java @@ -370,7 +370,7 @@ public void realRun() throws Throwable { */ public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted() { final StampedLock lock = new StampedLock(); - long s = lock.writeLock(); + long stamp = lock.writeLock(); Action[] interruptibleLockBlockingActions = { () -> lock.writeLockInterruptibly(), @@ -385,6 +385,8 @@ public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInter shuffle(interruptibleLockBlockingActions); assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions); + + releaseWriteLock(lock, stamp); } /** @@ -392,7 +394,7 @@ public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInter */ public void testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterrupted() { final StampedLock lock = new StampedLock(); - long s = lock.readLock(); + long stamp = lock.readLock(); Action[] interruptibleLockBlockingActions = { () -> lock.writeLockInterruptibly(), @@ -403,6 +405,8 @@ public void testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterr shuffle(interruptibleLockBlockingActions); assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions); + + releaseReadLock(lock, stamp); } /** @@ -726,6 +730,7 @@ public void testToString() { lock.unlockWrite(s); s = lock.readLock(); assertTrue(lock.toString().contains("Read-locks")); + releaseReadLock(lock, s); } /** @@ -1423,7 +1428,7 @@ public void testConcurrentAccess() throws Exception { final long testDurationMillis = expensiveTests ? 1000 : 2; final int nTasks = ThreadLocalRandom.current().nextInt(1, 10); final AtomicBoolean done = new AtomicBoolean(false); - final List futures = new ArrayList<>(); + final List> futures = new ArrayList<>(); final List> stampedWriteLockers = List.of( () -> sl.writeLock(), () -> writeLockInterruptiblyUninterrupted(sl), diff --git a/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java b/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java index 2f153ee5d6b..c47e66c6727 100644 --- a/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java +++ b/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java @@ -682,7 +682,7 @@ static boolean noopHandle(AtomicInteger count) { return false; } - static boolean reqHandle(AtomicInteger count, Subscriber s) { + static boolean reqHandle(AtomicInteger count, Subscriber s) { count.getAndIncrement(); ((TestSubscriber)s).sn.request(Long.MAX_VALUE); return true; @@ -985,7 +985,7 @@ public void testConsume() { public void testConsumeNPE() { SubmissionPublisher p = basicPublisher(); try { - CompletableFuture f = p.consume(null); + CompletableFuture unused = p.consume(null); shouldThrow(); } catch (NullPointerException success) {} } diff --git a/test/jdk/java/util/concurrent/tck/SynchronousQueueTest.java b/test/jdk/java/util/concurrent/tck/SynchronousQueueTest.java index 00f66a29950..7d17fac4d35 100644 --- a/test/jdk/java/util/concurrent/tck/SynchronousQueueTest.java +++ b/test/jdk/java/util/concurrent/tck/SynchronousQueueTest.java @@ -78,10 +78,10 @@ public static Test suite() { public void testEmptyFull() { testEmptyFull(false); } public void testEmptyFull_fair() { testEmptyFull(true); } public void testEmptyFull(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.size()); + mustEqual(0, q.remainingCapacity()); assertFalse(q.offer(zero)); } @@ -91,7 +91,7 @@ public void testEmptyFull(boolean fair) { public void testOffer() { testOffer(false); } public void testOffer_fair() { testOffer(true); } public void testOffer(boolean fair) { - SynchronousQueue q = new SynchronousQueue(fair); + SynchronousQueue q = new SynchronousQueue<>(fair); assertFalse(q.offer(one)); } @@ -101,8 +101,8 @@ public void testOffer(boolean fair) { public void testAdd() { testAdd(false); } public void testAdd_fair() { testAdd(true); } public void testAdd(boolean fair) { - SynchronousQueue q = new SynchronousQueue(fair); - assertEquals(0, q.remainingCapacity()); + SynchronousQueue q = new SynchronousQueue<>(fair); + mustEqual(0, q.remainingCapacity()); try { q.add(one); shouldThrow(); @@ -115,24 +115,22 @@ public void testAdd(boolean fair) { public void testAddAll_self() { testAddAll_self(false); } public void testAddAll_self_fair() { testAddAll_self(true); } public void testAddAll_self(boolean fair) { - SynchronousQueue q = new SynchronousQueue(fair); + SynchronousQueue q = new SynchronousQueue<>(fair); try { q.addAll(q); shouldThrow(); } catch (IllegalArgumentException success) {} } - /** + /**S * addAll throws IllegalStateException if no active taker */ public void testAddAll_ISE() { testAddAll_ISE(false); } public void testAddAll_ISE_fair() { testAddAll_ISE(true); } public void testAddAll_ISE(boolean fair) { - SynchronousQueue q = new SynchronousQueue(fair); - Integer[] ints = new Integer[1]; - for (int i = 0; i < ints.length; i++) - ints[i] = i; - Collection coll = Arrays.asList(ints); + SynchronousQueue q = new SynchronousQueue<>(fair); + Item[] items = seqItems(1); + Collection coll = Arrays.asList(items); try { q.addAll(coll); shouldThrow(); @@ -145,20 +143,20 @@ public void testAddAll_ISE(boolean fair) { public void testBlockingPut() { testBlockingPut(false); } public void testBlockingPut_fair() { testBlockingPut(true); } public void testBlockingPut(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -168,7 +166,7 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** @@ -177,7 +175,7 @@ public void realRun() throws InterruptedException { public void testPutWithTake() { testPutWithTake(false); } public void testPutWithTake_fair() { testPutWithTake(true); } public void testPutWithTake(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { @@ -187,21 +185,21 @@ public void realRun() throws InterruptedException { Thread.currentThread().interrupt(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.put(99); + q.put(ninetynine); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseTake); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); try { assertSame(one, q.take()); } catch (InterruptedException e) { threadUnexpectedException(e); } @@ -209,7 +207,7 @@ public void realRun() throws InterruptedException { if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); } /** @@ -217,25 +215,25 @@ public void realRun() throws InterruptedException { */ public void testTimedOffer() { final boolean fair = randomBoolean(); - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { long startTime = System.nanoTime(); - assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); + assertFalse(q.offer(zero, timeoutMillis(), MILLISECONDS)); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); Thread.currentThread().interrupt(); try { - q.offer(new Object(), randomTimeout(), randomTimeUnit()); + q.offer(one, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { - q.offer(new Object(), LONGER_DELAY_MS, MILLISECONDS); + q.offer(two, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -253,7 +251,7 @@ public void realRun() throws InterruptedException { public void testPoll() { testPoll(false); } public void testPoll_fair() { testPoll(true); } public void testPoll(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); assertNull(q.poll()); } @@ -263,7 +261,7 @@ public void testPoll(boolean fair) { public void testTimedPoll0() { testTimedPoll0(false); } public void testTimedPoll0_fair() { testTimedPoll0(true); } public void testTimedPoll0(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); try { assertNull(q.poll(0, MILLISECONDS)); } catch (InterruptedException e) { threadUnexpectedException(e); } } @@ -273,7 +271,7 @@ public void testTimedPoll0(boolean fair) { */ public void testTimedPoll() { final boolean fair = randomBoolean(); - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final long startTime = System.nanoTime(); try { assertNull(q.poll(timeoutMillis(), MILLISECONDS)); } catch (InterruptedException e) { threadUnexpectedException(e); } @@ -286,7 +284,7 @@ public void testTimedPoll() { */ public void testTimedPollWithOffer() { final boolean fair = randomBoolean(); - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CountDownLatch pleaseOffer = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { @@ -334,7 +332,7 @@ public void realRun() throws InterruptedException { public void testPeek() { testPeek(false); } public void testPeek_fair() { testPeek(true); } public void testPeek(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); assertNull(q.peek()); } @@ -344,7 +342,7 @@ public void testPeek(boolean fair) { public void testElement() { testElement(false); } public void testElement_fair() { testElement(true); } public void testElement(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); try { q.element(); shouldThrow(); @@ -357,7 +355,7 @@ public void testElement(boolean fair) { public void testRemove() { testRemove(false); } public void testRemove_fair() { testRemove(true); } public void testRemove(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); try { q.remove(); shouldThrow(); @@ -370,7 +368,7 @@ public void testRemove(boolean fair) { public void testContains() { testContains(false); } public void testContains_fair() { testContains(true); } public void testContains(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); assertFalse(q.contains(zero)); } @@ -380,7 +378,7 @@ public void testContains(boolean fair) { public void testClear() { testClear(false); } public void testClear_fair() { testClear(true); } public void testClear(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); q.clear(); assertTrue(q.isEmpty()); } @@ -391,11 +389,11 @@ public void testClear(boolean fair) { public void testContainsAll() { testContainsAll(false); } public void testContainsAll_fair() { testContainsAll(true); } public void testContainsAll(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); - Integer[] empty = new Integer[0]; + final SynchronousQueue q = new SynchronousQueue<>(fair); + Item[] empty = new Item[0]; assertTrue(q.containsAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.containsAll(Arrays.asList(ints))); + Item[] items = new Item[1]; items[0] = zero; + assertFalse(q.containsAll(Arrays.asList(items))); } /** @@ -404,11 +402,11 @@ public void testContainsAll(boolean fair) { public void testRetainAll() { testRetainAll(false); } public void testRetainAll_fair() { testRetainAll(true); } public void testRetainAll(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); - Integer[] empty = new Integer[0]; + final SynchronousQueue q = new SynchronousQueue<>(fair); + Item[] empty = new Item[0]; assertFalse(q.retainAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.retainAll(Arrays.asList(ints))); + Item[] items = new Item[1]; items[0] = zero; + assertFalse(q.retainAll(Arrays.asList(items))); } /** @@ -417,11 +415,11 @@ public void testRetainAll(boolean fair) { public void testRemoveAll() { testRemoveAll(false); } public void testRemoveAll_fair() { testRemoveAll(true); } public void testRemoveAll(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); - Integer[] empty = new Integer[0]; + final SynchronousQueue q = new SynchronousQueue<>(fair); + Item[] empty = new Item[0]; assertFalse(q.removeAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.containsAll(Arrays.asList(ints))); + Item[] items = new Item[1]; items[0] = zero; + assertFalse(q.containsAll(Arrays.asList(items))); } /** @@ -430,30 +428,30 @@ public void testRemoveAll(boolean fair) { public void testToArray() { testToArray(false); } public void testToArray_fair() { testToArray(true); } public void testToArray(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); Object[] o = q.toArray(); - assertEquals(0, o.length); + mustEqual(0, o.length); } /** - * toArray(Integer array) returns its argument with the first + * toArray(Item array) returns its argument with the first * element (if present) nulled out */ public void testToArray2() { testToArray2(false); } public void testToArray2_fair() { testToArray2(true); } public void testToArray2(boolean fair) { - final SynchronousQueue q = new SynchronousQueue<>(fair); - Integer[] a; + final SynchronousQueue q = new SynchronousQueue<>(fair); + Item[] a; - a = new Integer[0]; + a = new Item[0]; assertSame(a, q.toArray(a)); - a = new Integer[3]; - Arrays.fill(a, 42); + a = new Item[3]; + Arrays.fill(a, fortytwo); assertSame(a, q.toArray(a)); assertNull(a[0]); for (int i = 1; i < a.length; i++) - assertEquals(42, (int) a[i]); + mustEqual(42, a[i]); } /** @@ -462,9 +460,9 @@ public void testToArray2(boolean fair) { public void testToArray_null() { testToArray_null(false); } public void testToArray_null_fair() { testToArray_null(true); } public void testToArray_null(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); try { - Object[] o = q.toArray((Object[])null); + Object[] unused = q.toArray((Object[])null); shouldThrow(); } catch (NullPointerException success) {} } @@ -475,7 +473,7 @@ public void testToArray_null(boolean fair) { public void testIterator() { testIterator(false); } public void testIterator_fair() { testIterator(true); } public void testIterator(boolean fair) { - assertIteratorExhausted(new SynchronousQueue(fair).iterator()); + assertIteratorExhausted(new SynchronousQueue(fair).iterator()); } /** @@ -484,8 +482,8 @@ public void testIterator(boolean fair) { public void testIteratorRemove() { testIteratorRemove(false); } public void testIteratorRemove_fair() { testIteratorRemove(true); } public void testIteratorRemove(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); - Iterator it = q.iterator(); + final SynchronousQueue q = new SynchronousQueue<>(fair); + Iterator it = q.iterator(); try { it.remove(); shouldThrow(); @@ -498,7 +496,7 @@ public void testIteratorRemove(boolean fair) { public void testToString() { testToString(false); } public void testToString_fair() { testToString(true); } public void testToString(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); String s = q.toString(); assertNotNull(s); } @@ -509,7 +507,7 @@ public void testToString(boolean fair) { public void testOfferInExecutor() { testOfferInExecutor(false); } public void testOfferInExecutor_fair() { testOfferInExecutor(true); } public void testOfferInExecutor(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -519,7 +517,7 @@ public void realRun() throws InterruptedException { assertFalse(q.offer(one)); threadsStarted.await(); assertTrue(q.offer(one, LONG_DELAY_MS, MILLISECONDS)); - assertEquals(0, q.remainingCapacity()); + mustEqual(0, q.remainingCapacity()); }}); executor.execute(new CheckedRunnable() { @@ -536,7 +534,7 @@ public void realRun() throws InterruptedException { public void testPollInExecutor() { testPollInExecutor(false); } public void testPollInExecutor_fair() { testPollInExecutor(true); } public void testPollInExecutor(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -560,19 +558,21 @@ public void realRun() throws InterruptedException { * a deserialized/reserialized queue is usable */ public void testSerialization() { - final SynchronousQueue x = new SynchronousQueue(); - final SynchronousQueue y = new SynchronousQueue(false); - final SynchronousQueue z = new SynchronousQueue(true); + final SynchronousQueue x = new SynchronousQueue<>(); + final SynchronousQueue y = new SynchronousQueue<>(false); + final SynchronousQueue z = new SynchronousQueue<>(true); assertSerialEquals(x, y); assertNotSerialEquals(x, z); - SynchronousQueue[] qs = { x, y, z }; - for (SynchronousQueue q : qs) { - SynchronousQueue clone = serialClone(q); + SynchronousQueue[] rqs = { x, y, z }; + @SuppressWarnings("unchecked") + SynchronousQueue[] qs = (SynchronousQueue[])rqs; + for (SynchronousQueue q : qs) { + SynchronousQueue clone = serialClone(q); assertNotSame(q, clone); assertSerialEquals(q, clone); assertTrue(clone.isEmpty()); - assertEquals(0, clone.size()); - assertEquals(0, clone.remainingCapacity()); + mustEqual(0, clone.size()); + mustEqual(0, clone.remainingCapacity()); assertFalse(clone.offer(zero)); } } @@ -583,11 +583,11 @@ public void testSerialization() { public void testDrainTo() { testDrainTo(false); } public void testDrainTo_fair() { testDrainTo(true); } public void testDrainTo(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); - ArrayList l = new ArrayList(); + final SynchronousQueue q = new SynchronousQueue<>(fair); + ArrayList l = new ArrayList<>(); q.drainTo(l); - assertEquals(0, q.size()); - assertEquals(0, l.size()); + mustEqual(0, q.size()); + mustEqual(0, l.size()); } /** @@ -596,13 +596,13 @@ public void testDrainTo(boolean fair) { public void testDrainToWithActivePut() { testDrainToWithActivePut(false); } public void testDrainToWithActivePut_fair() { testDrainToWithActivePut(true); } public void testDrainToWithActivePut(boolean fair) { - final SynchronousQueue q = new SynchronousQueue(fair); + final SynchronousQueue q = new SynchronousQueue<>(fair); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.put(one); }}); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); long startTime = System.nanoTime(); while (l.isEmpty()) { q.drainTo(l); @@ -610,7 +610,7 @@ public void realRun() throws InterruptedException { fail("timed out"); Thread.yield(); } - assertEquals(1, l.size()); + mustEqual(1, l.size()); assertSame(one, l.get(0)); awaitTermination(t); } @@ -619,7 +619,7 @@ public void realRun() throws InterruptedException { * drainTo(c, n) empties up to n elements of queue into c */ public void testDrainToN() throws InterruptedException { - final SynchronousQueue q = new SynchronousQueue(); + final SynchronousQueue q = new SynchronousQueue<>(); Thread t1 = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.put(one); @@ -630,14 +630,14 @@ public void realRun() throws InterruptedException { q.put(two); }}); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); int drained; while ((drained = q.drainTo(l, 1)) == 0) Thread.yield(); - assertEquals(1, drained); - assertEquals(1, l.size()); + mustEqual(1, drained); + mustEqual(1, l.size()); while ((drained = q.drainTo(l, 1)) == 0) Thread.yield(); - assertEquals(1, drained); - assertEquals(2, l.size()); + mustEqual(1, drained); + mustEqual(2, l.size()); assertTrue(l.contains(one)); assertTrue(l.contains(two)); awaitTermination(t1); @@ -648,7 +648,7 @@ public void realRun() throws InterruptedException { * remove(null), contains(null) always return false */ public void testNeverContainsNull() { - Collection q = new SynchronousQueue(); + Collection q = new SynchronousQueue<>(); assertFalse(q.contains(null)); assertFalse(q.remove(null)); } diff --git a/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java b/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java index 0100cf3c8ca..3159dfbaa4a 100644 --- a/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java +++ b/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java @@ -384,27 +384,24 @@ public void testDifferentSequences() { new AtomicReference<>(); final AtomicLong rand = new AtomicLong(); - long firstRand = 0; - ThreadLocalRandom firstThreadLocalRandom = null; - Runnable getRandomState = new CheckedRunnable() { public void realRun() { ThreadLocalRandom current = ThreadLocalRandom.current(); assertSame(current, ThreadLocalRandom.current()); - // test bug: the following is not guaranteed and not true in JDK8 - // assertNotSame(current, threadLocalRandom.get()); rand.set(current.nextLong()); threadLocalRandom.set(current); }}; - Thread first = newStartedThread(getRandomState); - awaitTermination(first); - firstRand = rand.get(); - firstThreadLocalRandom = threadLocalRandom.get(); + awaitTermination(newStartedThread(getRandomState)); + long firstRand = rand.get(); + ThreadLocalRandom firstThreadLocalRandom = threadLocalRandom.get(); + assertNotNull(firstThreadLocalRandom); for (int i = 0; i < NCALLS; i++) { - Thread t = newStartedThread(getRandomState); - awaitTermination(t); + awaitTermination(newStartedThread(getRandomState)); + if (testImplementationDetails) + // ThreadLocalRandom has been a singleton since jdk8. + assertSame(firstThreadLocalRandom, threadLocalRandom.get()); if (firstRand != rand.get()) return; } diff --git a/test/jdk/java/util/concurrent/tck/ThreadLocalTest.java b/test/jdk/java/util/concurrent/tck/ThreadLocalTest.java index 51d2197f4d7..0f80dd63415 100644 --- a/test/jdk/java/util/concurrent/tck/ThreadLocalTest.java +++ b/test/jdk/java/util/concurrent/tck/ThreadLocalTest.java @@ -45,20 +45,20 @@ public static Test suite() { return new TestSuite(ThreadLocalTest.class); } - static ThreadLocal tl = new ThreadLocal() { - public Integer initialValue() { + static ThreadLocal tl = new ThreadLocal<>() { + public Item initialValue() { return one; } }; - static InheritableThreadLocal itl = - new InheritableThreadLocal() { - protected Integer initialValue() { + static InheritableThreadLocal itl = + new InheritableThreadLocal<>() { + protected Item initialValue() { return zero; } - protected Integer childValue(Integer parentValue) { - return new Integer(parentValue.intValue() + 1); + protected Item childValue(Item parentValue) { + return new Item(parentValue.intValue() + 1); } }; diff --git a/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java index 90b0837815d..dec00360f60 100644 --- a/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java +++ b/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java @@ -687,16 +687,18 @@ public void testGetQueue() throws InterruptedException { q); try (PoolCleaner cleaner = cleaner(p, done)) { final CountDownLatch threadStarted = new CountDownLatch(1); - FutureTask[] tasks = new FutureTask[5]; + FutureTask[] rtasks = new FutureTask[5]; + @SuppressWarnings("unchecked") + FutureTask[] tasks = (FutureTask[])rtasks; for (int i = 0; i < tasks.length; i++) { - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() throws InterruptedException { threadStarted.countDown(); assertSame(q, p.getQueue()); await(done); return Boolean.TRUE; }}; - tasks[i] = new FutureTask(task); + tasks[i] = new FutureTask<>(task); p.execute(tasks[i]); } await(threadStarted); @@ -753,15 +755,17 @@ public void testPurge() throws InterruptedException { LONG_DELAY_MS, MILLISECONDS, q); try (PoolCleaner cleaner = cleaner(p, done)) { - FutureTask[] tasks = new FutureTask[5]; + FutureTask[] rtasks = new FutureTask[5]; + @SuppressWarnings("unchecked") + FutureTask[] tasks = (FutureTask[])rtasks; for (int i = 0; i < tasks.length; i++) { - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() throws InterruptedException { threadStarted.countDown(); await(done); return Boolean.TRUE; }}; - tasks[i] = new FutureTask(task); + tasks[i] = new FutureTask<>(task); p.execute(tasks[i]); } await(threadStarted); @@ -1836,7 +1840,7 @@ public void testTimedInvokeAll5() throws Exception { public void testTimedInvokeAll6() throws Exception { for (long timeout = timeoutMillis();;) { final CountDownLatch done = new CountDownLatch(1); - final Callable waiter = new CheckedCallable() { + final Callable waiter = new CheckedCallable<>() { public String realCall() { try { done.await(LONG_DELAY_MS, MILLISECONDS); } catch (InterruptedException ok) {} @@ -1855,7 +1859,7 @@ public String realCall() { p.invokeAll(tasks, timeout, MILLISECONDS); assertEquals(tasks.size(), futures.size()); assertTrue(millisElapsedSince(startTime) >= timeout); - for (Future future : futures) + for (Future future : futures) assertTrue(future.isDone()); assertTrue(futures.get(1).isCancelled()); try { @@ -1993,7 +1997,7 @@ public void testGet_cancelled() throws Exception { } } } - + @SuppressWarnings("deprecation") public void testFinalizeMethodCallsSuperFinalize() { new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, diff --git a/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java index 7f69e9bf3bd..73e6deda987 100644 --- a/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java +++ b/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java @@ -590,16 +590,18 @@ public void testGetQueue() throws InterruptedException { q); try (PoolCleaner cleaner = cleaner(p, done)) { final CountDownLatch threadStarted = new CountDownLatch(1); - FutureTask[] tasks = new FutureTask[5]; + FutureTask[] rtasks = new FutureTask[5]; + @SuppressWarnings("unchecked") + FutureTask[] tasks = (FutureTask[])rtasks; for (int i = 0; i < tasks.length; i++) { - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() throws InterruptedException { threadStarted.countDown(); assertSame(q, p.getQueue()); await(done); return Boolean.TRUE; }}; - tasks[i] = new FutureTask(task); + tasks[i] = new FutureTask<>(task); p.execute(tasks[i]); } await(threadStarted); @@ -656,15 +658,17 @@ public void testPurge() throws InterruptedException { LONG_DELAY_MS, MILLISECONDS, q); try (PoolCleaner cleaner = cleaner(p, done)) { - FutureTask[] tasks = new FutureTask[5]; + FutureTask[] rtasks = new FutureTask[5]; + @SuppressWarnings("unchecked") + FutureTask[] tasks = (FutureTask[])rtasks; for (int i = 0; i < tasks.length; i++) { - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() throws InterruptedException { threadStarted.countDown(); await(done); return Boolean.TRUE; }}; - tasks[i] = new FutureTask(task); + tasks[i] = new FutureTask<>(task); p.execute(tasks[i]); } await(threadStarted); @@ -786,7 +790,7 @@ public void testConstructor5() { public void testConstructorNullPointerException() { try { new ThreadPoolExecutor(1, 2, 1L, SECONDS, - (BlockingQueue) null); + (BlockingQueue) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -857,7 +861,7 @@ public void testConstructor10() { public void testConstructorNullPointerException2() { try { new ThreadPoolExecutor(1, 2, 1L, SECONDS, - (BlockingQueue) null, + (BlockingQueue) null, new SimpleThreadFactory()); shouldThrow(); } catch (NullPointerException success) {} @@ -941,7 +945,7 @@ public void testConstructor15() { public void testConstructorNullPointerException4() { try { new ThreadPoolExecutor(1, 2, 1L, SECONDS, - (BlockingQueue) null, + (BlockingQueue) null, new NoOpREHandler()); shouldThrow(); } catch (NullPointerException success) {} @@ -1030,7 +1034,7 @@ public void testConstructor20() { public void testConstructorNullPointerException6() { try { new ThreadPoolExecutor(1, 2, 1L, SECONDS, - (BlockingQueue) null, + (BlockingQueue) null, new SimpleThreadFactory(), new NoOpREHandler()); shouldThrow(); @@ -1077,7 +1081,7 @@ public void testInterruptedSubmit() throws InterruptedException { final CountDownLatch threadStarted = new CountDownLatch(1); Thread t = newStartedThread(new CheckedInterruptedRunnable() { public void realRun() throws Exception { - Callable task = new CheckedCallable() { + Callable task = new CheckedCallable<>() { public Boolean realCall() throws InterruptedException { threadStarted.countDown(); await(done); @@ -1797,7 +1801,7 @@ public void testTimedInvokeAll5() throws Exception { public void testTimedInvokeAll6() throws Exception { for (long timeout = timeoutMillis();;) { final CountDownLatch done = new CountDownLatch(1); - final Callable waiter = new CheckedCallable() { + final Callable waiter = new CheckedCallable<>() { public String realCall() { try { done.await(LONG_DELAY_MS, MILLISECONDS); } catch (InterruptedException ok) {} @@ -1816,7 +1820,7 @@ public String realCall() { p.invokeAll(tasks, timeout, MILLISECONDS); assertEquals(tasks.size(), futures.size()); assertTrue(millisElapsedSince(startTime) >= timeout); - for (Future future : futures) + for (Future future : futures) assertTrue(future.isDone()); assertTrue(futures.get(1).isCancelled()); try { @@ -1931,7 +1935,7 @@ public void run() { final ThreadPoolExecutor p = new ThreadPoolExecutor(1, 30, 60, SECONDS, - new ArrayBlockingQueue(30)); + new ArrayBlockingQueue(30)); try (PoolCleaner cleaner = cleaner(p)) { for (int i = 0; i < nTasks; ++i) { for (;;) { diff --git a/test/jdk/java/util/concurrent/tck/TreeMapTest.java b/test/jdk/java/util/concurrent/tck/TreeMapTest.java index 73e1d3e9efe..f8d408f234b 100644 --- a/test/jdk/java/util/concurrent/tck/TreeMapTest.java +++ b/test/jdk/java/util/concurrent/tck/TreeMapTest.java @@ -64,10 +64,10 @@ class Implementation implements MapImplementation { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static TreeMap map5() { - TreeMap map = new TreeMap(); + private static TreeMap map5() { + TreeMap map = new TreeMap<>(); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(five, "E"); @@ -75,7 +75,7 @@ private static TreeMap map5() { map.put(two, "B"); map.put(four, "D"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map; } @@ -83,28 +83,28 @@ private static TreeMap map5() { * clear removes all pairs */ public void testClear() { - TreeMap map = map5(); + TreeMap map = map5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * copy constructor creates map equal to source map */ public void testConstructFromSorted() { - TreeMap map = map5(); - TreeMap map2 = new TreeMap(map); - assertEquals(map, map2); + TreeMap map = map5(); + TreeMap map2 = new TreeMap<>(map); + mustEqual(map, map2); } /** * Maps with same contents are equal */ public void testEquals() { - TreeMap map1 = map5(); - TreeMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + TreeMap map1 = map5(); + TreeMap map2 = map5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -114,7 +114,7 @@ public void testEquals() { * containsKey returns true for contained key */ public void testContainsKey() { - TreeMap map = map5(); + TreeMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); } @@ -123,7 +123,7 @@ public void testContainsKey() { * containsValue returns true for held values */ public void testContainsValue() { - TreeMap map = map5(); + TreeMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -133,9 +133,9 @@ public void testContainsValue() { * or null if not present */ public void testGet() { - TreeMap map = map5(); - assertEquals("A", (String)map.get(one)); - TreeMap empty = new TreeMap(); + TreeMap map = map5(); + mustEqual("A", map.get(one)); + TreeMap empty = new TreeMap<>(); assertNull(empty.get(one)); } @@ -143,8 +143,8 @@ public void testGet() { * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { - TreeMap empty = new TreeMap(); - TreeMap map = map5(); + TreeMap empty = new TreeMap<>(); + TreeMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -153,28 +153,28 @@ public void testIsEmpty() { * firstKey returns first key */ public void testFirstKey() { - TreeMap map = map5(); - assertEquals(one, map.firstKey()); + TreeMap map = map5(); + mustEqual(one, map.firstKey()); } /** * lastKey returns last key */ public void testLastKey() { - TreeMap map = map5(); - assertEquals(five, map.lastKey()); + TreeMap map = map5(); + mustEqual(five, map.lastKey()); } /** * keySet.toArray returns contains all keys */ public void testKeySetToArray() { - TreeMap map = map5(); - Set s = map.keySet(); + TreeMap map = map5(); + Set s = map.keySet(); Object[] ar = s.toArray(); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -182,12 +182,12 @@ public void testKeySetToArray() { * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { - TreeMap map = map5(); - Set s = map.descendingKeySet(); + TreeMap map = map5(); + Set s = map.descendingKeySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); - ar[0] = m10; + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -195,99 +195,99 @@ public void testDescendingKeySetToArray() { * keySet returns a Set containing all the keys */ public void testKeySet() { - TreeMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); + TreeMap map = map5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, one); + mustContain(s, two); + mustContain(s, three); + mustContain(s, four); + mustContain(s, five); } /** * keySet is ordered */ public void testKeySetOrder() { - TreeMap map = map5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + TreeMap map = map5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = i.next(); + mustEqual(last, one); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descending iterator of key set is inverse ordered */ public void testKeySetDescendingIteratorOrder() { - TreeMap map = map5(); - NavigableSet s = map.navigableKeySet(); - Iterator i = s.descendingIterator(); - Integer last = (Integer)i.next(); - assertEquals(last, five); + TreeMap map = map5(); + NavigableSet s = map.navigableKeySet(); + Iterator i = s.descendingIterator(); + Item last = (Item)i.next(); + mustEqual(last, five); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descendingKeySet is ordered */ public void testDescendingKeySetOrder() { - TreeMap map = map5(); - Set s = map.descendingKeySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, five); + TreeMap map = map5(); + Set s = map.descendingKeySet(); + Iterator i = s.iterator(); + Item last = (Item)i.next(); + mustEqual(last, five); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) > 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * descending iterator of descendingKeySet is ordered */ public void testDescendingKeySetDescendingIteratorOrder() { - TreeMap map = map5(); - NavigableSet s = map.descendingKeySet(); - Iterator i = s.descendingIterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + TreeMap map = map5(); + NavigableSet s = map.descendingKeySet(); + Iterator i = s.descendingIterator(); + Item last = (Item)i.next(); + mustEqual(last, one); int count = 1; while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) < 0); last = k; ++count; } - assertEquals(5, count); + mustEqual(5, count); } /** * values collection contains all values */ public void testValues() { - TreeMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); + TreeMap map = map5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -299,12 +299,12 @@ public void testValues() { * entrySet contains all pairs */ public void testEntrySet() { - TreeMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + TreeMap map = map5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -318,12 +318,12 @@ public void testEntrySet() { * descendingEntrySet contains all pairs */ public void testDescendingEntrySet() { - TreeMap map = map5(); - Set s = map.descendingMap().entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + TreeMap map = map5(); + Set> s = map.descendingMap().entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -337,10 +337,10 @@ public void testDescendingEntrySet() { * entrySet.toArray contains all entries */ public void testEntrySetToArray() { - TreeMap map = map5(); - Set s = map.entrySet(); + TreeMap map = map5(); + Set> s = map.entrySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); @@ -351,10 +351,10 @@ public void testEntrySetToArray() { * descendingEntrySet.toArray contains all entries */ public void testDescendingEntrySetToArray() { - TreeMap map = map5(); - Set s = map.descendingMap().entrySet(); + TreeMap map = map5(); + Set> s = map.descendingMap().entrySet(); Object[] ar = s.toArray(); - assertEquals(5, ar.length); + mustEqual(5, ar.length); for (int i = 0; i < 5; ++i) { assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); @@ -365,10 +365,10 @@ public void testDescendingEntrySetToArray() { * putAll adds all key-value pairs from the given map */ public void testPutAll() { - TreeMap empty = new TreeMap(); - TreeMap map = map5(); + TreeMap empty = new TreeMap<>(); + TreeMap map = map5(); empty.putAll(map); - assertEquals(5, empty.size()); + mustEqual(5, empty.size()); assertTrue(empty.containsKey(one)); assertTrue(empty.containsKey(two)); assertTrue(empty.containsKey(three)); @@ -380,9 +380,9 @@ public void testPutAll() { * remove removes the correct key-value pair from the map */ public void testRemove() { - TreeMap map = map5(); + TreeMap map = map5(); map.remove(five); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); } @@ -390,17 +390,17 @@ public void testRemove() { * lowerEntry returns preceding entry. */ public void testLowerEntry() { - TreeMap map = map5(); - Map.Entry e1 = map.lowerEntry(three); - assertEquals(two, e1.getKey()); + TreeMap map = map5(); + Map.Entry e1 = map.lowerEntry(three); + mustEqual(two, e1.getKey()); - Map.Entry e2 = map.lowerEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.lowerEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.lowerEntry(one); + Map.Entry e3 = map.lowerEntry(one); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -408,17 +408,17 @@ public void testLowerEntry() { * higherEntry returns next entry. */ public void testHigherEntry() { - TreeMap map = map5(); - Map.Entry e1 = map.higherEntry(three); - assertEquals(four, e1.getKey()); + TreeMap map = map5(); + Map.Entry e1 = map.higherEntry(three); + mustEqual(four, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.higherEntry(five); + Map.Entry e3 = map.higherEntry(five); assertNull(e3); - Map.Entry e4 = map.higherEntry(six); + Map.Entry e4 = map.higherEntry(six); assertNull(e4); } @@ -426,17 +426,17 @@ public void testHigherEntry() { * floorEntry returns preceding entry. */ public void testFloorEntry() { - TreeMap map = map5(); - Map.Entry e1 = map.floorEntry(three); - assertEquals(three, e1.getKey()); + TreeMap map = map5(); + Map.Entry e1 = map.floorEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.floorEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.floorEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.floorEntry(one); - assertEquals(one, e3.getKey()); + Map.Entry e3 = map.floorEntry(one); + mustEqual(one, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -444,17 +444,17 @@ public void testFloorEntry() { * ceilingEntry returns next entry. */ public void testCeilingEntry() { - TreeMap map = map5(); - Map.Entry e1 = map.ceilingEntry(three); - assertEquals(three, e1.getKey()); + TreeMap map = map5(); + Map.Entry e1 = map.ceilingEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(five); - assertEquals(five, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(five); + mustEqual(five, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(six); + Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); } @@ -462,12 +462,12 @@ public void testCeilingEntry() { * lowerKey returns preceding element */ public void testLowerKey() { - TreeMap q = map5(); + TreeMap q = map5(); Object e1 = q.lowerKey(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lowerKey(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lowerKey(one); assertNull(e3); @@ -480,12 +480,12 @@ public void testLowerKey() { * higherKey returns next element */ public void testHigherKey() { - TreeMap q = map5(); + TreeMap q = map5(); Object e1 = q.higherKey(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higherKey(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higherKey(five); assertNull(e3); @@ -498,15 +498,15 @@ public void testHigherKey() { * floorKey returns preceding element */ public void testFloorKey() { - TreeMap q = map5(); + TreeMap q = map5(); Object e1 = q.floorKey(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floorKey(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floorKey(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floorKey(zero); assertNull(e4); @@ -516,15 +516,15 @@ public void testFloorKey() { * ceilingKey returns next element */ public void testCeilingKey() { - TreeMap q = map5(); + TreeMap q = map5(); Object e1 = q.ceilingKey(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceilingKey(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceilingKey(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceilingKey(six); assertNull(e4); @@ -534,21 +534,21 @@ public void testCeilingKey() { * pollFirstEntry returns entries in order */ public void testPollFirstEntry() { - TreeMap map = map5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + TreeMap map = map5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(two, e.getKey()); + mustEqual(two, e.getKey()); map.put(one, "A"); e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(four); e = map.pollFirstEntry(); - assertEquals(five, e.getKey()); + mustEqual(five, e.getKey()); try { e.setValue("A"); shouldThrow(); @@ -561,21 +561,21 @@ public void testPollFirstEntry() { * pollLastEntry returns entries in order */ public void testPollLastEntry() { - TreeMap map = map5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + TreeMap map = map5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(four, e.getKey()); + mustEqual(four, e.getKey()); map.put(five, "E"); e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(two); e = map.pollLastEntry(); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -588,17 +588,17 @@ public void testPollLastEntry() { * size returns the correct values */ public void testSize() { - TreeMap map = map5(); - TreeMap empty = new TreeMap(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + TreeMap map = map5(); + TreeMap empty = new TreeMap<>(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testToString() { - TreeMap map = map5(); + TreeMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -611,7 +611,7 @@ public void testToString() { * get(null) of nonempty map throws NPE */ public void testGet_NullPointerException() { - TreeMap c = map5(); + TreeMap c = map5(); try { c.get(null); shouldThrow(); @@ -622,7 +622,7 @@ public void testGet_NullPointerException() { * containsKey(null) of nonempty map throws NPE */ public void testContainsKey_NullPointerException() { - TreeMap c = map5(); + TreeMap c = map5(); try { c.containsKey(null); shouldThrow(); @@ -633,8 +633,8 @@ public void testContainsKey_NullPointerException() { * remove(null) throws NPE for nonempty map */ public void testRemove1_NullPointerException() { - TreeMap c = new TreeMap(); - c.put("sadsdf", "asdads"); + TreeMap c = new TreeMap<>(); + c.put(one, "asdads"); try { c.remove(null); shouldThrow(); @@ -645,171 +645,170 @@ public void testRemove1_NullPointerException() { * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { - NavigableMap x = map5(); - NavigableMap y = serialClone(x); + NavigableMap x = map5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); } /** * subMap returns map with keys in requested range */ public void testSubMapContents() { - TreeMap map = map5(); - NavigableMap sm = map.subMap(two, true, four, false); - assertEquals(two, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals(2, sm.size()); + TreeMap map = map5(); + NavigableMap sm = map.subMap(two, true, four, false); + mustEqual(two, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual(2, sm.size()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(three, k); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = (Item)(r.next()); + mustEqual(three, k); + k = (Item)(r.next()); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals("C", sm.remove(three)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual("C", sm.remove(three)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testSubMapContents2() { - TreeMap map = map5(); - NavigableMap sm = map.subMap(two, true, three, false); - assertEquals(1, sm.size()); - assertEquals(two, sm.firstKey()); - assertEquals(two, sm.lastKey()); + TreeMap map = map5(); + NavigableMap sm = map.subMap(two, true, three, false); + mustEqual(1, sm.size()); + mustEqual(two, sm.firstKey()); + mustEqual(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = (Item)(r.next()); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); - assertEquals(4, map.size()); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testHeadMapContents() { - TreeMap map = map5(); - NavigableMap sm = map.headMap(four, false); + TreeMap map = map5(); + NavigableMap sm = map.headMap(four, false); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(one, k); + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(four, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(four, map.firstKey()); } /** * headMap returns map with keys in requested range */ public void testTailMapContents() { - TreeMap map = map5(); - NavigableMap sm = map.tailMap(two, true); + TreeMap map = map5(); + NavigableMap sm = map.tailMap(two, true); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertTrue(sm.containsKey(four)); assertTrue(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + Iterator i = sm.keySet().iterator(); + Item k = (i.next()); + mustEqual(two, k); + k = (i.next()); + mustEqual(three, k); + k = (i.next()); + mustEqual(four, k); + k = (i.next()); + mustEqual(five, k); assertFalse(i.hasNext()); - Iterator r = sm.descendingKeySet().iterator(); - k = (Integer)(r.next()); - assertEquals(five, k); - k = (Integer)(r.next()); - assertEquals(four, k); - k = (Integer)(r.next()); - assertEquals(three, k); - k = (Integer)(r.next()); - assertEquals(two, k); + Iterator r = sm.descendingKeySet().iterator(); + k = (r.next()); + mustEqual(five, k); + k = (r.next()); + mustEqual(four, k); + k = (r.next()); + mustEqual(three, k); + k = (r.next()); + mustEqual(two, k); assertFalse(r.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(two, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(three, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(four, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = (ei.next()); + mustEqual(two, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(three, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(four, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - NavigableMap ssm = sm.tailMap(four, true); - assertEquals(four, ssm.firstKey()); - assertEquals(five, ssm.lastKey()); - assertEquals("D", ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + NavigableMap ssm = sm.tailMap(four, true); + mustEqual(four, ssm.firstKey()); + mustEqual(five, ssm.lastKey()); + mustEqual("D", ssm.remove(four)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } Random rnd = new Random(666); @@ -820,8 +819,8 @@ public void testTailMapContents() { */ public void testRecursiveSubMaps() throws Exception { int mapSize = expensiveTests ? 1000 : 100; - Class cl = TreeMap.class; - NavigableMap map = newMap(cl); + Class cl = TreeMap.class; + NavigableMap map = newMap(cl); bs = new BitSet(mapSize); populate(map, mapSize); @@ -832,26 +831,27 @@ public void testRecursiveSubMaps() throws Exception { check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); - bashSubMap(map.subMap(0, true, mapSize, false), + bashSubMap(map.subMap(zero, true, itemFor(mapSize), false), 0, mapSize - 1, true); } - static NavigableMap newMap(Class cl) throws Exception { - NavigableMap result - = (NavigableMap) cl.getConstructor().newInstance(); - assertEquals(0, result.size()); + static NavigableMap newMap(Class cl) throws Exception { + @SuppressWarnings("unchecked") + NavigableMap result + = (NavigableMap) cl.getConstructor().newInstance(); + mustEqual(0, result.size()); assertFalse(result.keySet().iterator().hasNext()); return result; } - void populate(NavigableMap map, int limit) { + void populate(NavigableMap map, int limit) { for (int i = 0, n = 2 * limit / 3; i < n; i++) { int key = rnd.nextInt(limit); put(map, key); } } - void mutateMap(NavigableMap map, int min, int max) { + void mutateMap(NavigableMap map, int min, int max) { int size = map.size(); int rangeSize = max - min + 1; @@ -861,9 +861,9 @@ void mutateMap(NavigableMap map, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { + for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -876,7 +876,7 @@ void mutateMap(NavigableMap map, int min, int max) { } } - void mutateSubMap(NavigableMap map, int min, int max) { + void mutateSubMap(NavigableMap map, int min, int max) { int size = map.size(); int rangeSize = max - min + 1; @@ -886,9 +886,9 @@ void mutateSubMap(NavigableMap map, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { + for (Iterator it = map.keySet().iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -900,24 +900,24 @@ void mutateSubMap(NavigableMap map, int min, int max) { put(map, key); } else { try { - map.put(key, 2 * key); + map.put(itemFor(key), itemFor(2 * key)); shouldThrow(); } catch (IllegalArgumentException success) {} } } } - void put(NavigableMap map, int key) { - if (map.put(key, 2 * key) == null) + void put(NavigableMap map, int key) { + if (map.put(itemFor(key), itemFor(2 * key)) == null) bs.set(key); } - void remove(NavigableMap map, int key) { - if (map.remove(key) != null) + void remove(NavigableMap map, int key) { + if (map.remove(itemFor(key)) != null) bs.clear(key); } - void bashSubMap(NavigableMap map, + void bashSubMap(NavigableMap map, int min, int max, boolean ascending) { check(map, min, max, ascending); check(map.descendingMap(), min, max, !ascending); @@ -933,7 +933,7 @@ void bashSubMap(NavigableMap map, // headMap - pick direction and endpoint inclusion randomly boolean incl = rnd.nextBoolean(); - NavigableMap hm = map.headMap(midPoint, incl); + NavigableMap hm = map.headMap(itemFor(midPoint), incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(hm, min, midPoint - (incl ? 0 : 1), true); @@ -950,7 +950,7 @@ void bashSubMap(NavigableMap map, // tailMap - pick direction and endpoint inclusion randomly incl = rnd.nextBoolean(); - NavigableMap tm = map.tailMap(midPoint,incl); + NavigableMap tm = map.tailMap(itemFor(midPoint),incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(tm, midPoint + (incl ? 0 : 1), max, true); @@ -975,8 +975,8 @@ void bashSubMap(NavigableMap map, boolean lowIncl = rnd.nextBoolean(); boolean highIncl = rnd.nextBoolean(); if (ascending) { - NavigableMap sm = map.subMap( - endpoints[0], lowIncl, endpoints[1], highIncl); + NavigableMap sm = map.subMap( + itemFor(endpoints[0]), lowIncl, itemFor(endpoints[1]), highIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), true); @@ -984,8 +984,8 @@ void bashSubMap(NavigableMap map, bashSubMap(sm.descendingMap(), endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); } else { - NavigableMap sm = map.subMap( - endpoints[1], highIncl, endpoints[0], lowIncl); + NavigableMap sm = map.subMap( + itemFor(endpoints[1]), highIncl, itemFor(endpoints[0]), lowIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); @@ -998,7 +998,7 @@ void bashSubMap(NavigableMap map, /** * min and max are both inclusive. If max < min, interval is empty. */ - void check(NavigableMap map, + void check(NavigableMap map, final int min, final int max, final boolean ascending) { class ReferenceSet { int lower(int key) { @@ -1062,30 +1062,31 @@ private int lastAscending() { int size = 0; for (int i = min; i <= max; i++) { boolean bsContainsI = bs.get(i); - assertEquals(bsContainsI, map.containsKey(i)); + mustEqual(bsContainsI, map.containsKey(itemFor(i))); if (bsContainsI) size++; } - assertEquals(size, map.size()); + mustEqual(size, map.size()); // Test contents using contains keySet iterator int size2 = 0; int previousKey = -1; - for (int key : map.keySet()) { - assertTrue(bs.get(key)); + for (Item key : map.keySet()) { + assertTrue(bs.get(key.value)); size2++; assertTrue(previousKey < 0 || - (ascending ? key - previousKey > 0 : key - previousKey < 0)); - previousKey = key; + (ascending ? key.value - previousKey > 0 : key.value - previousKey < 0)); + previousKey = key.value; } - assertEquals(size2, size); + mustEqual(size2, size); // Test navigation ops for (int key = min - 1; key <= max + 1; key++) { - assertEq(map.lowerKey(key), rs.lower(key)); - assertEq(map.floorKey(key), rs.floor(key)); - assertEq(map.higherKey(key), rs.higher(key)); - assertEq(map.ceilingKey(key), rs.ceiling(key)); + Item k = itemFor(key); + assertEq(map.lowerKey(k), rs.lower(key)); + assertEq(map.floorKey(k), rs.floor(key)); + assertEq(map.higherKey(k), rs.higher(key)); + assertEq(map.ceilingKey(k), rs.ceiling(key)); } // Test extrema @@ -1093,8 +1094,8 @@ private int lastAscending() { assertEq(map.firstKey(), rs.first()); assertEq(map.lastKey(), rs.last()); } else { - assertEq(rs.first(), -1); - assertEq(rs.last(), -1); + mustEqual(rs.first(), -1); + mustEqual(rs.last(), -1); try { map.firstKey(); shouldThrow(); @@ -1106,15 +1107,15 @@ private int lastAscending() { } } - static void assertEq(Integer i, int j) { + static void assertEq(Item i, int j) { if (i == null) - assertEquals(j, -1); + mustEqual(j, -1); else - assertEquals((int) i, j); + mustEqual(i, j); } - static boolean eq(Integer i, int j) { - return i == null ? j == -1 : i == j; + static boolean eq(Item i, int j) { + return i == null ? j == -1 : i.value == j; } } diff --git a/test/jdk/java/util/concurrent/tck/TreeSetTest.java b/test/jdk/java/util/concurrent/tck/TreeSetTest.java index 4234e66ec87..75f0b522362 100644 --- a/test/jdk/java/util/concurrent/tck/TreeSetTest.java +++ b/test/jdk/java/util/concurrent/tck/TreeSetTest.java @@ -55,44 +55,40 @@ public static Test suite() { } static class MyReverseComparator implements Comparator { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } } - /** - * The number of elements to place in collections, arrays, etc. - */ - static final int SIZE = 20; - /** * Returns a new set of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static TreeSet populatedSet(int n) { - TreeSet q = new TreeSet<>(); + private static TreeSet populatedSet(int n) { + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); assertFalse(q.isEmpty()); - assertEquals(n, q.size()); + mustEqual(n, q.size()); return q; } /** * Returns a new set of first 5 ints. */ - private static TreeSet set5() { - TreeSet q = new TreeSet(); + private static TreeSet set5() { + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); q.add(one); q.add(two); q.add(three); q.add(four); q.add(five); - assertEquals(5, q.size()); + mustEqual(5, q.size()); return q; } @@ -100,7 +96,7 @@ private static TreeSet set5() { * A new set has unbounded capacity */ public void testConstructor1() { - assertEquals(0, new TreeSet().size()); + mustEqual(0, new TreeSet().size()); } /** @@ -108,7 +104,7 @@ public void testConstructor1() { */ public void testConstructor3() { try { - new TreeSet((Collection)null); + new TreeSet((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -118,7 +114,7 @@ public void testConstructor3() { */ public void testConstructor4() { try { - new TreeSet(Arrays.asList(new Integer[SIZE])); + new TreeSet(Arrays.asList(new Item[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -127,11 +123,10 @@ public void testConstructor4() { * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + Item[] items = new Item[2]; + items[1] = zero; try { - new TreeSet(Arrays.asList(ints)); + new TreeSet(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -140,12 +135,10 @@ public void testConstructor5() { * Set contains all elements of collection used to initialize */ public void testConstructor6() { - Integer[] ints = new Integer[SIZE]; + Item[] items = defaultItems; + TreeSet q = new TreeSet<>(Arrays.asList(items)); for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - TreeSet q = new TreeSet(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** @@ -153,25 +146,24 @@ public void testConstructor6() { */ public void testConstructor7() { MyReverseComparator cmp = new MyReverseComparator(); - TreeSet q = new TreeSet(cmp); - assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); + @SuppressWarnings("unchecked") + TreeSet q = new TreeSet<>(cmp); + mustEqual(cmp, q.comparator()); + Item[] items = defaultItems; + q.addAll(Arrays.asList(items)); for (int i = SIZE - 1; i >= 0; --i) - assertEquals(ints[i], q.pollFirst()); + mustEqual(items[i], q.pollFirst()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - TreeSet q = new TreeSet(); + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); - q.add(new Integer(1)); + q.add(one); assertFalse(q.isEmpty()); - q.add(new Integer(2)); + q.add(two); q.pollFirst(); q.pollFirst(); assertTrue(q.isEmpty()); @@ -181,14 +173,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -196,7 +188,7 @@ public void testSize() { * add(null) throws NPE if nonempty */ public void testAddNull() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); try { q.add(null); shouldThrow(); @@ -207,7 +199,7 @@ public void testAddNull() { * Add of comparable element succeeds */ public void testAdd() { - TreeSet q = new TreeSet(); + TreeSet q = new TreeSet<>(); assertTrue(q.add(zero)); assertTrue(q.add(one)); } @@ -216,7 +208,7 @@ public void testAdd() { * Add of duplicate element fails */ public void testAddDup() { - TreeSet q = new TreeSet(); + TreeSet q = new TreeSet<>(); assertTrue(q.add(zero)); assertFalse(q.add(zero)); } @@ -225,7 +217,7 @@ public void testAddDup() { * Add of non-Comparable throws CCE */ public void testAddNonComparable() { - TreeSet q = new TreeSet(); + TreeSet q = new TreeSet<>(); try { q.add(new Object()); q.add(new Object()); @@ -237,7 +229,7 @@ public void testAddNonComparable() { * addAll(null) throws NPE */ public void testAddAll1() { - TreeSet q = new TreeSet(); + TreeSet q = new TreeSet<>(); try { q.addAll(null); shouldThrow(); @@ -248,10 +240,10 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - TreeSet q = new TreeSet(); - Integer[] ints = new Integer[SIZE]; + TreeSet q = new TreeSet<>(); + Item[] items = new Item[2]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -261,12 +253,11 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - TreeSet q = new TreeSet(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i); + TreeSet q = new TreeSet<>(); + Item[] items = new Item[2]; + items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -275,24 +266,22 @@ public void testAddAll3() { * Set contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - TreeSet q = new TreeSet(); + Item[] empty = new Item[0]; + Item[] items = defaultItems; + TreeSet q = new TreeSet<>(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * pollFirst succeeds unless empty */ public void testPollFirst() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -301,9 +290,9 @@ public void testPollFirst() { * pollLast succeeds unless empty */ public void testPollLast() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); for (int i = SIZE - 1; i >= 0; --i) { - assertEquals(i, q.pollLast()); + mustEqual(i, q.pollLast()); } assertNull(q.pollFirst()); } @@ -312,19 +301,19 @@ public void testPollLast() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -333,11 +322,11 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -345,11 +334,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); + mustEqual(0, q.size()); + q.add(one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -359,12 +348,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - TreeSet q = populatedSet(SIZE); - TreeSet p = new TreeSet(); + TreeSet q = populatedSet(SIZE); + TreeSet p = new TreeSet<>(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -373,8 +362,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - TreeSet q = populatedSet(SIZE); - TreeSet p = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); + TreeSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -383,7 +372,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -393,13 +382,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - TreeSet q = populatedSet(SIZE); - TreeSet p = populatedSet(i); + TreeSet q = populatedSet(SIZE); + TreeSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -408,12 +396,12 @@ public void testRemoveAll() { * lower returns preceding element */ public void testLower() { - TreeSet q = set5(); + TreeSet q = set5(); Object e1 = q.lower(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lower(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lower(one); assertNull(e3); @@ -426,12 +414,12 @@ public void testLower() { * higher returns next element */ public void testHigher() { - TreeSet q = set5(); + TreeSet q = set5(); Object e1 = q.higher(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higher(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higher(five); assertNull(e3); @@ -444,15 +432,15 @@ public void testHigher() { * floor returns preceding element */ public void testFloor() { - TreeSet q = set5(); + TreeSet q = set5(); Object e1 = q.floor(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floor(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floor(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -462,15 +450,15 @@ public void testFloor() { * ceiling returns next element */ public void testCeiling() { - TreeSet q = set5(); + TreeSet q = set5(); Object e1 = q.ceiling(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceiling(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceiling(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceiling(six); assertNull(e4); @@ -480,7 +468,7 @@ public void testCeiling() { * toArray contains all elements in sorted order */ public void testToArray() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -492,11 +480,11 @@ public void testToArray() { * toArray(a) contains all elements in sorted order */ public void testToArray2() { - TreeSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + TreeSet q = populatedSet(SIZE); + Item[] items = new Item[SIZE]; + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.pollFirst()); assertTrue(q.isEmpty()); } @@ -505,12 +493,12 @@ public void testToArray2() { * iterator iterates through all elements */ public void testIterator() { - TreeSet q = populatedSet(SIZE); - Iterator it = q.iterator(); + TreeSet q = populatedSet(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -518,25 +506,25 @@ public void testIterator() { * iterator of empty set has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new TreeSet().iterator()); + assertIteratorExhausted(new TreeSet().iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final TreeSet q = new TreeSet(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final TreeSet q = new TreeSet<>(); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); + mustEqual(it.next(), two); + mustEqual(it.next(), three); assertFalse(it.hasNext()); } @@ -544,7 +532,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - TreeSet q = populatedSet(SIZE); + TreeSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -555,16 +543,16 @@ public void testToString() { * A deserialized/reserialized set equals original */ public void testSerialization() throws Exception { - NavigableSet x = populatedSet(SIZE); - NavigableSet y = serialClone(x); + NavigableSet x = populatedSet(SIZE); + NavigableSet y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -573,119 +561,115 @@ public void testSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testSubSetContents() { - TreeSet set = set5(); - SortedSet sm = set.subSet(two, four); - assertEquals(two, sm.first()); - assertEquals(three, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + TreeSet set = set5(); + SortedSet sm = set.subSet(two, four); + mustEqual(two, sm.first()); + mustEqual(three, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.first()); - assertEquals(three, sm.last()); - assertTrue(sm.remove(three)); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.first()); + mustEqual(three, sm.last()); + mustRemove(sm, three); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testSubSetContents2() { - TreeSet set = set5(); - SortedSet sm = set.subSet(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.first()); - assertEquals(two, sm.last()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertFalse(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + TreeSet set = set5(); + SortedSet sm = set.subSet(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.first()); + mustEqual(two, sm.last()); + mustNotContain(sm, one); + mustContain(sm, two); + mustNotContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertFalse(sm.remove(three)); - assertEquals(4, set.size()); + mustNotRemove(sm, three); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testHeadSetContents() { - TreeSet set = set5(); - SortedSet sm = set.headSet(four); - assertTrue(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + TreeSet set = set5(); + SortedSet sm = set.headSet(four); + mustContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(one, k); + k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(four, set.first()); + mustEqual(2, set.size()); + mustEqual(four, set.first()); } /** * tailSet returns set with keys in requested range */ public void testTailSetContents() { - TreeSet set = set5(); - SortedSet sm = set.tailSet(two); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertTrue(sm.contains(four)); - assertTrue(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + TreeSet set = set5(); + SortedSet sm = set.tailSet(two); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustContain(sm, four); + mustContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(four); - assertEquals(four, ssm.first()); - assertEquals(five, ssm.last()); - assertTrue(ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(four); + mustEqual(four, ssm.first()); + mustEqual(five, ssm.last()); + mustRemove(ssm, four); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } Random rnd = new Random(666); @@ -696,9 +680,9 @@ public void testTailSetContents() { */ public void testRecursiveSubSets() throws Exception { int setSize = expensiveTests ? 1000 : 100; - Class cl = TreeSet.class; + Class cl = TreeSet.class; - NavigableSet set = newSet(cl); + NavigableSet set = newSet(cl); bs = new BitSet(setSize); populate(set, setSize); @@ -709,7 +693,7 @@ public void testRecursiveSubSets() throws Exception { check(set, 0, setSize - 1, true); check(set.descendingSet(), 0, setSize - 1, false); - bashSubSet(set.subSet(0, true, setSize, false), + bashSubSet(set.subSet(zero, true, itemFor(setSize), false), 0, setSize - 1, true); } @@ -717,29 +701,30 @@ public void testRecursiveSubSets() throws Exception { * addAll is idempotent */ public void testAddAll_idempotent() throws Exception { - Set x = populatedSet(SIZE); - Set y = new TreeSet(x); + Set x = populatedSet(SIZE); + Set y = new TreeSet<>(x); y.addAll(x); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); } - static NavigableSet newSet(Class cl) throws Exception { - NavigableSet result = - (NavigableSet) cl.getConstructor().newInstance(); - assertEquals(0, result.size()); + static NavigableSet newSet(Class cl) throws Exception { + @SuppressWarnings("unchecked") + NavigableSet result = + (NavigableSet) cl.getConstructor().newInstance(); + mustEqual(0, result.size()); assertFalse(result.iterator().hasNext()); return result; } - void populate(NavigableSet set, int limit) { + void populate(NavigableSet set, int limit) { for (int i = 0, n = 2 * limit / 3; i < n; i++) { int element = rnd.nextInt(limit); put(set, element); } } - void mutateSet(NavigableSet set, int min, int max) { + void mutateSet(NavigableSet set, int min, int max) { int size = set.size(); int rangeSize = max - min + 1; @@ -749,9 +734,9 @@ void mutateSet(NavigableSet set, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = set.iterator(); it.hasNext(); ) { + for (Iterator it = set.iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -764,7 +749,7 @@ void mutateSet(NavigableSet set, int min, int max) { } } - void mutateSubSet(NavigableSet set, int min, int max) { + void mutateSubSet(NavigableSet set, int min, int max) { int size = set.size(); int rangeSize = max - min + 1; @@ -774,9 +759,9 @@ void mutateSubSet(NavigableSet set, int min, int max) { } // Remove a bunch of entries with iterator - for (Iterator it = set.iterator(); it.hasNext(); ) { + for (Iterator it = set.iterator(); it.hasNext(); ) { if (rnd.nextBoolean()) { - bs.clear(it.next()); + bs.clear(it.next().value); it.remove(); } } @@ -788,24 +773,24 @@ void mutateSubSet(NavigableSet set, int min, int max) { put(set, element); } else { try { - set.add(element); + set.add(itemFor(element)); shouldThrow(); } catch (IllegalArgumentException success) {} } } } - void put(NavigableSet set, int element) { - if (set.add(element)) + void put(NavigableSet set, int element) { + if (set.add(itemFor(element))) bs.set(element); } - void remove(NavigableSet set, int element) { - if (set.remove(element)) + void remove(NavigableSet set, int element) { + if (set.remove(itemFor(element))) bs.clear(element); } - void bashSubSet(NavigableSet set, + void bashSubSet(NavigableSet set, int min, int max, boolean ascending) { check(set, min, max, ascending); check(set.descendingSet(), min, max, !ascending); @@ -821,7 +806,7 @@ void bashSubSet(NavigableSet set, // headSet - pick direction and endpoint inclusion randomly boolean incl = rnd.nextBoolean(); - NavigableSet hm = set.headSet(midPoint, incl); + NavigableSet hm = set.headSet(itemFor(midPoint), incl); if (ascending) { if (rnd.nextBoolean()) bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true); @@ -838,7 +823,7 @@ void bashSubSet(NavigableSet set, // tailSet - pick direction and endpoint inclusion randomly incl = rnd.nextBoolean(); - NavigableSet tm = set.tailSet(midPoint,incl); + NavigableSet tm = set.tailSet(itemFor(midPoint),incl); if (ascending) { if (rnd.nextBoolean()) bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true); @@ -863,8 +848,8 @@ void bashSubSet(NavigableSet set, boolean lowIncl = rnd.nextBoolean(); boolean highIncl = rnd.nextBoolean(); if (ascending) { - NavigableSet sm = set.subSet( - endpoints[0], lowIncl, endpoints[1], highIncl); + NavigableSet sm = set.subSet( + itemFor(endpoints[0]), lowIncl, itemFor(endpoints[1]), highIncl); if (rnd.nextBoolean()) bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), true); @@ -872,8 +857,8 @@ void bashSubSet(NavigableSet set, bashSubSet(sm.descendingSet(), endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); } else { - NavigableSet sm = set.subSet( - endpoints[1], highIncl, endpoints[0], lowIncl); + NavigableSet sm = set.subSet( + itemFor(endpoints[1]), highIncl, itemFor(endpoints[0]), lowIncl); if (rnd.nextBoolean()) bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); @@ -886,7 +871,7 @@ void bashSubSet(NavigableSet set, /** * min and max are both inclusive. If max < min, interval is empty. */ - void check(NavigableSet set, + void check(NavigableSet set, final int min, final int max, final boolean ascending) { class ReferenceSet { int lower(int element) { @@ -954,30 +939,31 @@ private int lastAscending() { int size = 0; for (int i = min; i <= max; i++) { boolean bsContainsI = bs.get(i); - assertEquals(bsContainsI, set.contains(i)); + mustEqual(bsContainsI, set.contains(itemFor(i))); if (bsContainsI) size++; } - assertEquals(size, set.size()); + mustEqual(size, set.size()); // Test contents using contains elementSet iterator int size2 = 0; int previousElement = -1; - for (int element : set) { - assertTrue(bs.get(element)); + for (Item element : set) { + assertTrue(bs.get(element.value)); size2++; assertTrue(previousElement < 0 || (ascending ? - element - previousElement > 0 : element - previousElement < 0)); - previousElement = element; + element.value - previousElement > 0 : element.value - previousElement < 0)); + previousElement = element.value; } - assertEquals(size2, size); + mustEqual(size2, size); // Test navigation ops for (int element = min - 1; element <= max + 1; element++) { - assertEq(set.lower(element), rs.lower(element)); - assertEq(set.floor(element), rs.floor(element)); - assertEq(set.higher(element), rs.higher(element)); - assertEq(set.ceiling(element), rs.ceiling(element)); + Item e = itemFor(element); + assertEq(set.lower(e), rs.lower(element)); + assertEq(set.floor(e), rs.floor(element)); + assertEq(set.higher(e), rs.higher(element)); + assertEq(set.ceiling(e), rs.ceiling(element)); } // Test extrema @@ -985,8 +971,8 @@ private int lastAscending() { assertEq(set.first(), rs.first()); assertEq(set.last(), rs.last()); } else { - assertEq(rs.first(), -1); - assertEq(rs.last(), -1); + mustEqual(rs.first(), -1); + mustEqual(rs.last(), -1); try { set.first(); shouldThrow(); @@ -998,15 +984,15 @@ private int lastAscending() { } } - static void assertEq(Integer i, int j) { + static void assertEq(Item i, int j) { if (i == null) - assertEquals(j, -1); + mustEqual(j, -1); else - assertEquals((int) i, j); + mustEqual(i, j); } - static boolean eq(Integer i, int j) { - return (i == null) ? j == -1 : i == j; + static boolean eq(Item i, int j) { + return (i == null) ? j == -1 : i.value == j; } } diff --git a/test/jdk/java/util/concurrent/tck/TreeSubMapTest.java b/test/jdk/java/util/concurrent/tck/TreeSubMapTest.java index 05e876292b8..9b600a19eab 100644 --- a/test/jdk/java/util/concurrent/tck/TreeSubMapTest.java +++ b/test/jdk/java/util/concurrent/tck/TreeSubMapTest.java @@ -53,10 +53,10 @@ public static Test suite() { } /** - * Returns a new map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Items 1-5 to Strings "A"-"E". */ - private static NavigableMap map5() { - TreeMap map = new TreeMap(); + private static NavigableMap map5() { + TreeMap map = new TreeMap<>(); assertTrue(map.isEmpty()); map.put(zero, "Z"); map.put(one, "A"); @@ -66,34 +66,34 @@ private static NavigableMap map5() { map.put(four, "D"); map.put(seven, "F"); assertFalse(map.isEmpty()); - assertEquals(7, map.size()); + mustEqual(7, map.size()); return map.subMap(one, true, seven, false); } - private static NavigableMap map0() { - TreeMap map = new TreeMap(); + private static NavigableMap map0() { + TreeMap map = new TreeMap<>(); assertTrue(map.isEmpty()); return map.tailMap(one, true); } /** - * Returns a new map from Integers -5 to -1 to Strings "A"-"E". + * Returns a new map from Items -5 to -1 to Strings "A"-"E". */ - private static NavigableMap dmap5() { - TreeMap map = new TreeMap(); + private static NavigableMap dmap5() { + TreeMap map = new TreeMap<>(); assertTrue(map.isEmpty()); - map.put(m1, "A"); - map.put(m5, "E"); - map.put(m3, "C"); - map.put(m2, "B"); - map.put(m4, "D"); + map.put(minusOne, "A"); + map.put(minusFive, "E"); + map.put(minusThree, "C"); + map.put(minusTwo, "B"); + map.put(minusFour, "D"); assertFalse(map.isEmpty()); - assertEquals(5, map.size()); + mustEqual(5, map.size()); return map.descendingMap(); } - private static NavigableMap dmap0() { - TreeMap map = new TreeMap(); + private static NavigableMap dmap0() { + TreeMap map = new TreeMap<>(); assertTrue(map.isEmpty()); return map; } @@ -102,19 +102,19 @@ private static NavigableMap dmap0() { * clear removes all pairs */ public void testClear() { - NavigableMap map = map5(); + NavigableMap map = map5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * Maps with same contents are equal */ public void testEquals() { - NavigableMap map1 = map5(); - NavigableMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + NavigableMap map1 = map5(); + NavigableMap map2 = map5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -124,7 +124,7 @@ public void testEquals() { * containsKey returns true for contained key */ public void testContainsKey() { - NavigableMap map = map5(); + NavigableMap map = map5(); assertTrue(map.containsKey(one)); assertFalse(map.containsKey(zero)); } @@ -133,7 +133,7 @@ public void testContainsKey() { * containsValue returns true for held values */ public void testContainsValue() { - NavigableMap map = map5(); + NavigableMap map = map5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -143,9 +143,9 @@ public void testContainsValue() { * or null if not present */ public void testGet() { - NavigableMap map = map5(); - assertEquals("A", (String)map.get(one)); - NavigableMap empty = map0(); + NavigableMap map = map5(); + mustEqual("A", map.get(one)); + NavigableMap empty = map0(); assertNull(empty.get(one)); } @@ -153,8 +153,8 @@ public void testGet() { * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { - NavigableMap empty = map0(); - NavigableMap map = map5(); + NavigableMap empty = map0(); + NavigableMap map = map5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -163,43 +163,43 @@ public void testIsEmpty() { * firstKey returns first key */ public void testFirstKey() { - NavigableMap map = map5(); - assertEquals(one, map.firstKey()); + NavigableMap map = map5(); + mustEqual(one, map.firstKey()); } /** * lastKey returns last key */ public void testLastKey() { - NavigableMap map = map5(); - assertEquals(five, map.lastKey()); + NavigableMap map = map5(); + mustEqual(five, map.lastKey()); } /** * keySet returns a Set containing all the keys */ public void testKeySet() { - NavigableMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); + NavigableMap map = map5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, one); + mustContain(s, two); + mustContain(s, three); + mustContain(s, four); + mustContain(s, five); } /** * keySet is ordered */ public void testKeySetOrder() { - NavigableMap map = map5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, one); + NavigableMap map = map5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = i.next(); + mustEqual(last, one); while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = i.next(); assertTrue(last.compareTo(k) < 0); last = k; } @@ -209,9 +209,9 @@ public void testKeySetOrder() { * values collection contains all values */ public void testValues() { - NavigableMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); + NavigableMap map = map5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -223,12 +223,12 @@ public void testValues() { * entrySet contains all pairs */ public void testEntrySet() { - NavigableMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + NavigableMap map = map5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( (e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || @@ -242,10 +242,10 @@ public void testEntrySet() { * putAll adds all key-value pairs from the given map */ public void testPutAll() { - NavigableMap empty = map0(); - NavigableMap map = map5(); + NavigableMap empty = map0(); + NavigableMap map = map5(); empty.putAll(map); - assertEquals(5, empty.size()); + mustEqual(5, empty.size()); assertTrue(empty.containsKey(one)); assertTrue(empty.containsKey(two)); assertTrue(empty.containsKey(three)); @@ -257,9 +257,9 @@ public void testPutAll() { * remove removes the correct key-value pair from the map */ public void testRemove() { - NavigableMap map = map5(); + NavigableMap map = map5(); map.remove(five); - assertEquals(4, map.size()); + mustEqual(4, map.size()); assertFalse(map.containsKey(five)); } @@ -267,17 +267,17 @@ public void testRemove() { * lowerEntry returns preceding entry. */ public void testLowerEntry() { - NavigableMap map = map5(); - Map.Entry e1 = map.lowerEntry(three); - assertEquals(two, e1.getKey()); + NavigableMap map = map5(); + Map.Entry e1 = map.lowerEntry(three); + mustEqual(two, e1.getKey()); - Map.Entry e2 = map.lowerEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.lowerEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.lowerEntry(one); + Map.Entry e3 = map.lowerEntry(one); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -285,17 +285,17 @@ public void testLowerEntry() { * higherEntry returns next entry. */ public void testHigherEntry() { - NavigableMap map = map5(); - Map.Entry e1 = map.higherEntry(three); - assertEquals(four, e1.getKey()); + NavigableMap map = map5(); + Map.Entry e1 = map.higherEntry(three); + mustEqual(four, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.higherEntry(five); + Map.Entry e3 = map.higherEntry(five); assertNull(e3); - Map.Entry e4 = map.higherEntry(six); + Map.Entry e4 = map.higherEntry(six); assertNull(e4); } @@ -303,17 +303,17 @@ public void testHigherEntry() { * floorEntry returns preceding entry. */ public void testFloorEntry() { - NavigableMap map = map5(); - Map.Entry e1 = map.floorEntry(three); - assertEquals(three, e1.getKey()); + NavigableMap map = map5(); + Map.Entry e1 = map.floorEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.floorEntry(six); - assertEquals(five, e2.getKey()); + Map.Entry e2 = map.floorEntry(six); + mustEqual(five, e2.getKey()); - Map.Entry e3 = map.floorEntry(one); - assertEquals(one, e3.getKey()); + Map.Entry e3 = map.floorEntry(one); + mustEqual(one, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -321,17 +321,17 @@ public void testFloorEntry() { * ceilingEntry returns next entry. */ public void testCeilingEntry() { - NavigableMap map = map5(); - Map.Entry e1 = map.ceilingEntry(three); - assertEquals(three, e1.getKey()); + NavigableMap map = map5(); + Map.Entry e1 = map.ceilingEntry(three); + mustEqual(three, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(one, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(one, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(five); - assertEquals(five, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(five); + mustEqual(five, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(six); + Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); } @@ -339,27 +339,27 @@ public void testCeilingEntry() { * pollFirstEntry returns entries in order */ public void testPollFirstEntry() { - NavigableMap map = map5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + NavigableMap map = map5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(two, e.getKey()); + mustEqual(two, e.getKey()); map.put(one, "A"); e = map.pollFirstEntry(); - assertEquals(one, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(one, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(four); e = map.pollFirstEntry(); - assertEquals(five, e.getKey()); + mustEqual(five, e.getKey()); try { e.setValue("A"); shouldThrow(); } catch (UnsupportedOperationException success) {} assertTrue(map.isEmpty()); - Map.Entry f = map.firstEntry(); + Map.Entry f = map.firstEntry(); assertNull(f); e = map.pollFirstEntry(); assertNull(e); @@ -369,21 +369,21 @@ public void testPollFirstEntry() { * pollLastEntry returns entries in order */ public void testPollLastEntry() { - NavigableMap map = map5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + NavigableMap map = map5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(four, e.getKey()); + mustEqual(four, e.getKey()); map.put(five, "E"); e = map.pollLastEntry(); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(three, e.getKey()); + mustEqual(three, e.getKey()); map.remove(two); e = map.pollLastEntry(); - assertEquals(one, e.getKey()); + mustEqual(one, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -396,17 +396,17 @@ public void testPollLastEntry() { * size returns the correct values */ public void testSize() { - NavigableMap map = map5(); - NavigableMap empty = map0(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + NavigableMap map = map5(); + NavigableMap empty = map0(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testToString() { - NavigableMap map = map5(); + NavigableMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -419,7 +419,7 @@ public void testToString() { * get(null) of nonempty map throws NPE */ public void testGet_NullPointerException() { - NavigableMap c = map5(); + NavigableMap c = map5(); try { c.get(null); shouldThrow(); @@ -430,7 +430,7 @@ public void testGet_NullPointerException() { * containsKey(null) of nonempty map throws NPE */ public void testContainsKey_NullPointerException() { - NavigableMap c = map5(); + NavigableMap c = map5(); try { c.containsKey(null); shouldThrow(); @@ -441,7 +441,7 @@ public void testContainsKey_NullPointerException() { * put(null,x) throws NPE */ public void testPut1_NullPointerException() { - NavigableMap c = map5(); + NavigableMap c = map5(); try { c.put(null, "whatever"); shouldThrow(); @@ -452,7 +452,7 @@ public void testPut1_NullPointerException() { * remove(null) throws NPE */ public void testRemove1_NullPointerException() { - NavigableMap c = map5(); + NavigableMap c = map5(); try { c.remove(null); shouldThrow(); @@ -463,168 +463,168 @@ public void testRemove1_NullPointerException() { * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { - NavigableMap x = map5(); - NavigableMap y = serialClone(x); + NavigableMap x = map5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); } /** * subMap returns map with keys in requested range */ public void testSubMapContents() { - NavigableMap map = map5(); - SortedMap sm = map.subMap(two, four); - assertEquals(two, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals(2, sm.size()); + NavigableMap map = map5(); + SortedMap sm = map.subMap(two, four); + mustEqual(two, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual(2, sm.size()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.firstKey()); - assertEquals(three, sm.lastKey()); - assertEquals("C", sm.remove(three)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.firstKey()); + mustEqual(three, sm.lastKey()); + mustEqual("C", sm.remove(three)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testSubMapContents2() { - NavigableMap map = map5(); - SortedMap sm = map.subMap(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.firstKey()); - assertEquals(two, sm.lastKey()); + NavigableMap map = map5(); + SortedMap sm = map.subMap(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.firstKey()); + mustEqual(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); + Iterator i = sm.keySet().iterator(); Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + k = (Item)(i.next()); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertSame(sm.remove(three), null); - assertEquals(4, map.size()); + assertNull(sm.remove(three)); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testHeadMapContents() { - NavigableMap map = map5(); - SortedMap sm = map.headMap(four); + NavigableMap map = map5(); + SortedMap sm = map.headMap(four); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(one, k); + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(four, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(four, map.firstKey()); } /** * headMap returns map with keys in requested range */ public void testTailMapContents() { - NavigableMap map = map5(); - SortedMap sm = map.tailMap(two); + NavigableMap map = map5(); + SortedMap sm = map.tailMap(two); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); assertTrue(sm.containsKey(four)); assertTrue(sm.containsKey(five)); - Iterator i = sm.keySet().iterator(); + Iterator i = sm.keySet().iterator(); Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + k = (Item)(i.next()); + mustEqual(two, k); + k = (Item)(i.next()); + mustEqual(three, k); + k = (Item)(i.next()); + mustEqual(four, k); + k = (Item)(i.next()); + mustEqual(five, k); assertFalse(i.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(two, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(three, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(four, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(five, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = ei.next(); + mustEqual(two, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(three, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(four, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(five, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - SortedMap ssm = sm.tailMap(four); - assertEquals(four, ssm.firstKey()); - assertEquals(five, ssm.lastKey()); - assertEquals("D", ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + SortedMap ssm = sm.tailMap(four); + mustEqual(four, ssm.firstKey()); + mustEqual(five, ssm.lastKey()); + mustEqual("D", ssm.remove(four)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } /** * clear removes all pairs */ public void testDescendingClear() { - NavigableMap map = dmap5(); + NavigableMap map = dmap5(); map.clear(); - assertEquals(0, map.size()); + mustEqual(0, map.size()); } /** * Maps with same contents are equal */ public void testDescendingEquals() { - NavigableMap map1 = dmap5(); - NavigableMap map2 = dmap5(); - assertEquals(map1, map2); - assertEquals(map2, map1); + NavigableMap map1 = dmap5(); + NavigableMap map2 = dmap5(); + mustEqual(map1, map2); + mustEqual(map2, map1); map1.clear(); assertFalse(map1.equals(map2)); assertFalse(map2.equals(map1)); @@ -634,8 +634,8 @@ public void testDescendingEquals() { * containsKey returns true for contained key */ public void testDescendingContainsKey() { - NavigableMap map = dmap5(); - assertTrue(map.containsKey(m1)); + NavigableMap map = dmap5(); + assertTrue(map.containsKey(minusOne)); assertFalse(map.containsKey(zero)); } @@ -643,7 +643,7 @@ public void testDescendingContainsKey() { * containsValue returns true for held values */ public void testDescendingContainsValue() { - NavigableMap map = dmap5(); + NavigableMap map = dmap5(); assertTrue(map.containsValue("A")); assertFalse(map.containsValue("Z")); } @@ -653,18 +653,18 @@ public void testDescendingContainsValue() { * or null if not present */ public void testDescendingGet() { - NavigableMap map = dmap5(); - assertEquals("A", (String)map.get(m1)); - NavigableMap empty = dmap0(); - assertNull(empty.get(m1)); + NavigableMap map = dmap5(); + mustEqual("A", map.get(minusOne)); + NavigableMap empty = dmap0(); + assertNull(empty.get(minusOne)); } /** * isEmpty is true of empty map and false for non-empty */ public void testDescendingIsEmpty() { - NavigableMap empty = dmap0(); - NavigableMap map = dmap5(); + NavigableMap empty = dmap0(); + NavigableMap map = dmap5(); assertTrue(empty.isEmpty()); assertFalse(map.isEmpty()); } @@ -673,43 +673,43 @@ public void testDescendingIsEmpty() { * firstKey returns first key */ public void testDescendingFirstKey() { - NavigableMap map = dmap5(); - assertEquals(m1, map.firstKey()); + NavigableMap map = dmap5(); + mustEqual(minusOne, map.firstKey()); } /** * lastKey returns last key */ public void testDescendingLastKey() { - NavigableMap map = dmap5(); - assertEquals(m5, map.lastKey()); + NavigableMap map = dmap5(); + mustEqual(minusFive, map.lastKey()); } /** * keySet returns a Set containing all the keys */ public void testDescendingKeySet() { - NavigableMap map = dmap5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(m1)); - assertTrue(s.contains(m2)); - assertTrue(s.contains(m3)); - assertTrue(s.contains(m4)); - assertTrue(s.contains(m5)); + NavigableMap map = dmap5(); + Set s = map.keySet(); + mustEqual(5, s.size()); + mustContain(s, minusOne); + mustContain(s, minusTwo); + mustContain(s, minusThree); + mustContain(s, minusFour); + mustContain(s, minusFive); } /** * keySet is ordered */ public void testDescendingKeySetOrder() { - NavigableMap map = dmap5(); - Set s = map.keySet(); - Iterator i = s.iterator(); - Integer last = (Integer)i.next(); - assertEquals(last, m1); + NavigableMap map = dmap5(); + Set s = map.keySet(); + Iterator i = s.iterator(); + Item last = (Item)i.next(); + mustEqual(last, minusOne); while (i.hasNext()) { - Integer k = (Integer)i.next(); + Item k = (Item)i.next(); assertTrue(last.compareTo(k) > 0); last = k; } @@ -719,9 +719,9 @@ public void testDescendingKeySetOrder() { * values collection contains all values */ public void testDescendingValues() { - NavigableMap map = dmap5(); - Collection s = map.values(); - assertEquals(5, s.size()); + NavigableMap map = dmap5(); + Collection s = map.values(); + mustEqual(5, s.size()); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -733,12 +733,12 @@ public void testDescendingValues() { * keySet.toArray returns contains all keys */ public void testDescendingAscendingKeySetToArray() { - NavigableMap map = dmap5(); - Set s = map.keySet(); - Object[] ar = s.toArray(); + NavigableMap map = dmap5(); + Set s = map.keySet(); + Item[] ar = s.toArray(new Item[0]); assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; + mustEqual(5, ar.length); + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -746,12 +746,12 @@ public void testDescendingAscendingKeySetToArray() { * descendingkeySet.toArray returns contains all keys */ public void testDescendingDescendingKeySetToArray() { - NavigableMap map = dmap5(); - Set s = map.descendingKeySet(); - Object[] ar = s.toArray(); - assertEquals(5, ar.length); + NavigableMap map = dmap5(); + Set s = map.descendingKeySet(); + Item[] ar = s.toArray(new Item[0]); + mustEqual(5, ar.length); assertTrue(s.containsAll(Arrays.asList(ar))); - ar[0] = m10; + ar[0] = minusTen; assertFalse(s.containsAll(Arrays.asList(ar))); } @@ -759,11 +759,11 @@ public void testDescendingDescendingKeySetToArray() { * Values.toArray contains all values */ public void testDescendingValuesToArray() { - NavigableMap map = dmap5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); + NavigableMap map = dmap5(); + Collection v = map.values(); + String[] ar = v.toArray(new String[0]); + ArrayList s = new ArrayList<>(Arrays.asList(ar)); + mustEqual(5, ar.length); assertTrue(s.contains("A")); assertTrue(s.contains("B")); assertTrue(s.contains("C")); @@ -775,18 +775,18 @@ public void testDescendingValuesToArray() { * entrySet contains all pairs */ public void testDescendingEntrySet() { - NavigableMap map = dmap5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); + NavigableMap map = dmap5(); + Set> s = map.entrySet(); + mustEqual(5, s.size()); + Iterator> it = s.iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); + Map.Entry e = it.next(); assertTrue( - (e.getKey().equals(m1) && e.getValue().equals("A")) || - (e.getKey().equals(m2) && e.getValue().equals("B")) || - (e.getKey().equals(m3) && e.getValue().equals("C")) || - (e.getKey().equals(m4) && e.getValue().equals("D")) || - (e.getKey().equals(m5) && e.getValue().equals("E"))); + (e.getKey().equals(minusOne) && e.getValue().equals("A")) || + (e.getKey().equals(minusTwo) && e.getValue().equals("B")) || + (e.getKey().equals(minusThree) && e.getValue().equals("C")) || + (e.getKey().equals(minusFour) && e.getValue().equals("D")) || + (e.getKey().equals(minusFive) && e.getValue().equals("E"))); } } @@ -794,42 +794,42 @@ public void testDescendingEntrySet() { * putAll adds all key-value pairs from the given map */ public void testDescendingPutAll() { - NavigableMap empty = dmap0(); - NavigableMap map = dmap5(); + NavigableMap empty = dmap0(); + NavigableMap map = dmap5(); empty.putAll(map); - assertEquals(5, empty.size()); - assertTrue(empty.containsKey(m1)); - assertTrue(empty.containsKey(m2)); - assertTrue(empty.containsKey(m3)); - assertTrue(empty.containsKey(m4)); - assertTrue(empty.containsKey(m5)); + mustEqual(5, empty.size()); + assertTrue(empty.containsKey(minusOne)); + assertTrue(empty.containsKey(minusTwo)); + assertTrue(empty.containsKey(minusThree)); + assertTrue(empty.containsKey(minusFour)); + assertTrue(empty.containsKey(minusFive)); } /** * remove removes the correct key-value pair from the map */ public void testDescendingRemove() { - NavigableMap map = dmap5(); - map.remove(m5); - assertEquals(4, map.size()); - assertFalse(map.containsKey(m5)); + NavigableMap map = dmap5(); + map.remove(minusFive); + mustEqual(4, map.size()); + assertFalse(map.containsKey(minusFive)); } /** * lowerEntry returns preceding entry. */ public void testDescendingLowerEntry() { - NavigableMap map = dmap5(); - Map.Entry e1 = map.lowerEntry(m3); - assertEquals(m2, e1.getKey()); + NavigableMap map = dmap5(); + Map.Entry e1 = map.lowerEntry(minusThree); + mustEqual(minusTwo, e1.getKey()); - Map.Entry e2 = map.lowerEntry(m6); - assertEquals(m5, e2.getKey()); + Map.Entry e2 = map.lowerEntry(minusSix); + mustEqual(minusFive, e2.getKey()); - Map.Entry e3 = map.lowerEntry(m1); + Map.Entry e3 = map.lowerEntry(minusOne); assertNull(e3); - Map.Entry e4 = map.lowerEntry(zero); + Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); } @@ -837,17 +837,17 @@ public void testDescendingLowerEntry() { * higherEntry returns next entry. */ public void testDescendingHigherEntry() { - NavigableMap map = dmap5(); - Map.Entry e1 = map.higherEntry(m3); - assertEquals(m4, e1.getKey()); + NavigableMap map = dmap5(); + Map.Entry e1 = map.higherEntry(minusThree); + mustEqual(minusFour, e1.getKey()); - Map.Entry e2 = map.higherEntry(zero); - assertEquals(m1, e2.getKey()); + Map.Entry e2 = map.higherEntry(zero); + mustEqual(minusOne, e2.getKey()); - Map.Entry e3 = map.higherEntry(m5); + Map.Entry e3 = map.higherEntry(minusFive); assertNull(e3); - Map.Entry e4 = map.higherEntry(m6); + Map.Entry e4 = map.higherEntry(minusSix); assertNull(e4); } @@ -855,17 +855,17 @@ public void testDescendingHigherEntry() { * floorEntry returns preceding entry. */ public void testDescendingFloorEntry() { - NavigableMap map = dmap5(); - Map.Entry e1 = map.floorEntry(m3); - assertEquals(m3, e1.getKey()); + NavigableMap map = dmap5(); + Map.Entry e1 = map.floorEntry(minusThree); + mustEqual(minusThree, e1.getKey()); - Map.Entry e2 = map.floorEntry(m6); - assertEquals(m5, e2.getKey()); + Map.Entry e2 = map.floorEntry(minusSix); + mustEqual(minusFive, e2.getKey()); - Map.Entry e3 = map.floorEntry(m1); - assertEquals(m1, e3.getKey()); + Map.Entry e3 = map.floorEntry(minusOne); + mustEqual(minusOne, e3.getKey()); - Map.Entry e4 = map.floorEntry(zero); + Map.Entry e4 = map.floorEntry(zero); assertNull(e4); } @@ -873,17 +873,17 @@ public void testDescendingFloorEntry() { * ceilingEntry returns next entry. */ public void testDescendingCeilingEntry() { - NavigableMap map = dmap5(); - Map.Entry e1 = map.ceilingEntry(m3); - assertEquals(m3, e1.getKey()); + NavigableMap map = dmap5(); + Map.Entry e1 = map.ceilingEntry(minusThree); + mustEqual(minusThree, e1.getKey()); - Map.Entry e2 = map.ceilingEntry(zero); - assertEquals(m1, e2.getKey()); + Map.Entry e2 = map.ceilingEntry(zero); + mustEqual(minusOne, e2.getKey()); - Map.Entry e3 = map.ceilingEntry(m5); - assertEquals(m5, e3.getKey()); + Map.Entry e3 = map.ceilingEntry(minusFive); + mustEqual(minusFive, e3.getKey()); - Map.Entry e4 = map.ceilingEntry(m6); + Map.Entry e4 = map.ceilingEntry(minusSix); assertNull(e4); } @@ -891,21 +891,21 @@ public void testDescendingCeilingEntry() { * pollFirstEntry returns entries in order */ public void testDescendingPollFirstEntry() { - NavigableMap map = dmap5(); - Map.Entry e = map.pollFirstEntry(); - assertEquals(m1, e.getKey()); - assertEquals("A", e.getValue()); + NavigableMap map = dmap5(); + Map.Entry e = map.pollFirstEntry(); + mustEqual(minusOne, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(m2, e.getKey()); - map.put(m1, "A"); + mustEqual(minusTwo, e.getKey()); + map.put(minusOne, "A"); e = map.pollFirstEntry(); - assertEquals(m1, e.getKey()); - assertEquals("A", e.getValue()); + mustEqual(minusOne, e.getKey()); + mustEqual("A", e.getValue()); e = map.pollFirstEntry(); - assertEquals(m3, e.getKey()); - map.remove(m4); + mustEqual(minusThree, e.getKey()); + map.remove(minusFour); e = map.pollFirstEntry(); - assertEquals(m5, e.getKey()); + mustEqual(minusFive, e.getKey()); try { e.setValue("A"); shouldThrow(); @@ -918,21 +918,21 @@ public void testDescendingPollFirstEntry() { * pollLastEntry returns entries in order */ public void testDescendingPollLastEntry() { - NavigableMap map = dmap5(); - Map.Entry e = map.pollLastEntry(); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + NavigableMap map = dmap5(); + Map.Entry e = map.pollLastEntry(); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(m4, e.getKey()); - map.put(m5, "E"); + mustEqual(minusFour, e.getKey()); + map.put(minusFive, "E"); e = map.pollLastEntry(); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); e = map.pollLastEntry(); - assertEquals(m3, e.getKey()); - map.remove(m2); + mustEqual(minusThree, e.getKey()); + map.remove(minusTwo); e = map.pollLastEntry(); - assertEquals(m1, e.getKey()); + mustEqual(minusOne, e.getKey()); try { e.setValue("E"); shouldThrow(); @@ -945,17 +945,17 @@ public void testDescendingPollLastEntry() { * size returns the correct values */ public void testDescendingSize() { - NavigableMap map = dmap5(); - NavigableMap empty = dmap0(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); + NavigableMap map = dmap5(); + NavigableMap empty = dmap0(); + mustEqual(0, empty.size()); + mustEqual(5, map.size()); } /** * toString contains toString of elements */ public void testDescendingToString() { - NavigableMap map = dmap5(); + NavigableMap map = dmap5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -968,7 +968,7 @@ public void testDescendingToString() { * get(null) of nonempty map throws NPE */ public void testDescendingGet_NullPointerException() { - NavigableMap c = dmap5(); + NavigableMap c = dmap5(); try { c.get(null); shouldThrow(); @@ -979,7 +979,7 @@ public void testDescendingGet_NullPointerException() { * put(null,x) throws NPE */ public void testDescendingPut1_NullPointerException() { - NavigableMap c = dmap5(); + NavigableMap c = dmap5(); try { c.put(null, "whatever"); shouldThrow(); @@ -990,149 +990,149 @@ public void testDescendingPut1_NullPointerException() { * A deserialized/reserialized map equals original */ public void testDescendingSerialization() throws Exception { - NavigableMap x = dmap5(); - NavigableMap y = serialClone(x); + NavigableMap x = dmap5(); + NavigableMap y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); } /** * subMap returns map with keys in requested range */ public void testDescendingSubMapContents() { - NavigableMap map = dmap5(); - SortedMap sm = map.subMap(m2, m4); - assertEquals(m2, sm.firstKey()); - assertEquals(m3, sm.lastKey()); - assertEquals(2, sm.size()); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableMap map = dmap5(); + SortedMap sm = map.subMap(minusTwo, minusFour); + mustEqual(minusTwo, sm.firstKey()); + mustEqual(minusThree, sm.lastKey()); + mustEqual(2, sm.size()); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusTwo, k); + k = (Item)(i.next()); + mustEqual(minusThree, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); - assertFalse(map.containsKey(m2)); - assertEquals(4, map.size()); - assertEquals(1, sm.size()); - assertEquals(m3, sm.firstKey()); - assertEquals(m3, sm.lastKey()); - assertEquals("C", sm.remove(m3)); + assertFalse(map.containsKey(minusTwo)); + mustEqual(4, map.size()); + mustEqual(1, sm.size()); + mustEqual(minusThree, sm.firstKey()); + mustEqual(minusThree, sm.lastKey()); + mustEqual("C", sm.remove(minusThree)); assertTrue(sm.isEmpty()); - assertEquals(3, map.size()); + mustEqual(3, map.size()); } public void testDescendingSubMapContents2() { - NavigableMap map = dmap5(); - SortedMap sm = map.subMap(m2, m3); - assertEquals(1, sm.size()); - assertEquals(m2, sm.firstKey()); - assertEquals(m2, sm.lastKey()); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertFalse(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); + NavigableMap map = dmap5(); + SortedMap sm = map.subMap(minusTwo, minusThree); + mustEqual(1, sm.size()); + mustEqual(minusTwo, sm.firstKey()); + mustEqual(minusTwo, sm.lastKey()); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertFalse(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusTwo, k); assertFalse(i.hasNext()); - Iterator j = sm.keySet().iterator(); + Iterator j = sm.keySet().iterator(); j.next(); j.remove(); - assertFalse(map.containsKey(m2)); - assertEquals(4, map.size()); - assertEquals(0, sm.size()); + assertFalse(map.containsKey(minusTwo)); + mustEqual(4, map.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertSame(sm.remove(m3), null); - assertEquals(4, map.size()); + assertNull(sm.remove(minusThree)); + mustEqual(4, map.size()); } /** * headMap returns map with keys in requested range */ public void testDescendingHeadMapContents() { - NavigableMap map = dmap5(); - SortedMap sm = map.headMap(m4); - assertTrue(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertFalse(sm.containsKey(m4)); - assertFalse(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m1, k); - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableMap map = dmap5(); + SortedMap sm = map.headMap(minusFour); + assertTrue(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertFalse(sm.containsKey(minusFour)); + assertFalse(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusOne, k); + k = (Item)(i.next()); + mustEqual(minusTwo, k); + k = (Item)(i.next()); + mustEqual(minusThree, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, map.size()); - assertEquals(m4, map.firstKey()); + mustEqual(2, map.size()); + mustEqual(minusFour, map.firstKey()); } /** * headMap returns map with keys in requested range */ public void testDescendingTailMapContents() { - NavigableMap map = dmap5(); - SortedMap sm = map.tailMap(m2); - assertFalse(sm.containsKey(m1)); - assertTrue(sm.containsKey(m2)); - assertTrue(sm.containsKey(m3)); - assertTrue(sm.containsKey(m4)); - assertTrue(sm.containsKey(m5)); - Iterator i = sm.keySet().iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); - k = (Integer)(i.next()); - assertEquals(m4, k); - k = (Integer)(i.next()); - assertEquals(m5, k); + NavigableMap map = dmap5(); + SortedMap sm = map.tailMap(minusTwo); + assertFalse(sm.containsKey(minusOne)); + assertTrue(sm.containsKey(minusTwo)); + assertTrue(sm.containsKey(minusThree)); + assertTrue(sm.containsKey(minusFour)); + assertTrue(sm.containsKey(minusFive)); + Iterator i = sm.keySet().iterator(); + Item k; + k = (Item)(i.next()); + mustEqual(minusTwo, k); + k = (Item)(i.next()); + mustEqual(minusThree, k); + k = (Item)(i.next()); + mustEqual(minusFour, k); + k = (Item)(i.next()); + mustEqual(minusFive, k); assertFalse(i.hasNext()); - Iterator ei = sm.entrySet().iterator(); - Map.Entry e; - e = (Map.Entry)(ei.next()); - assertEquals(m2, e.getKey()); - assertEquals("B", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m3, e.getKey()); - assertEquals("C", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m4, e.getKey()); - assertEquals("D", e.getValue()); - e = (Map.Entry)(ei.next()); - assertEquals(m5, e.getKey()); - assertEquals("E", e.getValue()); + Iterator> ei = sm.entrySet().iterator(); + Map.Entry e; + e = (ei.next()); + mustEqual(minusTwo, e.getKey()); + mustEqual("B", e.getValue()); + e = (ei.next()); + mustEqual(minusThree, e.getKey()); + mustEqual("C", e.getValue()); + e = (ei.next()); + mustEqual(minusFour, e.getKey()); + mustEqual("D", e.getValue()); + e = (ei.next()); + mustEqual(minusFive, e.getKey()); + mustEqual("E", e.getValue()); assertFalse(i.hasNext()); - SortedMap ssm = sm.tailMap(m4); - assertEquals(m4, ssm.firstKey()); - assertEquals(m5, ssm.lastKey()); - assertEquals("D", ssm.remove(m4)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, map.size()); + SortedMap ssm = sm.tailMap(minusFour); + mustEqual(minusFour, ssm.firstKey()); + mustEqual(minusFive, ssm.lastKey()); + mustEqual("D", ssm.remove(minusFour)); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, map.size()); } } diff --git a/test/jdk/java/util/concurrent/tck/TreeSubSetTest.java b/test/jdk/java/util/concurrent/tck/TreeSubSetTest.java index d9ce1c7d214..d740ee28326 100644 --- a/test/jdk/java/util/concurrent/tck/TreeSubSetTest.java +++ b/test/jdk/java/util/concurrent/tck/TreeSubSetTest.java @@ -51,6 +51,7 @@ public static Test suite() { } static class MyReverseComparator implements Comparator { + @SuppressWarnings("unchecked") public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -58,29 +59,29 @@ public int compare(Object x, Object y) { /** * Returns a new set of given size containing consecutive - * Integers 0 ... n - 1. + * Items 0 ... n - 1. */ - private static NavigableSet populatedSet(int n) { - TreeSet q = new TreeSet<>(); + private static NavigableSet populatedSet(int n) { + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) - assertTrue(q.add(new Integer(i))); + mustAdd(q, i); for (int i = (n & 1); i < n; i += 2) - assertTrue(q.add(new Integer(i))); - assertTrue(q.add(new Integer(-n))); - assertTrue(q.add(new Integer(n))); - NavigableSet s = q.subSet(new Integer(0), true, new Integer(n), false); + mustAdd(q, i); + mustAdd(q, new Item(-n)); + mustAdd(q, new Item(n)); + NavigableSet s = q.subSet(zero, true, itemFor(n), false); assertFalse(s.isEmpty()); - assertEquals(n, s.size()); + mustEqual(n, s.size()); return s; } /** * Returns a new set of first 5 ints. */ - private static NavigableSet set5() { - TreeSet q = new TreeSet(); + private static NavigableSet set5() { + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); q.add(one); q.add(two); @@ -89,32 +90,32 @@ private static NavigableSet set5() { q.add(five); q.add(zero); q.add(seven); - NavigableSet s = q.subSet(one, true, seven, false); - assertEquals(5, s.size()); + NavigableSet s = q.subSet(one, true, seven, false); + mustEqual(5, s.size()); return s; } - private static NavigableSet dset5() { - TreeSet q = new TreeSet(); + private static NavigableSet dset5() { + TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); - q.add(m1); - q.add(m2); - q.add(m3); - q.add(m4); - q.add(m5); - NavigableSet s = q.descendingSet(); - assertEquals(5, s.size()); + q.add(minusOne); + q.add(minusTwo); + q.add(minusThree); + q.add(minusFour); + q.add(minusFive); + NavigableSet s = q.descendingSet(); + mustEqual(5, s.size()); return s; } - private static NavigableSet set0() { - TreeSet set = new TreeSet(); + private static NavigableSet set0() { + TreeSet set = new TreeSet<>(); assertTrue(set.isEmpty()); - return set.tailSet(m1, false); + return set.tailSet(minusOne, false); } - private static NavigableSet dset0() { - TreeSet set = new TreeSet(); + private static NavigableSet dset0() { + TreeSet set = new TreeSet<>(); assertTrue(set.isEmpty()); return set; } @@ -123,18 +124,18 @@ private static NavigableSet dset0() { * A new set has unbounded capacity */ public void testConstructor1() { - assertEquals(0, set0().size()); + mustEqual(0, set0().size()); } /** * isEmpty is true before add, false after */ public void testEmpty() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.isEmpty()); - assertTrue(q.add(new Integer(1))); + assertTrue(q.add(one)); assertFalse(q.isEmpty()); - assertTrue(q.add(new Integer(2))); + assertTrue(q.add(two)); q.pollFirst(); q.pollFirst(); assertTrue(q.isEmpty()); @@ -144,14 +145,14 @@ public void testEmpty() { * size changes when elements added and removed */ public void testSize() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -159,7 +160,7 @@ public void testSize() { * add(null) throws NPE */ public void testAddNull() { - NavigableSet q = set0(); + NavigableSet q = set0(); try { q.add(null); shouldThrow(); @@ -170,7 +171,7 @@ public void testAddNull() { * Add of comparable element succeeds */ public void testAdd() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.add(six)); } @@ -178,7 +179,7 @@ public void testAdd() { * Add of duplicate element fails */ public void testAddDup() { - NavigableSet q = set0(); + NavigableSet q = set0(); assertTrue(q.add(six)); assertFalse(q.add(six)); } @@ -187,7 +188,7 @@ public void testAddDup() { * Add of non-Comparable throws CCE */ public void testAddNonComparable() { - NavigableSet q = set0(); + NavigableSet q = new TreeSet<>(); try { q.add(new Object()); q.add(new Object()); @@ -199,7 +200,7 @@ public void testAddNonComparable() { * addAll(null) throws NPE */ public void testAddAll1() { - NavigableSet q = set0(); + NavigableSet q = set0(); try { q.addAll(null); shouldThrow(); @@ -210,10 +211,10 @@ public void testAddAll1() { * addAll of a collection with null elements throws NPE */ public void testAddAll2() { - NavigableSet q = set0(); - Integer[] ints = new Integer[SIZE]; + NavigableSet q = set0(); + Item[] items = new Item[2]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -223,12 +224,11 @@ public void testAddAll2() { * possibly adding some elements */ public void testAddAll3() { - NavigableSet q = set0(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i + SIZE); + NavigableSet q = set0(); + Item[] items = new Item[2]; + items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -237,24 +237,24 @@ public void testAddAll3() { * Set contains all elements of successful addAll */ public void testAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; + Item[] empty = new Item[0]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - NavigableSet q = set0(); + items[i] = itemFor(SIZE - 1 - i); + NavigableSet q = set0(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * poll succeeds unless empty */ public void testPoll() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -263,19 +263,19 @@ public void testPoll() { * remove(x) removes x and returns true if present */ public void testRemoveElement() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertTrue(q.contains(i - 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustContain(q, i - 1); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.contains(i)); - assertTrue(q.remove(i)); - assertFalse(q.contains(i)); - assertFalse(q.remove(i + 1)); - assertFalse(q.contains(i + 1)); + mustContain(q, i); + mustRemove(q, i); + mustNotContain(q, i); + mustNotRemove(q, i + 1); + mustNotContain(q, i + 1); } assertTrue(q.isEmpty()); } @@ -284,11 +284,10 @@ public void testRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testContains() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustContain(q, i); + mustNotContain(q, q.pollFirst()); } } @@ -296,11 +295,11 @@ public void testContains() { * clear removes all elements */ public void testClear() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertTrue(q.add(new Integer(1))); + mustEqual(0, q.size()); + assertTrue(q.add(one)); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -310,12 +309,12 @@ public void testClear() { * containsAll(c) is true when c contains a subset of elements */ public void testContainsAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = set0(); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = set0(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -324,8 +323,8 @@ public void testContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testRetainAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -334,7 +333,7 @@ public void testRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -344,13 +343,12 @@ public void testRetainAll() { */ public void testRemoveAll() { for (int i = 1; i < SIZE; ++i) { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(i); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -359,12 +357,12 @@ public void testRemoveAll() { * lower returns preceding element */ public void testLower() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.lower(three); - assertEquals(two, e1); + mustEqual(two, e1); Object e2 = q.lower(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.lower(one); assertNull(e3); @@ -377,12 +375,12 @@ public void testLower() { * higher returns next element */ public void testHigher() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.higher(three); - assertEquals(four, e1); + mustEqual(four, e1); Object e2 = q.higher(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.higher(five); assertNull(e3); @@ -395,15 +393,15 @@ public void testHigher() { * floor returns preceding element */ public void testFloor() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.floor(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.floor(six); - assertEquals(five, e2); + mustEqual(five, e2); Object e3 = q.floor(one); - assertEquals(one, e3); + mustEqual(one, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -413,15 +411,15 @@ public void testFloor() { * ceiling returns next element */ public void testCeiling() { - NavigableSet q = set5(); + NavigableSet q = set5(); Object e1 = q.ceiling(three); - assertEquals(three, e1); + mustEqual(three, e1); Object e2 = q.ceiling(zero); - assertEquals(one, e2); + mustEqual(one, e2); Object e3 = q.ceiling(five); - assertEquals(five, e3); + mustEqual(five, e3); Object e4 = q.ceiling(six); assertNull(e4); @@ -431,7 +429,7 @@ public void testCeiling() { * toArray contains all elements in sorted order */ public void testToArray() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); Object[] a = q.toArray(); assertSame(Object[].class, a.getClass()); for (Object o : a) @@ -443,11 +441,11 @@ public void testToArray() { * toArray(a) contains all elements in sorted order */ public void testToArray2() { - NavigableSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); - for (Integer o : ints) + NavigableSet q = populatedSet(SIZE); + Item[] items = seqItems(SIZE); + Item[] array = q.toArray(items); + assertSame(items, array); + for (Item o : items) assertSame(o, q.pollFirst()); assertTrue(q.isEmpty()); } @@ -456,12 +454,12 @@ public void testToArray2() { * iterator iterates through all elements */ public void testIterator() { - NavigableSet q = populatedSet(SIZE); - Iterator it = q.iterator(); + NavigableSet q = populatedSet(SIZE); + Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) - assertTrue(q.contains(it.next())); - assertEquals(i, SIZE); + mustContain(q, it.next()); + mustEqual(i, SIZE); assertIteratorExhausted(it); } @@ -476,18 +474,18 @@ public void testEmptyIterator() { * iterator.remove removes current element */ public void testIteratorRemove() { - final NavigableSet q = set0(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final NavigableSet q = set0(); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(2, it.next()); - assertEquals(3, it.next()); + mustEqual(two, it.next()); + mustEqual(three, it.next()); assertFalse(it.hasNext()); } @@ -495,7 +493,7 @@ public void testIteratorRemove() { * toString contains toStrings of elements */ public void testToString() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -506,16 +504,16 @@ public void testToString() { * A deserialized/reserialized set equals original */ public void testSerialization() throws Exception { - NavigableSet x = populatedSet(SIZE); - NavigableSet y = serialClone(x); + NavigableSet x = populatedSet(SIZE); + NavigableSet y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -524,133 +522,129 @@ public void testSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testSubSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.subSet(two, four); - assertEquals(two, sm.first()); - assertEquals(three, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + NavigableSet set = set5(); + SortedSet sm = set.subSet(two, four); + mustEqual(two, sm.first()); + mustEqual(three, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(three, sm.first()); - assertEquals(three, sm.last()); - assertTrue(sm.remove(three)); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(three, sm.first()); + mustEqual(three, sm.last()); + mustRemove(sm, three); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testSubSetContents2() { - NavigableSet set = set5(); - SortedSet sm = set.subSet(two, three); - assertEquals(1, sm.size()); - assertEquals(two, sm.first()); - assertEquals(two, sm.last()); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertFalse(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); + NavigableSet set = set5(); + SortedSet sm = set.subSet(two, three); + mustEqual(1, sm.size()); + mustEqual(two, sm.first()); + mustEqual(two, sm.last()); + mustNotContain(sm, one); + mustContain(sm, two); + mustNotContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(two)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, two); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertFalse(sm.remove(three)); - assertEquals(4, set.size()); + mustNotRemove(sm, three); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testHeadSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.headSet(four); - assertTrue(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertFalse(sm.contains(four)); - assertFalse(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(one, k); - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); + NavigableSet set = set5(); + SortedSet sm = set.headSet(four); + mustContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustNotContain(sm, four); + mustNotContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(one, k); + k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(four, set.first()); + mustEqual(2, set.size()); + mustEqual(four, set.first()); } /** * tailSet returns set with keys in requested range */ public void testTailSetContents() { - NavigableSet set = set5(); - SortedSet sm = set.tailSet(two); - assertFalse(sm.contains(one)); - assertTrue(sm.contains(two)); - assertTrue(sm.contains(three)); - assertTrue(sm.contains(four)); - assertTrue(sm.contains(five)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(two, k); - k = (Integer)(i.next()); - assertEquals(three, k); - k = (Integer)(i.next()); - assertEquals(four, k); - k = (Integer)(i.next()); - assertEquals(five, k); + NavigableSet set = set5(); + SortedSet sm = set.tailSet(two); + mustNotContain(sm, one); + mustContain(sm, two); + mustContain(sm, three); + mustContain(sm, four); + mustContain(sm, five); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(two, k); + k = i.next(); + mustEqual(three, k); + k = i.next(); + mustEqual(four, k); + k = i.next(); + mustEqual(five, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(four); - assertEquals(four, ssm.first()); - assertEquals(five, ssm.last()); - assertTrue(ssm.remove(four)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(four); + mustEqual(four, ssm.first()); + mustEqual(five, ssm.last()); + mustRemove(ssm, four); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } /** * size changes when elements added and removed */ public void testDescendingSize() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); + mustEqual(i, q.size()); + mustAdd(q, i); } } @@ -658,24 +652,24 @@ public void testDescendingSize() { * Add of comparable element succeeds */ public void testDescendingAdd() { - NavigableSet q = dset0(); - assertTrue(q.add(m6)); + NavigableSet q = dset0(); + assertTrue(q.add(minusSix)); } /** * Add of duplicate element fails */ public void testDescendingAddDup() { - NavigableSet q = dset0(); - assertTrue(q.add(m6)); - assertFalse(q.add(m6)); + NavigableSet q = dset0(); + assertTrue(q.add(minusSix)); + assertFalse(q.add(minusSix)); } /** * Add of non-Comparable throws CCE */ public void testDescendingAddNonComparable() { - NavigableSet q = dset0(); + NavigableSet q = new TreeSet<>(); try { q.add(new Object()); q.add(new Object()); @@ -687,7 +681,7 @@ public void testDescendingAddNonComparable() { * addAll(null) throws NPE */ public void testDescendingAddAll1() { - NavigableSet q = dset0(); + NavigableSet q = dset0(); try { q.addAll(null); shouldThrow(); @@ -698,10 +692,10 @@ public void testDescendingAddAll1() { * addAll of a collection with null elements throws NPE */ public void testDescendingAddAll2() { - NavigableSet q = dset0(); - Integer[] ints = new Integer[SIZE]; + NavigableSet q = dset0(); + Item[] items = new Item[2]; items[0] = zero; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -711,12 +705,11 @@ public void testDescendingAddAll2() { * possibly adding some elements */ public void testDescendingAddAll3() { - NavigableSet q = dset0(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) - ints[i] = new Integer(i + SIZE); + NavigableSet q = dset0(); + Item[] items = new Item[2]; + items[0] = ninetynine; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -725,24 +718,24 @@ public void testDescendingAddAll3() { * Set contains all elements of successful addAll */ public void testDescendingAddAll5() { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; + Item[] empty = new Item[0]; + Item[] items = new Item[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE - 1 - i); - NavigableSet q = dset0(); + items[i] = itemFor(SIZE - 1 - i); + NavigableSet q = dset0(); assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); + assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.pollFirst()); + mustEqual(i, q.pollFirst()); } /** * poll succeeds unless empty */ public void testDescendingPoll() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.pollFirst()); + mustEqual(i, q.pollFirst()); } assertNull(q.pollFirst()); } @@ -751,13 +744,13 @@ public void testDescendingPoll() { * remove(x) removes x and returns true if present */ public void testDescendingRemoveElement() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 1; i < SIZE; i += 2) { - assertTrue(q.remove(new Integer(i))); + mustRemove(q, i); } for (int i = 0; i < SIZE; i += 2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i + 1))); + mustRemove(q, i); + mustNotRemove(q, i + 1); } assertTrue(q.isEmpty()); } @@ -766,11 +759,11 @@ public void testDescendingRemoveElement() { * contains(x) reports true when elements added but not yet removed */ public void testDescendingContains() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); + mustContain(q, i); q.pollFirst(); - assertFalse(q.contains(new Integer(i))); + mustNotContain(q, i); } } @@ -778,11 +771,11 @@ public void testDescendingContains() { * clear removes all elements */ public void testDescendingClear() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); q.clear(); assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertTrue(q.add(new Integer(1))); + mustEqual(0, q.size()); + mustAdd(q, one); assertFalse(q.isEmpty()); q.clear(); assertTrue(q.isEmpty()); @@ -792,12 +785,12 @@ public void testDescendingClear() { * containsAll(c) is true when c contains a subset of elements */ public void testDescendingContainsAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = dset0(); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = dset0(); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); - p.add(new Integer(i)); + mustAdd(p, i); } assertTrue(p.containsAll(q)); } @@ -806,8 +799,8 @@ public void testDescendingContainsAll() { * retainAll(c) retains only those elements of c and reports true if changed */ public void testDescendingRetainAll() { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { boolean changed = q.retainAll(p); if (i == 0) @@ -816,7 +809,7 @@ public void testDescendingRetainAll() { assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); p.pollFirst(); } } @@ -826,13 +819,12 @@ public void testDescendingRetainAll() { */ public void testDescendingRemoveAll() { for (int i = 1; i < SIZE; ++i) { - NavigableSet q = populatedSet(SIZE); - NavigableSet p = populatedSet(i); + NavigableSet q = populatedSet(SIZE); + NavigableSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE - i, q.size()); + mustEqual(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { - Integer x = (Integer)(p.pollFirst()); - assertFalse(q.contains(x)); + mustNotContain(q, p.pollFirst()); } } } @@ -841,14 +833,14 @@ public void testDescendingRemoveAll() { * lower returns preceding element */ public void testDescendingLower() { - NavigableSet q = dset5(); - Object e1 = q.lower(m3); - assertEquals(m2, e1); + NavigableSet q = dset5(); + Object e1 = q.lower(minusThree); + mustEqual(minusTwo, e1); - Object e2 = q.lower(m6); - assertEquals(m5, e2); + Object e2 = q.lower(minusSix); + mustEqual(minusFive, e2); - Object e3 = q.lower(m1); + Object e3 = q.lower(minusOne); assertNull(e3); Object e4 = q.lower(zero); @@ -859,17 +851,17 @@ public void testDescendingLower() { * higher returns next element */ public void testDescendingHigher() { - NavigableSet q = dset5(); - Object e1 = q.higher(m3); - assertEquals(m4, e1); + NavigableSet q = dset5(); + Object e1 = q.higher(minusThree); + mustEqual(minusFour, e1); Object e2 = q.higher(zero); - assertEquals(m1, e2); + mustEqual(minusOne, e2); - Object e3 = q.higher(m5); + Object e3 = q.higher(minusFive); assertNull(e3); - Object e4 = q.higher(m6); + Object e4 = q.higher(minusSix); assertNull(e4); } @@ -877,15 +869,15 @@ public void testDescendingHigher() { * floor returns preceding element */ public void testDescendingFloor() { - NavigableSet q = dset5(); - Object e1 = q.floor(m3); - assertEquals(m3, e1); + NavigableSet q = dset5(); + Object e1 = q.floor(minusThree); + mustEqual(minusThree, e1); - Object e2 = q.floor(m6); - assertEquals(m5, e2); + Object e2 = q.floor(minusSix); + mustEqual(minusFive, e2); - Object e3 = q.floor(m1); - assertEquals(m1, e3); + Object e3 = q.floor(minusOne); + mustEqual(minusOne, e3); Object e4 = q.floor(zero); assertNull(e4); @@ -895,17 +887,17 @@ public void testDescendingFloor() { * ceiling returns next element */ public void testDescendingCeiling() { - NavigableSet q = dset5(); - Object e1 = q.ceiling(m3); - assertEquals(m3, e1); + NavigableSet q = dset5(); + Object e1 = q.ceiling(minusThree); + mustEqual(minusThree, e1); Object e2 = q.ceiling(zero); - assertEquals(m1, e2); + mustEqual(minusOne, e2); - Object e3 = q.ceiling(m5); - assertEquals(m5, e3); + Object e3 = q.ceiling(minusFive); + mustEqual(minusFive, e3); - Object e4 = q.ceiling(m6); + Object e4 = q.ceiling(minusSix); assertNull(e4); } @@ -913,69 +905,69 @@ public void testDescendingCeiling() { * toArray contains all elements */ public void testDescendingToArray() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); Object[] o = q.toArray(); Arrays.sort(o); for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.pollFirst()); + mustEqual((Item)o[i], q.pollFirst()); } /** * toArray(a) contains all elements */ public void testDescendingToArray2() { - NavigableSet q = populatedSet(SIZE); - Integer[] ints = new Integer[SIZE]; - assertSame(ints, q.toArray(ints)); - Arrays.sort(ints); - for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.pollFirst()); + NavigableSet q = populatedSet(SIZE); + Item[] items = new Item[SIZE]; + assertSame(items, q.toArray(items)); + Arrays.sort(items); + for (int i = 0; i < items.length; i++) + mustEqual(items[i], q.pollFirst()); } /** * iterator iterates through all elements */ public void testDescendingIterator() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); int i = 0; - Iterator it = q.iterator(); + Iterator it = q.iterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(i, SIZE); + mustEqual(i, SIZE); } /** * iterator of empty set has no elements */ public void testDescendingEmptyIterator() { - NavigableSet q = dset0(); + NavigableSet q = dset0(); int i = 0; - Iterator it = q.iterator(); + Iterator it = q.iterator(); while (it.hasNext()) { - assertTrue(q.contains(it.next())); + mustContain(q, it.next()); ++i; } - assertEquals(0, i); + mustEqual(0, i); } /** * iterator.remove removes current element */ public void testDescendingIteratorRemove() { - final NavigableSet q = dset0(); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); + final NavigableSet q = dset0(); + q.add(two); + q.add(one); + q.add(three); - Iterator it = q.iterator(); + Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); - assertEquals(2, it.next()); - assertEquals(3, it.next()); + mustEqual(two, it.next()); + mustEqual(three, it.next()); assertFalse(it.hasNext()); } @@ -983,7 +975,7 @@ public void testDescendingIteratorRemove() { * toString contains toStrings of elements */ public void testDescendingToString() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); String s = q.toString(); for (int i = 0; i < SIZE; ++i) { assertTrue(s.contains(String.valueOf(i))); @@ -994,17 +986,17 @@ public void testDescendingToString() { * A deserialized/reserialized set equals original */ public void testDescendingSerialization() throws Exception { - NavigableSet x = dset5(); - NavigableSet y = serialClone(x); + NavigableSet x = dset5(); + NavigableSet y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.pollFirst(), y.pollFirst()); + mustEqual(x.pollFirst(), y.pollFirst()); } assertTrue(y.isEmpty()); } @@ -1013,130 +1005,126 @@ public void testDescendingSerialization() throws Exception { * subSet returns set with keys in requested range */ public void testDescendingSubSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.subSet(m2, m4); - assertEquals(m2, sm.first()); - assertEquals(m3, sm.last()); - assertEquals(2, sm.size()); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableSet set = dset5(); + SortedSet sm = set.subSet(minusTwo, minusFour); + mustEqual(minusTwo, sm.first()); + mustEqual(minusThree, sm.last()); + mustEqual(2, sm.size()); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(m2)); - assertEquals(4, set.size()); - assertEquals(1, sm.size()); - assertEquals(m3, sm.first()); - assertEquals(m3, sm.last()); - assertTrue(sm.remove(m3)); + mustNotContain(set, minusTwo); + mustEqual(4, set.size()); + mustEqual(1, sm.size()); + mustEqual(minusThree, sm.first()); + mustEqual(minusThree, sm.last()); + mustRemove(sm, minusThree); assertTrue(sm.isEmpty()); - assertEquals(3, set.size()); + mustEqual(3, set.size()); } public void testDescendingSubSetContents2() { - NavigableSet set = dset5(); - SortedSet sm = set.subSet(m2, m3); - assertEquals(1, sm.size()); - assertEquals(m2, sm.first()); - assertEquals(m2, sm.last()); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertFalse(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); + NavigableSet set = dset5(); + SortedSet sm = set.subSet(minusTwo, minusThree); + mustEqual(1, sm.size()); + mustEqual(minusTwo, sm.first()); + mustEqual(minusTwo, sm.last()); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustNotContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); assertFalse(i.hasNext()); - Iterator j = sm.iterator(); + Iterator j = sm.iterator(); j.next(); j.remove(); - assertFalse(set.contains(m2)); - assertEquals(4, set.size()); - assertEquals(0, sm.size()); + mustNotContain(set, minusTwo); + mustEqual(4, set.size()); + mustEqual(0, sm.size()); assertTrue(sm.isEmpty()); - assertFalse(sm.remove(m3)); - assertEquals(4, set.size()); + mustNotRemove(sm, minusThree); + mustEqual(4, set.size()); } /** * headSet returns set with keys in requested range */ public void testDescendingHeadSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.headSet(m4); - assertTrue(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertFalse(sm.contains(m4)); - assertFalse(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m1, k); - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); + NavigableSet set = dset5(); + SortedSet sm = set.headSet(minusFour); + mustContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustNotContain(sm, minusFour); + mustNotContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusOne, k); + k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); assertFalse(i.hasNext()); sm.clear(); assertTrue(sm.isEmpty()); - assertEquals(2, set.size()); - assertEquals(m4, set.first()); + mustEqual(2, set.size()); + mustEqual(minusFour, set.first()); } /** * tailSet returns set with keys in requested range */ public void testDescendingTailSetContents() { - NavigableSet set = dset5(); - SortedSet sm = set.tailSet(m2); - assertFalse(sm.contains(m1)); - assertTrue(sm.contains(m2)); - assertTrue(sm.contains(m3)); - assertTrue(sm.contains(m4)); - assertTrue(sm.contains(m5)); - Iterator i = sm.iterator(); - Object k; - k = (Integer)(i.next()); - assertEquals(m2, k); - k = (Integer)(i.next()); - assertEquals(m3, k); - k = (Integer)(i.next()); - assertEquals(m4, k); - k = (Integer)(i.next()); - assertEquals(m5, k); + NavigableSet set = dset5(); + SortedSet sm = set.tailSet(minusTwo); + mustNotContain(sm, minusOne); + mustContain(sm, minusTwo); + mustContain(sm, minusThree); + mustContain(sm, minusFour); + mustContain(sm, minusFive); + Iterator i = sm.iterator(); + Item k = i.next(); + mustEqual(minusTwo, k); + k = i.next(); + mustEqual(minusThree, k); + k = i.next(); + mustEqual(minusFour, k); + k = i.next(); + mustEqual(minusFive, k); assertFalse(i.hasNext()); - SortedSet ssm = sm.tailSet(m4); - assertEquals(m4, ssm.first()); - assertEquals(m5, ssm.last()); - assertTrue(ssm.remove(m4)); - assertEquals(1, ssm.size()); - assertEquals(3, sm.size()); - assertEquals(4, set.size()); + SortedSet ssm = sm.tailSet(minusFour); + mustEqual(minusFour, ssm.first()); + mustEqual(minusFive, ssm.last()); + mustRemove(ssm, minusFour); + mustEqual(1, ssm.size()); + mustEqual(3, sm.size()); + mustEqual(4, set.size()); } /** * addAll is idempotent */ public void testAddAll_idempotent() throws Exception { - Set x = populatedSet(SIZE); - Set y = new TreeSet(x); + Set x = populatedSet(SIZE); + Set y = new TreeSet<>(x); y.addAll(x); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); } } diff --git a/test/jdk/java/util/concurrent/tck/VectorTest.java b/test/jdk/java/util/concurrent/tck/VectorTest.java index 4428ecaf2e4..7524ee58432 100644 --- a/test/jdk/java/util/concurrent/tck/VectorTest.java +++ b/test/jdk/java/util/concurrent/tck/VectorTest.java @@ -50,11 +50,12 @@ public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return Vector.class; } public List emptyCollection() { return new Vector(); } - public Object makeElement(int i) { return i; } + public Object makeElement(int i) { return JSR166TestCase.itemFor(i); } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return true; } } class SubListImplementation extends Implementation { + @SuppressWarnings("unchecked") public List emptyCollection() { List list = super.emptyCollection(); ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -70,13 +71,13 @@ public List emptyCollection() { CollectionTest.testSuite(new SubListImplementation())); } - static Vector populatedList(int n) { - Vector list = new Vector<>(); + static Vector populatedList(int n) { + Vector list = new Vector<>(); assertTrue(list.isEmpty()); for (int i = 0; i < n; i++) - list.add(i); - assertEquals(n <= 0, list.isEmpty()); - assertEquals(n, list.size()); + mustAdd(list, i); + mustEqual(n <= 0, list.isEmpty()); + mustEqual(n, list.size()); return list; } @@ -84,29 +85,30 @@ static Vector populatedList(int n) { * addAll adds each element from the given collection, including duplicates */ public void testAddAll() { - List list = populatedList(3); + List list = populatedList(3); assertTrue(list.addAll(Arrays.asList(three, four, five))); - assertEquals(6, list.size()); + mustEqual(6, list.size()); assertTrue(list.addAll(Arrays.asList(three, four, five))); - assertEquals(9, list.size()); + mustEqual(9, list.size()); } /** * clear removes all elements from the list */ public void testClear() { - List list = populatedList(SIZE); + List list = populatedList(SIZE); list.clear(); - assertEquals(0, list.size()); + mustEqual(0, list.size()); } /** * Cloned list is equal */ public void testClone() { - Vector l1 = populatedList(SIZE); - Vector l2 = (Vector)(l1.clone()); - assertEquals(l1, l2); + Vector l1 = populatedList(SIZE); + @SuppressWarnings("unchecked") + Vector l2 = (Vector)(l1.clone()); + mustEqual(l1, l2); l1.clear(); assertFalse(l1.equals(l2)); } @@ -115,49 +117,49 @@ public void testClone() { * contains is true for added elements */ public void testContains() { - List list = populatedList(3); - assertTrue(list.contains(one)); - assertFalse(list.contains(five)); + List list = populatedList(3); + mustContain(list, one); + mustNotContain(list, five); } /** * adding at an index places it in the indicated index */ public void testAddIndex() { - List list = populatedList(3); - list.add(0, m1); - assertEquals(4, list.size()); - assertEquals(m1, list.get(0)); - assertEquals(zero, list.get(1)); - - list.add(2, m2); - assertEquals(5, list.size()); - assertEquals(m2, list.get(2)); - assertEquals(two, list.get(4)); + List list = populatedList(3); + list.add(0, minusOne); + mustEqual(4, list.size()); + mustEqual(minusOne, list.get(0)); + mustEqual(zero, list.get(1)); + + list.add(2, minusTwo); + mustEqual(5, list.size()); + mustEqual(minusTwo, list.get(2)); + mustEqual(two, list.get(4)); } /** * lists with same elements are equal and have same hashCode */ public void testEquals() { - List a = populatedList(3); - List b = populatedList(3); + List a = populatedList(3); + List b = populatedList(3); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); - a.add(m1); + mustEqual(a.hashCode(), b.hashCode()); + a.add(minusOne); assertFalse(a.equals(b)); assertFalse(b.equals(a)); assertTrue(a.containsAll(b)); assertFalse(b.containsAll(a)); - b.add(m1); + b.add(minusOne); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.containsAll(b)); assertTrue(b.containsAll(a)); - assertEquals(a.hashCode(), b.hashCode()); + mustEqual(a.hashCode(), b.hashCode()); assertFalse(a.equals(null)); } @@ -166,7 +168,7 @@ public void testEquals() { * containsAll returns true for collections with subset of elements */ public void testContainsAll() { - List list = populatedList(3); + List list = populatedList(3); assertTrue(list.containsAll(Arrays.asList())); assertTrue(list.containsAll(Arrays.asList(one))); assertTrue(list.containsAll(Arrays.asList(one, two))); @@ -183,8 +185,8 @@ public void testContainsAll() { * get returns the value at the given index */ public void testGet() { - List list = populatedList(3); - assertEquals(0, list.get(0)); + List list = populatedList(3); + mustEqual(0, list.get(0)); } /** @@ -193,25 +195,26 @@ public void testGet() { * contain the element */ public void testIndexOf() { - List list = populatedList(3); - assertEquals(-1, list.indexOf(-42)); + List list = populatedList(3); + mustEqual(-1, list.indexOf(minusTen)); int size = list.size(); for (int i = 0; i < size; i++) { - assertEquals(i, list.indexOf(i)); - assertEquals(i, list.subList(0, size).indexOf(i)); - assertEquals(i, list.subList(0, i + 1).indexOf(i)); - assertEquals(-1, list.subList(0, i).indexOf(i)); - assertEquals(0, list.subList(i, size).indexOf(i)); - assertEquals(-1, list.subList(i + 1, size).indexOf(i)); + Item I = itemFor(i); + mustEqual(i, list.indexOf(I)); + mustEqual(i, list.subList(0, size).indexOf(I)); + mustEqual(i, list.subList(0, i + 1).indexOf(I)); + mustEqual(-1, list.subList(0, i).indexOf(I)); + mustEqual(0, list.subList(i, size).indexOf(I)); + mustEqual(-1, list.subList(i + 1, size).indexOf(I)); } - list.add(1); - assertEquals(1, list.indexOf(1)); - assertEquals(1, list.subList(0, size + 1).indexOf(1)); - assertEquals(0, list.subList(1, size + 1).indexOf(1)); - assertEquals(size - 2, list.subList(2, size + 1).indexOf(1)); - assertEquals(0, list.subList(size, size + 1).indexOf(1)); - assertEquals(-1, list.subList(size + 1, size + 1).indexOf(1)); + list.add(one); + mustEqual(1, list.indexOf(one)); + mustEqual(1, list.subList(0, size + 1).indexOf(one)); + mustEqual(0, list.subList(1, size + 1).indexOf(one)); + mustEqual(size - 2, list.subList(2, size + 1).indexOf(one)); + mustEqual(0, list.subList(size, size + 1).indexOf(one)); + mustEqual(-1, list.subList(size + 1, size + 1).indexOf(one)); } /** @@ -220,41 +223,42 @@ public void testIndexOf() { * or returns -1 if the element is not found */ public void testIndexOf2() { - Vector list = populatedList(3); + Vector list = populatedList(3); int size = list.size(); - assertEquals(-1, list.indexOf(-42, 0)); + mustEqual(-1, list.indexOf(minusTen, 0)); // we might expect IOOBE, but spec says otherwise - assertEquals(-1, list.indexOf(0, size)); - assertEquals(-1, list.indexOf(0, Integer.MAX_VALUE)); + mustEqual(-1, list.indexOf(zero, size)); + mustEqual(-1, list.indexOf(zero, Integer.MAX_VALUE)); assertThrows( IndexOutOfBoundsException.class, - () -> list.indexOf(0, -1), - () -> list.indexOf(0, Integer.MIN_VALUE)); + () -> list.indexOf(zero, -1), + () -> list.indexOf(zero, Integer.MIN_VALUE)); for (int i = 0; i < size; i++) { - assertEquals(i, list.indexOf(i, 0)); - assertEquals(i, list.indexOf(i, i)); - assertEquals(-1, list.indexOf(i, i + 1)); + Item I = itemFor(i); + mustEqual(i, list.indexOf(I, 0)); + mustEqual(i, list.indexOf(I, i)); + mustEqual(-1, list.indexOf(I, i + 1)); } - list.add(1); - assertEquals(1, list.indexOf(1, 0)); - assertEquals(1, list.indexOf(1, 1)); - assertEquals(size, list.indexOf(1, 2)); - assertEquals(size, list.indexOf(1, size)); + list.add(one); + mustEqual(1, list.indexOf(one, 0)); + mustEqual(1, list.indexOf(one, 1)); + mustEqual(size, list.indexOf(one, 2)); + mustEqual(size, list.indexOf(one, size)); } /** * isEmpty returns true when empty, else false */ public void testIsEmpty() { - List empty = new Vector(); + List empty = new Vector<>(); assertTrue(empty.isEmpty()); assertTrue(empty.subList(0, 0).isEmpty()); - List full = populatedList(SIZE); + List full = populatedList(SIZE); assertFalse(full.isEmpty()); assertTrue(full.subList(0, 0).isEmpty()); assertTrue(full.subList(SIZE, SIZE).isEmpty()); @@ -264,7 +268,7 @@ public void testIsEmpty() { * iterator of empty collection has no elements */ public void testEmptyIterator() { - Collection c = new Vector(); + Collection c = new Vector<>(); assertIteratorExhausted(c.iterator()); } @@ -274,24 +278,25 @@ public void testEmptyIterator() { * contain the element */ public void testLastIndexOf1() { - List list = populatedList(3); - assertEquals(-1, list.lastIndexOf(-42)); + List list = populatedList(3); + mustEqual(-1, list.lastIndexOf(minusTen)); int size = list.size(); for (int i = 0; i < size; i++) { - assertEquals(i, list.lastIndexOf(i)); - assertEquals(i, list.subList(0, size).lastIndexOf(i)); - assertEquals(i, list.subList(0, i + 1).lastIndexOf(i)); - assertEquals(-1, list.subList(0, i).lastIndexOf(i)); - assertEquals(0, list.subList(i, size).lastIndexOf(i)); - assertEquals(-1, list.subList(i + 1, size).lastIndexOf(i)); + Item I = itemFor(i); + mustEqual(i, list.lastIndexOf(I)); + mustEqual(i, list.subList(0, size).lastIndexOf(I)); + mustEqual(i, list.subList(0, i + 1).lastIndexOf(I)); + mustEqual(-1, list.subList(0, i).lastIndexOf(I)); + mustEqual(0, list.subList(i, size).lastIndexOf(I)); + mustEqual(-1, list.subList(i + 1, size).lastIndexOf(I)); } - list.add(1); - assertEquals(size, list.lastIndexOf(1)); - assertEquals(size, list.subList(0, size + 1).lastIndexOf(1)); - assertEquals(1, list.subList(0, size).lastIndexOf(1)); - assertEquals(0, list.subList(1, 2).lastIndexOf(1)); - assertEquals(-1, list.subList(0, 1).indexOf(1)); + list.add(one); + mustEqual(size, list.lastIndexOf(one)); + mustEqual(size, list.subList(0, size + 1).lastIndexOf(one)); + mustEqual(1, list.subList(0, size).lastIndexOf(one)); + mustEqual(0, list.subList(1, 2).lastIndexOf(one)); + mustEqual(-1, list.subList(0, 1).indexOf(one)); } /** @@ -300,89 +305,92 @@ public void testLastIndexOf1() { * returns -1 if the element is not found */ public void testLastIndexOf2() { - Vector list = populatedList(3); + Vector list = populatedList(3); // we might expect IOOBE, but spec says otherwise - assertEquals(-1, list.lastIndexOf(0, -1)); + mustEqual(-1, list.lastIndexOf(zero, -1)); int size = list.size(); assertThrows( IndexOutOfBoundsException.class, - () -> list.lastIndexOf(0, size), - () -> list.lastIndexOf(0, Integer.MAX_VALUE)); + () -> list.lastIndexOf(zero, size), + () -> list.lastIndexOf(zero, Integer.MAX_VALUE)); for (int i = 0; i < size; i++) { - assertEquals(i, list.lastIndexOf(i, i)); - assertEquals(list.indexOf(i), list.lastIndexOf(i, i)); + Item I = itemFor(i); + mustEqual(i, list.lastIndexOf(I, i)); + mustEqual(list.indexOf(I), list.lastIndexOf(I, i)); if (i > 0) - assertEquals(-1, list.lastIndexOf(i, i - 1)); + mustEqual(-1, list.lastIndexOf(I, i - 1)); } list.add(one); list.add(three); - assertEquals(1, list.lastIndexOf(one, 1)); - assertEquals(1, list.lastIndexOf(one, 2)); - assertEquals(3, list.lastIndexOf(one, 3)); - assertEquals(3, list.lastIndexOf(one, 4)); - assertEquals(-1, list.lastIndexOf(three, 3)); + mustEqual(1, list.lastIndexOf(one, 1)); + mustEqual(1, list.lastIndexOf(one, 2)); + mustEqual(3, list.lastIndexOf(one, 3)); + mustEqual(3, list.lastIndexOf(one, 4)); + mustEqual(-1, list.lastIndexOf(three, 3)); } /** * size returns the number of elements */ public void testSize() { - List empty = new Vector(); - assertEquals(0, empty.size()); - assertEquals(0, empty.subList(0, 0).size()); - - List full = populatedList(SIZE); - assertEquals(SIZE, full.size()); - assertEquals(0, full.subList(0, 0).size()); - assertEquals(0, full.subList(SIZE, SIZE).size()); + List empty = new Vector<>(); + mustEqual(0, empty.size()); + mustEqual(0, empty.subList(0, 0).size()); + + List full = populatedList(SIZE); + mustEqual(SIZE, full.size()); + mustEqual(0, full.subList(0, 0).size()); + mustEqual(0, full.subList(SIZE, SIZE).size()); } /** * sublists contains elements at indexes offset from their base */ public void testSubList() { - List a = populatedList(10); + List a = populatedList(10); assertTrue(a.subList(1,1).isEmpty()); for (int j = 0; j < 9; ++j) { for (int i = j ; i < 10; ++i) { - List b = a.subList(j,i); + List b = a.subList(j,i); for (int k = j; k < i; ++k) { - assertEquals(new Integer(k), b.get(k-j)); + mustEqual(k, b.get(k-j)); } } } - List s = a.subList(2, 5); - assertEquals(3, s.size()); - s.set(2, m1); - assertEquals(a.get(4), m1); + List s = a.subList(2, 5); + mustEqual(3, s.size()); + s.set(2, minusOne); + mustEqual(a.get(4), minusOne); s.clear(); - assertEquals(7, a.size()); + mustEqual(7, a.size()); assertThrows( IndexOutOfBoundsException.class, () -> s.get(0), - () -> s.set(0, 42)); + () -> s.set(0, fortytwo)); } /** * toArray throws an ArrayStoreException when the given array * can not store the objects inside the list */ + @SuppressWarnings("CollectionToArraySafeParameter") public void testToArray_ArrayStoreException() { - List list = new Vector(); - // Integers are not auto-converted to Longs - list.add(86); - list.add(99); + List list = new Vector<>(); + // Items are not auto-converted to Longs + list.add(eightysix); + list.add(ninetynine); assertThrows( ArrayStoreException.class, () -> list.toArray(new Long[0]), () -> list.toArray(new Long[5])); } + @SuppressWarnings("unchecked") void testIndexOutOfBoundsException(List list) { int size = list.size(); assertThrows( @@ -422,7 +430,7 @@ void testIndexOutOfBoundsException(List list) { */ public void testIndexOutOfBoundsException() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); - List x = populatedList(rnd.nextInt(5)); + List x = populatedList(rnd.nextInt(5)); testIndexOutOfBoundsException(x); int start = rnd.nextInt(x.size() + 1); @@ -433,7 +441,7 @@ public void testIndexOutOfBoundsException() { IllegalArgumentException.class, () -> x.subList(start, start - 1)); - List subList = x.subList(start, end); + List subList = x.subList(start, end); testIndexOutOfBoundsException(x); } @@ -441,18 +449,18 @@ public void testIndexOutOfBoundsException() { * a deserialized/reserialized list equals original */ public void testSerialization() throws Exception { - List x = populatedList(SIZE); - List y = serialClone(x); + List x = populatedList(SIZE); + List y = serialClone(x); assertNotSame(x, y); - assertEquals(x.size(), y.size()); - assertEquals(x.toString(), y.toString()); + mustEqual(x.size(), y.size()); + mustEqual(x.toString(), y.toString()); assertTrue(Arrays.equals(x.toArray(), y.toArray())); - assertEquals(x, y); - assertEquals(y, x); + mustEqual(x, y); + mustEqual(y, x); while (!x.isEmpty()) { assertFalse(y.isEmpty()); - assertEquals(x.remove(0), y.remove(0)); + mustEqual(x.remove(0), y.remove(0)); } assertTrue(y.isEmpty()); } @@ -461,15 +469,15 @@ public void testSerialization() throws Exception { * tests for setSize() */ public void testSetSize() { - final Vector v = new Vector(); + final Vector v = new Vector<>(); for (int n : new int[] { 100, 5, 50 }) { v.setSize(n); - assertEquals(n, v.size()); + mustEqual(n, v.size()); assertNull(v.get(0)); assertNull(v.get(n - 1)); assertThrows(ArrayIndexOutOfBoundsException.class, () -> v.setSize(-1)); - assertEquals(n, v.size()); + mustEqual(n, v.size()); assertNull(v.get(0)); assertNull(v.get(n - 1)); } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java index 41a00c2d913..114816d4787 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java @@ -48,7 +48,6 @@ import java.util.zip.ZipFile; import jdk.test.lib.RandomFactory; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java index 8d6c791bfae..93cf0e0165d 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java @@ -30,7 +30,7 @@ * jdk.compiler * jdk.httpserver * @build CreateMultiReleaseTestJars - * SimpleHttpServer + * jdk.test.lib.net.SimpleHttpServer * jdk.test.lib.compiler.Compiler * jdk.test.lib.util.JarBuilder * @run testng MultiReleaseJarHttpProperties @@ -48,22 +48,24 @@ import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.URL; import java.net.URLClassLoader; +import jdk.test.lib.net.SimpleHttpServer; import jdk.test.lib.net.URIBuilder; - -import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class MultiReleaseJarHttpProperties extends MultiReleaseJarProperties { private SimpleHttpServer server; + static final String TESTCONTEXT = "/multi-release.jar"; //mapped to local file path @BeforeClass public void initialize() throws Exception { - server = new SimpleHttpServer(InetAddress.getLoopbackAddress()); + server = new SimpleHttpServer(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), TESTCONTEXT, + System.getProperty("user.dir", ".")); server.start(); super.initialize(); } @@ -72,7 +74,7 @@ public void initialize() throws Exception { protected void initializeClassLoader() throws Exception { URL[] urls = new URL[]{ URIBuilder.newBuilder().scheme("http").port(server.getPort()).loopback() - .path("/multi-release.jar").toURL(), + .path(TESTCONTEXT).toURL(), }; cldr = new URLClassLoader(urls); // load any class, Main is convenient and in the root entries diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java index 93035abf252..cbc9516542e 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java @@ -72,7 +72,7 @@ public class MultiReleaseJarProperties { @BeforeClass public void initialize() throws Exception { - CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); + CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); creator.compileEntries(); creator.buildMultiReleaseJar(); int RUNTIME_VERSION = Runtime.version().major(); @@ -99,7 +99,7 @@ protected void initializeClassLoader() throws Exception { @AfterClass public void close() throws IOException { - ((URLClassLoader)cldr).close(); + ((URLClassLoader) cldr).close(); Files.delete(multirelease.toPath()); } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java b/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java index 91c0421b207..2573f4b31d4 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java @@ -32,11 +32,6 @@ * @run testng TestVersionedStream */ -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -59,6 +54,10 @@ import java.util.zip.ZipFile; import jdk.test.lib.util.FileUtils; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; public class TestVersionedStream { private final Path userdir; diff --git a/test/jdk/java/util/logging/DrainFindDeadlockTest.java b/test/jdk/java/util/logging/DrainFindDeadlockTest.java index 7bd7b81bd90..9dc7325cecf 100644 --- a/test/jdk/java/util/logging/DrainFindDeadlockTest.java +++ b/test/jdk/java/util/logging/DrainFindDeadlockTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,11 @@ import java.lang.Thread.State; import java.io.IOException; import java.lang.management.ManagementFactory; +import java.util.Random; import java.util.logging.LogManager; import java.util.logging.Logger; import java.util.Map; +import jdk.test.lib.RandomFactory; /** * @test @@ -36,6 +38,7 @@ * @author jim.gish@oracle.com * @modules java.logging * java.management + * @library /test/lib * @build DrainFindDeadlockTest * @run main/othervm DrainFindDeadlockTest * @key randomness @@ -50,6 +53,8 @@ public class DrainFindDeadlockTest { private LogManager mgr = LogManager.getLogManager(); private static final int MAX_ITERATIONS = 100; + private static final Random random = RandomFactory.getRandom(); + private static int preventLoopElision; // Get a ThreadMXBean so we can check for deadlock. N.B. this may // not be supported on all platforms, which means we will have to @@ -66,12 +71,13 @@ public static void main(String... args) throws IOException, Exception { } public static void randomDelay() { - int runs = (int) Math.random() * 1000000; + int runs = random.nextInt(1000000); int c = 0; for (int i=0; i list) { + try { + list.add(Integer.MIN_VALUE); + fail("List.add did not throw UnsupportedOperationException"); + } catch (UnsupportedOperationException ignore) { } + + if (list.size() > 0) { + try { + list.set(0, Integer.MAX_VALUE); + fail("List.set did not throw UnsupportedOperationException"); + } catch (UnsupportedOperationException ignore) { } + } + } + + @Test(dataProvider = "StreamTestData", dataProviderClass = StreamTestDataProvider.class) + public void testOps(String name, TestData.OfRef data) { + List objects = exerciseTerminalOps(data, s -> s.toList()); + checkUnmodifiable(objects); + assertFalse(objects.contains(null)); + } + + @Test(dataProvider = "withNull:StreamTestData", dataProviderClass = StreamTestDataProvider.class) + public void testOpsWithNull(String name, TestData.OfRef data) { + List objects = exerciseTerminalOps(data, s -> s.toList()); + checkUnmodifiable(objects); + assertTrue(objects.contains(null)); + } + + @Test(dataProvider = "StreamTestData", dataProviderClass = StreamTestDataProvider.class) + public void testDefaultOps(String name, TestData.OfRef data) { + List objects = exerciseTerminalOps(data, s -> DefaultMethodStreams.delegateTo(s).toList()); + checkUnmodifiable(objects); + assertFalse(objects.contains(null)); + } + + @Test(dataProvider = "withNull:StreamTestData", dataProviderClass = StreamTestDataProvider.class) + public void testDefaultOpsWithNull(String name, TestData.OfRef data) { + List objects = exerciseTerminalOps(data, s -> DefaultMethodStreams.delegateTo(s).toList()); + checkUnmodifiable(objects); + assertTrue(objects.contains(null)); + } + +} diff --git a/test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java b/test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java index 2fdd4f05a69..c1acd177123 100644 --- a/test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java +++ b/test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,15 +26,21 @@ * @bug 8181386 * @summary CipherSpi ByteBuffer to byte array conversion fails for * certain data overlap conditions - * @run main CipherByteBufferOverwriteTest 0 false - * @run main CipherByteBufferOverwriteTest 0 true - * @run main CipherByteBufferOverwriteTest 4 false - * @run main CipherByteBufferOverwriteTest 4 true + * @run main CipherByteBufferOverwriteTest AES/CBC/PKCS5Padding 0 false + * @run main CipherByteBufferOverwriteTest AES/CBC/PKCS5Padding 0 true + * @run main CipherByteBufferOverwriteTest AES/CBC/PKCS5Padding 4 false + * @run main CipherByteBufferOverwriteTest AES/CBC/PKCS5Padding 4 true + * @run main CipherByteBufferOverwriteTest AES/GCM/NoPadding 0 false + * @run main CipherByteBufferOverwriteTest AES/GCM/NoPadding 0 true + * @run main CipherByteBufferOverwriteTest AES/GCM/NoPadding 4 false + * @run main CipherByteBufferOverwriteTest AES/GCM/NoPadding 4 true */ +import java.math.BigInteger; import java.security.spec.AlgorithmParameterSpec; import javax.crypto.Cipher; import javax.crypto.SecretKey; +import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.nio.ByteBuffer; @@ -44,7 +50,7 @@ public class CipherByteBufferOverwriteTest { private static final boolean DEBUG = false; - private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding"; + private static String transformation; // must be larger than the temp array size, i.e. 4096, hardcoded in // javax.crypto.CipherSpi class @@ -53,8 +59,7 @@ public class CipherByteBufferOverwriteTest { private static final int CIPHERTEXT_BUFFER_SIZE = PLAINTEXT_SIZE + 32; private static final SecretKey KEY = new SecretKeySpec(new byte[16], "AES"); - private static final AlgorithmParameterSpec PARAMS = - new IvParameterSpec(new byte[16]); + private static AlgorithmParameterSpec params; private static ByteBuffer inBuf; private static ByteBuffer outBuf; @@ -65,9 +70,15 @@ private enum BufferType { public static void main(String[] args) throws Exception { - int offset = Integer.parseInt(args[0]); - boolean useRO = Boolean.parseBoolean(args[1]); + transformation = args[0]; + int offset = Integer.parseInt(args[1]); + boolean useRO = Boolean.parseBoolean(args[2]); + if (transformation.equalsIgnoreCase("AES/GCM/NoPadding")) { + params = new GCMParameterSpec(16 * 8, new byte[16]); + } else { + params = new IvParameterSpec(new byte[16]); + } // an all-zeros plaintext is the easiest way to demonstrate the issue, // but it fails with any plaintext, of course byte[] expectedPT = new byte[PLAINTEXT_SIZE]; @@ -75,8 +86,8 @@ public static void main(String[] args) throws Exception { System.arraycopy(expectedPT, 0, buf, 0, PLAINTEXT_SIZE); // generate expected cipher text using byte[] methods - Cipher c = Cipher.getInstance(TRANSFORMATION); - c.init(Cipher.ENCRYPT_MODE, KEY, PARAMS); + Cipher c = Cipher.getInstance(transformation); + c.init(Cipher.ENCRYPT_MODE, KEY, params); byte[] expectedCT = c.doFinal(expectedPT); // Test#1: against ByteBuffer generated with allocate(int) call @@ -89,9 +100,9 @@ public static void main(String[] args) throws Exception { // Test#2: against direct ByteBuffer prepareBuffers(BufferType.DIRECT, useRO, buf.length, buf, 0, PLAINTEXT_SIZE, offset); - System.out.println("\tDIRECT: passed"); runTest(offset, expectedPT, expectedCT); + System.out.println("\tDIRECT: passed"); // Test#3: against ByteBuffer wrapping existing array prepareBuffers(BufferType.WRAP, useRO, buf.length, @@ -150,8 +161,8 @@ private static void prepareBuffers(BufferType type, private static void runTest(int ofs, byte[] expectedPT, byte[] expectedCT) throws Exception { - Cipher c = Cipher.getInstance(TRANSFORMATION); - c.init(Cipher.ENCRYPT_MODE, KEY, PARAMS); + Cipher c = Cipher.getInstance(transformation); + c.init(Cipher.ENCRYPT_MODE, KEY, params); int ciphertextSize = c.doFinal(inBuf, outBuf); // read out the encrypted result @@ -166,14 +177,20 @@ private static void runTest(int ofs, byte[] expectedPT, byte[] expectedCT) outBuf.get(finalCT); if (!Arrays.equals(finalCT, expectedCT)) { + System.err.println("Ciphertext mismatch:" + + "\nresult (len=" + finalCT.length + "):\n" + + String.format("%0" + (finalCT.length << 1) + "x", + new BigInteger(1, finalCT)) + + "\nexpected (len=" + expectedCT.length + "):\n" + + String.format("%0" + (expectedCT.length << 1) + "x", + new BigInteger(1, expectedCT))); throw new Exception("ERROR: Ciphertext does not match"); } // now do decryption outBuf.position(ofs); outBuf.limit(ofs + ciphertextSize); - - c.init(Cipher.DECRYPT_MODE, KEY, PARAMS); + c.init(Cipher.DECRYPT_MODE, KEY, params); ByteBuffer finalPTBuf = ByteBuffer.allocate( c.getOutputSize(outBuf.remaining())); c.doFinal(outBuf, finalPTBuf); @@ -184,6 +201,13 @@ private static void runTest(int ofs, byte[] expectedPT, byte[] expectedCT) finalPTBuf.get(finalPT); if (!Arrays.equals(finalPT, expectedPT)) { + System.err.println("Ciphertext mismatch " + + "):\nresult (len=" + finalCT.length + "):\n" + + String.format("%0" + (finalCT.length << 1) + "x", + new BigInteger(1, finalCT)) + + "\nexpected (len=" + expectedCT.length + "):\n" + + String.format("%0" + (expectedCT.length << 1) + "x", + new BigInteger(1, expectedCT))); throw new Exception("ERROR: Plaintext does not match"); } } diff --git a/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java b/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java index 356beb31a53..c5080ba33c5 100644 --- a/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java +++ b/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,18 +27,17 @@ * @summary Use SunJCE Mac in SecretKeyFactory PBKDF2 implementation * @library evilprov.jar * @library /test/lib - * @build jdk.test.lib.Convert * @run main/othervm SecKeyFacSunJCEPrf */ import java.util.Arrays; +import java.util.HexFormat; import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKey; import javax.crypto.spec.PBEKeySpec; import java.security.Provider; import java.security.Security; import com.evilprovider.*; -import jdk.test.lib.Convert; public class SecKeyFacSunJCEPrf { @@ -46,8 +45,8 @@ public class SecKeyFacSunJCEPrf { private static final byte[] SALT = "salt".getBytes(); private static final char[] PASS = "password".toCharArray(); private static final int ITER = 4096; - private static final byte[] EXP_OUT = Convert.hexStringToByteArray( - "4B007901B765489ABEAD49D926F721D065A429C1"); + private static final byte[] EXP_OUT = + HexFormat.of().parseHex("4B007901B765489ABEAD49D926F721D065A429C1"); public static void main(String[] args) throws Exception { // Instantiate the Evil Provider and insert it in the @@ -62,13 +61,13 @@ public static void main(String[] args) throws Exception { SecretKey secKey1 = pbkdf2.generateSecret(pbks); System.out.println("PBKDF2WithHmacSHA1:\n" + - Convert.byteArrayToHexString(secKey1.getEncoded())); + HexFormat.of().withUpperCase().formatHex(secKey1.getEncoded())); if (Arrays.equals(secKey1.getEncoded(), EXP_OUT)) { System.out.println("Test Vector Passed"); } else { System.out.println("Test Vector Failed"); System.out.println("Expected Output:\n" + - Convert.byteArrayToHexString(EXP_OUT)); + HexFormat.of().withUpperCase().formatHex(EXP_OUT)); throw new RuntimeException(); } } diff --git a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java index 9dc217eaa7c..1c688b22524 100644 --- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java +++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -238,7 +238,7 @@ public static void main(String[] args) throws Exception { boolean retry = false; do { try { - // blacklist String + // filter DefaultAgentFilterTest$MyTestObject testDefaultAgent("mgmt1.properties"); System.out.println("----\tTest FAILED !!"); throw new RuntimeException("---" + DefaultAgentFilterTest.class.getName() + " - No exception reported"); @@ -264,7 +264,7 @@ public static void main(String[] args) throws Exception { retry = false; do { try { - // blacklist non-existent class + // filter non-existent class testDefaultAgent("mgmt2.properties"); System.out.println("----\tTest PASSED !!"); } catch (Exception ex) { diff --git a/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java b/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java index ce10f53b07e..d61d4d9623e 100644 --- a/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java +++ b/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ /* * @test - * @bug 8161086 + * @bug 8161086 8258914 + * @key intermittent * @summary DTLS handshaking fails if some messages were lost * @modules java.base/sun.security.util * @library /test/lib diff --git a/test/jdk/javax/net/ssl/SSLEngine/ArgCheck.java b/test/jdk/javax/net/ssl/SSLEngine/ArgCheck.java index 3b94c6e2992..4781d15972b 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/ArgCheck.java +++ b/test/jdk/javax/net/ssl/SSLEngine/ArgCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,7 +152,7 @@ private static void trySmallBufs(SSLEngine ssle, // For unwrap(), the BUFFER_OVERFLOW will not be generated // until received SSL/TLS application data. - // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check + // Test test/jdk/javax/net/ssl/SSLEngine/LargePacket.java will check // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap(). // //res = ssle.unwrap(netBB, smallAppBB); @@ -172,7 +172,7 @@ private static void trySmallBufsArray(SSLEngine ssle, // For unwrap(), the BUFFER_OVERFLOW will not be generated // until received SSL/TLS application data. - // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check + // Test test/jdk/javax/net/ssl/SSLEngine/LargePacket.java will check // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap(). // //res = ssle.unwrap(netBB, smallAppBB, 0, appBB.length); diff --git a/test/jdk/javax/net/ssl/SSLEngine/Basics.java b/test/jdk/javax/net/ssl/SSLEngine/Basics.java index 8c17e735c55..6e38c884e06 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/Basics.java +++ b/test/jdk/javax/net/ssl/SSLEngine/Basics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -177,7 +177,7 @@ public static void main(String args[]) throws Exception { // For unwrap(), the BUFFER_OVERFLOW will not be generated // until received SSL/TLS application data. - // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check + // Test test/jdk/javax/net/ssl/SSLEngine/LargePacket.java will check // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap(). // //if (ssle.unwrap(smallBB, smallBB).getStatus() != diff --git a/test/jdk/javax/net/ssl/SSLSession/CheckSessionContext.java b/test/jdk/javax/net/ssl/SSLSession/CheckSessionContext.java index b0d15afc536..98c7afb2738 100644 --- a/test/jdk/javax/net/ssl/SSLSession/CheckSessionContext.java +++ b/test/jdk/javax/net/ssl/SSLSession/CheckSessionContext.java @@ -31,11 +31,21 @@ * @run main/othervm -Djdk.tls.client.protocols=TLSv1.2 -Djdk.tls.server.enableSessionTicketExtension=true -Djdk.tls.client.enableSessionTicketExtension=true CheckSessionContext * @run main/othervm -Djdk.tls.client.protocols=TLSv1.3 -Djdk.tls.server.enableSessionTicketExtension=true -Djdk.tls.client.enableSessionTicketExtension=false CheckSessionContext * @run main/othervm -Djdk.tls.client.protocols=TLSv1.3 -Djdk.tls.server.enableSessionTicketExtension=true -Djdk.tls.client.enableSessionTicketExtension=true CheckSessionContext + * @run main/othervm -Djdk.tls.client.protocols=TLSv1.3 -Djdk.tls.server.enableSessionTicketExtension=false -Djdk.tls.client.enableSessionTicketExtension=true CheckSessionContext * */ +import javax.net.ssl.SSLSession; + public class CheckSessionContext { + static void toHex(byte[] id) { + for (byte b : id) { + System.out.printf("%02X ", b); + } + System.out.println(); + } + public static void main(String[] args) throws Exception { TLSBase.Server server = new TLSBase.Server(); @@ -46,6 +56,17 @@ public static void main(String[] args) throws Exception { } else { System.out.println("Context was found"); } + SSLSession ss = server.getSession(client1); + System.out.println(ss); + byte[] id = ss.getId(); + System.out.print("id = "); + toHex(id); + System.out.println("ss.getSessionContext().getSession(id) = " + ss.getSessionContext().getSession(id)); + if (ss.getSessionContext().getSession(id) != null) { + id = ss.getSessionContext().getSession(id).getId(); + System.out.print("id = "); + toHex(id); + } server.close(client1); client1.close(); diff --git a/test/jdk/javax/net/ssl/TLSCommon/TLSWithEdDSA.java b/test/jdk/javax/net/ssl/TLSCommon/TLSWithEdDSA.java new file mode 100644 index 00000000000..3fabc5bd73c --- /dev/null +++ b/test/jdk/javax/net/ssl/TLSCommon/TLSWithEdDSA.java @@ -0,0 +1,736 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * SunJSSE does not support dynamic system properties, no way to re-use + * system properties in samevm/agentvm mode. + * For extra debugging output, add -Djavax.net.debug=ssl:handshake into the + * run directive below. + */ + +/* + * @test + * @bug 8166596 + * @summary TLS support for the EdDSA signature algorithm + * @library /javax/net/ssl/templates /test/lib + * @run main/othervm TLSWithEdDSA + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.net.SocketException; +import java.nio.charset.Charset; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.Principal; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.PKIXBuilderParameters; +import java.security.cert.X509CertSelector; +import java.security.cert.X509Certificate; +import java.security.interfaces.ECKey; +import java.security.interfaces.EdECKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.*; +import javax.net.ssl.CertPathTrustManagerParameters; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLPeerUnverifiedException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509ExtendedKeyManager; +import javax.net.ssl.X509KeyManager; +import jdk.test.lib.security.SecurityUtils; + +public class TLSWithEdDSA extends SSLSocketTemplate { + private static final String PASSWD = "passphrase"; + private static final String DEF_TRUST_ANCHORS = "CA_DSA_1024:CA_DSA_2048:" + + "CA_ECDSA_SECP256R1:CA_ECDSA_SECP384R1:CA_ECDSA_SECP521R1:" + + "CA_ED25519:CA_ED448:CA_RSA_2048"; + private static final String DEF_ALL_EE = "EE_ECDSA_SECP256R1:" + + "EE_ECDSA_SECP384R1:EE_ECDSA_SECP521R1:EE_RSA_2048:" + + "EE_EC_RSA_SECP256R1:EE_DSA_2048:EE_DSA_1024:EE_ED25519:EE_ED448"; + private static final List TEST_PROTOS = List.of( + "TLSv1.3", "TLSv1.2", "TLSv1.1", "TLSv1"); + + private static CertificateFactory certFac; + private static final Map clientParameters = + new HashMap<>(); + private static final Map serverParameters = + new HashMap<>(); + + private final SessionChecker clientChecker; + private final SessionChecker serverChecker; + private final Class clientException; + private final Class serverException; + + interface SessionChecker { + public void check(SSLSocket socket); + } + + /** + * Checks to make sure the end-entity certificate presented by the + * peer uses and Ed25519 key. + */ + final static SessionChecker isPeerEd25519 = new SessionChecker() { + @Override + public void check(SSLSocket sock) { + try { + SSLSession session = sock.getSession(); + System.out.println("Peer certificate check for Ed25519:\n" + + sessionDump(session)); + Certificate[] serverCertChain = session.getPeerCertificates(); + X509Certificate tlsCert = (X509Certificate)serverCertChain[0]; + keyCheck(tlsCert.getPublicKey(), "EdDSA", "Ed25519"); + } catch (SSLPeerUnverifiedException sslpe) { + throw new RuntimeException(sslpe); + } + } + }; + + /** + * Checks to make sure the end-entity certificate presented by the + * peer uses and Ed448 key. + */ + final static SessionChecker isPeerEd448 = new SessionChecker() { + @Override + public void check(SSLSocket sock) { + try { + SSLSession session = sock.getSession(); + System.out.println("Peer certificate check for Ed448:\n" + + sessionDump(session)); + Certificate[] serverCertChain = session.getPeerCertificates(); + X509Certificate tlsCert = (X509Certificate)serverCertChain[0]; + keyCheck(tlsCert.getPublicKey(), "EdDSA", "Ed448"); + } catch (SSLPeerUnverifiedException sslpe) { + throw new RuntimeException(sslpe); + } + } + }; + + /** + * Checks to make sure the end-entity certificate presented by the + * peer uses an EC secp521r1 key. + */ + final static SessionChecker isPeerP521 = new SessionChecker() { + @Override + public void check(SSLSocket sock) { + try { + SSLSession session = sock.getSession(); + System.out.println("Peer certificate check for secp521r1:\n" + + sessionDump(session)); + Certificate[] serverCertChain = session.getPeerCertificates(); + X509Certificate tlsCert = (X509Certificate)serverCertChain[0]; + keyCheck(tlsCert.getPublicKey(), "EC", "secp521r1"); + } catch (SSLPeerUnverifiedException sslpe) { + throw new RuntimeException(sslpe); + } + } + }; + + /** + * Returns a String summary of an SSLSession object + * + * @param sess the SSLSession object to be dumped + * + * @return a String representation of the test-relevant portions of the + * SSLSession object. + */ + private static String sessionDump(SSLSession sess) { + StringBuilder sb = new StringBuilder(); + sb.append("----- Session Info -----\n"); + sb.append("Protocol: ").append(sess.getProtocol()).append("\n"); + sb.append("Cipher Suite: ").append(sess.getCipherSuite()); + Certificate[] localCerts = sess.getLocalCertificates(); + if (localCerts != null) { + sb.append("\nLocal Certs:"); + int i = 0; + for (Certificate cert : localCerts) { + sb.append(String.format("\n [%d]: %s", i++, + ((X509Certificate)cert).getSubjectX500Principal())); + } + } + try { + Certificate[] peerCerts = sess.getPeerCertificates(); + if (peerCerts != null) { + sb.append("\nPeer Certs:"); + int i = 0; + for (Certificate cert : peerCerts) { + sb.append(String.format("\n [%d]: %s", i++, + ((X509Certificate)cert).getSubjectX500Principal())); + } + } + } catch (SSLPeerUnverifiedException sslex) { + throw new RuntimeException(sslex); + } + + return sb.toString(); + } + + /** + * Checks to make sure the public key conforms to the expected key type + * and (where applicable) curve. + * + * @param pubKey the public key to be checked + * @param expPkType the expected key type (RSA/DSA/EC/EdDSA) + * @param expCurveName if an EC/EdDSA key, the expected curve + */ + private static void keyCheck(PublicKey pubKey, String expPkType, + String expCurveName) { + String curveName = null; + String pubKeyAlg = pubKey.getAlgorithm(); + if (!expPkType.equalsIgnoreCase(pubKeyAlg)) { + throw new RuntimeException("Expected " + expPkType + " key, got " + + pubKeyAlg); + } + + // Check the curve type + if (expCurveName != null) { + switch (pubKeyAlg) { + case "EdDSA": + curveName = ((EdECKey)pubKey).getParams().getName(). + toLowerCase(); + if (!expCurveName.equalsIgnoreCase(curveName)) { + throw new RuntimeException("Expected " + expCurveName + + " curve, " + "got " + curveName); + } + break; + case "EC": + curveName = ((ECKey)pubKey).getParams().toString(). + toLowerCase(); + if (!curveName.contains(expCurveName.toLowerCase())) { + throw new RuntimeException("Expected " + expCurveName + + " curve, " + "got " + curveName); + } + break; + default: + throw new IllegalArgumentException( + "Unsupported key type: " + pubKeyAlg); + } + } + System.out.format("Found key: %s / %s\n", pubKeyAlg, + curveName != null ? curveName : ""); + } + + TLSWithEdDSA(SessionChecker cliChk, Class cliExpExc, + SessionChecker servChk, Class servExpExc) { + super(); + clientChecker = cliChk; + clientException = cliExpExc; + serverChecker = servChk; + serverException = servExpExc; + } + + /** + * Creates an SSLContext for use with the client side of this test. This + * uses parameters held in the static client parameters map. + * + * @return an initialized SSLContext for use with the client. + * + * @throws Exception if any downstream errors occur during key store + * creation, key/trust manager factory creation or context + * initialization. + */ + @Override + protected SSLContext createClientSSLContext() throws Exception { + KeyStore clientKeyStore = createKeyStore( + clientParameters.getOrDefault(ParamType.KSENTRIES, ""), + PASSWD.toCharArray()); + KeyStore clientTrustStore = createTrustStore( + clientParameters.getOrDefault(ParamType.TSENTRIES, + DEF_TRUST_ANCHORS)); + return createCtxCommon(clientKeyStore, + clientParameters.get(ParamType.CERTALIAS), PASSWD.toCharArray(), + clientTrustStore, "jdk.tls.client.SignatureSchemes", + clientParameters.get(ParamType.SIGALGS)); + } + + /** + * Creates an SSLContext for use with the server side of this test. This + * uses parameters held in the static server parameters map. + * + * @return an initialized SSLContext for use with the server. + * + * @throws Exception if any downstream errors occur during key store + * creation, key/trust manager factory creation or context + * initialization. + */ + @Override + protected SSLContext createServerSSLContext() throws Exception { + KeyStore serverKeyStore = createKeyStore( + serverParameters.getOrDefault(ParamType.KSENTRIES, ""), + PASSWD.toCharArray()); + KeyStore serverTrustStore = createTrustStore( + serverParameters.getOrDefault(ParamType.TSENTRIES, + DEF_TRUST_ANCHORS)); + return createCtxCommon(serverKeyStore, + serverParameters.get(ParamType.CERTALIAS), PASSWD.toCharArray(), + serverTrustStore, "jdk.tls.server.SignatureSchemes", + serverParameters.get(ParamType.SIGALGS)); + } + + /** + * Create a trust store containing any CA certificates designated as + * trust anchors. + * + * @return the trust store populated with the root CA certificate. + * + * @throws GeneralSecurityException if any certificates cannot be added to + * the key store. + */ + private static KeyStore createTrustStore(String certEnumNames) + throws GeneralSecurityException { + KeyStore.Builder keyStoreBuilder = + KeyStore.Builder.newInstance("PKCS12", null, + new KeyStore.PasswordProtection(PASSWD.toCharArray())); + KeyStore ks = keyStoreBuilder.getKeyStore(); + for (String certName : certEnumNames.split(":")) { + try { + SSLSocketTemplate.Cert cert = + SSLSocketTemplate.Cert.valueOf(certName); + ks.setCertificateEntry(certName, pem2Cert(cert.certStr)); + } catch (IllegalArgumentException iae) { + System.out.println("Unable to find Cert enum entry for " + + certName + ", skipping"); + } + } + return ks; + } + + /** + * Create a key store containing any end-entity private keys/certs + * specified in the parameters. + * + * @param certEnumNames a colon-delimited list of String values that are + * the names of the SSLSocketTemplate.Cert enumeration entries. + * @param pass the desired password for the resulting KeyStore object. + * + * @return a populated, loaded KeyStore ready for use. + * + * @throws GeneralSecurityException if any issues occur while setting + * the private key or certificate entries. + */ + private static KeyStore createKeyStore(String certEnumNames, char[] pass) + throws GeneralSecurityException { + KeyStore.Builder keyStoreBuilder = + KeyStore.Builder.newInstance("PKCS12", null, + new KeyStore.PasswordProtection(pass)); + KeyStore ks = keyStoreBuilder.getKeyStore(); + if (certEnumNames != null && !certEnumNames.isEmpty()) { + for (String certName : certEnumNames.split(":")) { + try { + SSLSocketTemplate.Cert cert = + SSLSocketTemplate.Cert.valueOf(certName); + ks.setKeyEntry(certName, + pem2PrivKey(cert.privKeyStr, cert.keyAlgo), pass, + new Certificate[] { pem2Cert(cert.certStr) }); + } catch (IllegalArgumentException iae) { + System.out.println("Unable to find Cert enum entry for " + + certName + ", skipping"); + } + } + } + + return ks; + } + + /** + * Covert a PEM-encoded certificate into a X509Certificate object. + * + * @param certPem the PEM encoding for the certificate. + * + * @return the corresponding X509Certificate object for the provided PEM. + * + * @throws CertificateException if any decoding errors occur. + */ + private static X509Certificate pem2Cert(String certPem) + throws CertificateException { + return (X509Certificate)certFac.generateCertificate( + new ByteArrayInputStream(certPem.getBytes( + Charset.forName("UTF-8")))); + } + + /** + * Covert a PEM-encoded PKCS8 private key into a PrivateKey object. + * + * @param keyPem the PEM encoding for the certificate. + * @param keyAlg the algorithm for the private key contained in the PKCS8 + * ` encoding. + * + * @return the corresponding PrivateKey object for the provided PEM. + * + * @throws GeneralSecurityException if any decoding errors occur. + */ + private static PrivateKey pem2PrivKey(String keyPem, String keyAlg) + throws GeneralSecurityException { + PKCS8EncodedKeySpec p8Spec = new PKCS8EncodedKeySpec( + Base64.getMimeDecoder().decode(keyPem)); + KeyFactory keyFac = KeyFactory.getInstance(keyAlg); + return keyFac.generatePrivate(p8Spec); + } + + /** + * Create an SSLContext for use with the client or server sides of this + * test. + * + * @param keys the key store object for this SSLContext. + * @param alias optional alias specifier to exclusively use that alias for + * TLS connections. + * @param pass the key store password + * @param trust the trust store object + * @param sigAlgProp the signature algorithm property name to set + * (reserved for future use pending the fix for JDK-8255867) + * @param sigAlgVal the property value to be applied. + * + * @return an initialized SSLContext object. + * + * @throws IOException if any IOExceptions during manager factory creation + * take place + * @throws GeneralSecurityException any other failure during SSLContext + * creation/initialization + */ + private static SSLContext createCtxCommon(KeyStore keys, String alias, + char[] pass, KeyStore trust, String sigAlgProp, String sigAlgVal) + throws IOException, GeneralSecurityException { + SSLContext ctx; + if (sigAlgVal != null && !sigAlgVal.isEmpty()) { + System.setProperty(sigAlgProp, sigAlgVal); + } + + // If an alias is specified use our local AliasKeyManager + KeyManager[] kms = (alias != null && !alias.isEmpty()) ? + new KeyManager[] { new AliasKeyManager(keys, pass, alias) } : + createKeyManagerFactory(keys, pass).getKeyManagers(); + + ctx = SSLContext.getInstance("TLS"); + ctx.init(kms, createTrustManagerFactory(trust).getTrustManagers(), + null); + return ctx; + } + + /** + * Creates a KeyManagerFactory for use during SSLContext initialization. + * + * @param ks the KeyStore forming the base of the KeyManagerFactory + * @param passwd the password to use for the key store + * + * @return the initialized KeyManagerFactory + * + * @throws IOException any IOExceptions during key manager factory + * initialization. + * @throws GeneralSecurityException if any failures during instantiation + * take place. + */ + private static KeyManagerFactory createKeyManagerFactory(KeyStore ks, + char[] passwd) throws IOException, GeneralSecurityException { + KeyManagerFactory kmf; + kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, passwd); + + KeyManager[] kmgrs = kmf.getKeyManagers(); + X509ExtendedKeyManager xkm = (X509ExtendedKeyManager)kmgrs[0]; + return kmf; + } + + /** + * Creates a TrustManagerFactory for use during SSLContext initialization. + * + * @param trustStrore the KeyStore forming the base of the + * TrustManagerFactory + * + * @return the initialized TrustManagerFactory + * + * @throws IOException any IOExceptions during trust manager factory + * initialization. + * @throws GeneralSecurityException if any failures during instantiation + * take place. + */ + private static TrustManagerFactory createTrustManagerFactory( + KeyStore trustStore) throws IOException, GeneralSecurityException { + TrustManagerFactory tmf; + PKIXBuilderParameters pkixParams = + new PKIXBuilderParameters(trustStore, new X509CertSelector()); + pkixParams.setRevocationEnabled(false); + tmf = TrustManagerFactory.getInstance("PKIX"); + tmf.init(new CertPathTrustManagerParameters(pkixParams)); + return tmf; + } + + /* + * Configure the client side socket. + */ + @Override + protected void configureClientSocket(SSLSocket socket) { + String pVal; + if ((pVal = clientParameters.get(ParamType.PROTOS)) != null) { + socket.setEnabledProtocols(pVal.split(":")); + } + + if ((pVal = clientParameters.get(ParamType.CIPHERS)) != null) { + socket.setEnabledCipherSuites(pVal.split(":")); + } + } + + /* + * Configure the server side socket. + */ + @Override + protected void configureServerSocket(SSLServerSocket socket) { + String pVal; + try { + socket.setReuseAddress(true); + if ((pVal = serverParameters.get(ParamType.PROTOS)) != null) { + socket.setEnabledProtocols(pVal.split(":")); + } + + if ((pVal = serverParameters.get(ParamType.CIPHERS)) != null) { + socket.setEnabledCipherSuites(pVal.split(":")); + } + + pVal = serverParameters.get(ParamType.CLIAUTH); + socket.setWantClientAuth("WANT".equalsIgnoreCase(pVal)); + socket.setNeedClientAuth("NEED".equalsIgnoreCase(pVal)); + } catch (SocketException se) { + throw new RuntimeException(se); + } + } + + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + sslOS.write(85); + sslOS.flush(); + + if (serverChecker != null) { + serverChecker.check(socket); + } + } + + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(280); + sslOS.flush(); + sslIS.read(); + + if (clientChecker != null) { + clientChecker.check(socket); + } + } + + public static void main(String[] args) throws Exception { + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1", "TLSv1"); + certFac = CertificateFactory.getInstance("X.509"); + String testFormat; + + System.out.println("===== Test KeyManager alias retrieval ====="); + testKeyManager(DEF_ALL_EE, "EdDSA", + new String[] {"ee_ed25519", "ee_ed448"}); + + testFormat = + "===== Basic Ed25519 Server-side Authentication: %s =====\n"; + serverParameters.put(ParamType.KSENTRIES, "EE_ED25519:EE_RSA_2048"); + runtest(testFormat, isPeerEd25519, null, null, null); + + testFormat = + "===== Basic Ed448 Server-side Authentication: %s =====\n"; + serverParameters.put(ParamType.KSENTRIES, "EE_ED448:EE_RSA_2048"); + runtest(testFormat, isPeerEd448, null, null, null); + + testFormat = "===== EC favored over EdDSA by default: %s =====\n"; + serverParameters.put(ParamType.KSENTRIES, + "EE_ED25519:EE_ECDSA_SECP521R1"); + runtest(testFormat, isPeerP521, null, null, null); + + testFormat = "===== Override EC favoring by alias: %s =====\n"; + serverParameters.put(ParamType.CERTALIAS, "EE_ED25519"); + runtest(testFormat, isPeerEd25519, null, null, null); + serverParameters.remove(ParamType.CERTALIAS); + + testFormat = "===== EdDSA Client Authentication: %s =====\n"; + serverParameters.put(ParamType.KSENTRIES, "EE_RSA_2048"); + serverParameters.put(ParamType.CLIAUTH, "NEED"); + clientParameters.put(ParamType.KSENTRIES, "EE_ED25519"); + runtest(testFormat, null, null, isPeerEd25519, null); + } + + private static void testKeyManager(String keyStoreSpec, String keyType, + String[] expAliases) + throws GeneralSecurityException, IOException { + char[] passChar = PASSWD.toCharArray(); + + // Create the KeyManager factory and resulting KeyManager + KeyManagerFactory kmf = createKeyManagerFactory( + createKeyStore(keyStoreSpec, passChar), passChar); + KeyManager[] kMgrs = kmf.getKeyManagers(); + X509KeyManager xkm = (X509KeyManager)kMgrs[0]; + + String[] cliEdDSAAlises = xkm.getClientAliases(keyType, null); + System.out.format("Client Aliases (%s): ", keyType); + for (String alias : cliEdDSAAlises) { + System.out.print(alias + " "); + } + System.out.println(); + + String[] servEdDSAAliases = xkm.getServerAliases(keyType, null); + System.out.format("Server Aliases (%s): ", keyType); + for (String alias : servEdDSAAliases) { + System.out.print(alias + " "); + } + System.out.println(); + + if (!Arrays.equals(cliEdDSAAlises, expAliases)) { + throw new RuntimeException("Client alias mismatch"); + } else if (!Arrays.equals(servEdDSAAliases, expAliases)) { + throw new RuntimeException("Server alias mismatch"); + } + } + + private static void runtest(String testNameFmt, SessionChecker cliChk, + Class cliExpExc, SessionChecker servChk, + Class servExpExc) { + TEST_PROTOS.forEach(protocol -> { + clientParameters.put(ParamType.PROTOS, protocol); + TLSWithEdDSA testObj = new TLSWithEdDSA(cliChk, cliExpExc, servChk, + servExpExc); + System.out.format(testNameFmt, protocol); + try { + testObj.run(); + if (testObj.clientException != null || + testObj.serverException != null) { + throw new RuntimeException("Expected exception from " + + "either client or server but was missed"); + } + } catch (Exception exc) { + if (testObj.clientException == null && + testObj.serverException == null) { + throw new RuntimeException( + "Expected test failure did not occur"); + } else if (testObj.clientException != null && + !testObj.clientException.isAssignableFrom(exc.getClass())) { + throw new RuntimeException("Unexpected client exception " + + "detected: Expected " + + testObj.clientException.getName() + + ", got " + exc.getClass().getName()); + + } else if (testObj.serverException != null && + !testObj.serverException.isAssignableFrom(exc.getClass())) { + throw new RuntimeException("Unexpected client exception " + + "detected: Expected " + + testObj.serverException.getName() + + ", got " + exc.getClass().getName()); + } + } + System.out.println(); + }); + } + + /** + * A Custom KeyManager that allows the user to specify a key/certificate + * by alias to be used for any TLS authentication actions. + */ + static class AliasKeyManager implements X509KeyManager { + private final String alias; + private final KeyStore keystore; + private final char[] pass; + + public AliasKeyManager(KeyStore keystore, char[] pass, String alias) { + this.keystore = Objects.requireNonNull(keystore); + this.alias = Objects.requireNonNull(alias); + this.pass = Objects.requireNonNull(pass); + } + + @Override + public PrivateKey getPrivateKey(String alias) { + try { + return (PrivateKey)keystore.getKey(alias, pass); + } catch (GeneralSecurityException exc) { + throw new RuntimeException(exc); + } + } + + @Override + public X509Certificate[] getCertificateChain(String alias) { + try { + Certificate[] certAr = keystore.getCertificateChain(alias); + return (certAr != null) ? Arrays.copyOf(certAr, certAr.length, + X509Certificate[].class) : null; + } catch (KeyStoreException ke) { + throw new RuntimeException(ke); + } + } + + @Override + public String chooseClientAlias(String[] keyType, Principal[] issuers, + Socket socket) { + // Blindly return the one selected alias. + return alias; + } + + @Override + public String chooseServerAlias(String keyType, Principal[] issuers, + Socket socket) { + // Blindly return the one selected alias. + return alias; + } + + @Override + public String[] getClientAliases(String keyType, Principal[] issuers) { + // There can be only one! + return new String[] { alias }; + } + + @Override + public String[] getServerAliases(String keyType, Principal[] issuers) { + // There can be only one! + return new String[] { alias }; + } + } + + static enum ParamType { + PROTOS, + CIPHERS, + SIGALGS, + CLIAUTH, + KSENTRIES, + TSENTRIES, + CERTALIAS + } +} \ No newline at end of file diff --git a/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java b/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java index ad6a067ed47..91d1a8d1ead 100644 --- a/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java +++ b/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java @@ -24,11 +24,12 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.security.Security; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; -import jdk.test.lib.security.SecurityUtils; - /* * A JDK client process. */ @@ -161,7 +162,7 @@ public static void main(String[] args) throws Exception { String appProtocolsStr = System.getProperty(JdkProcUtils.PROP_APP_PROTOCOLS); // Re-enable TLSv1 and TLSv1.1 since client depends on them - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); + removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); JdkClient.Builder builder = new JdkClient.Builder(); builder.setCertTuple(JdkProcUtils.createCertTuple( @@ -188,4 +189,22 @@ public static void main(String[] args) throws Exception { client.connect(host, port); } } + + /** + * Removes the specified protocols from the jdk.tls.disabledAlgorithms + * security property. + */ + private static void removeFromDisabledTlsAlgs(String... algs) { + List algList = Arrays.asList(algs); + String value = Security.getProperty("jdk.tls.disabledAlgorithms"); + StringBuilder newValue = new StringBuilder(); + for (String constraint : value.split(",")) { + String tmp = constraint.trim(); + if (!algList.contains(tmp)) { + newValue.append(tmp); + newValue.append(","); + } + } + Security.setProperty("jdk.tls.disabledAlgorithms", newValue.toString()); + } } diff --git a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java index c1ec829b823..7b72d42849d 100644 --- a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java +++ b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,8 +63,8 @@ * Template to help speed your client/server tests. * * Two examples that use this template: - * test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java - * test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java + * test/jdk/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java + * test/jdk/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java */ public class SSLSocketTemplate { diff --git a/test/jdk/javax/swing/ButtonGroup/TestButtonGroupFocusTraversal.java b/test/jdk/javax/swing/ButtonGroup/TestButtonGroupFocusTraversal.java index 4e677c7ab0f..c115d44edbf 100644 --- a/test/jdk/javax/swing/ButtonGroup/TestButtonGroupFocusTraversal.java +++ b/test/jdk/javax/swing/ButtonGroup/TestButtonGroupFocusTraversal.java @@ -24,13 +24,15 @@ /* * @test * @key headful - * @bug 8249548 + * @bug 8249548 8259237 * @summary Test focus traversal in button group containing JToggleButton * and JRadioButton * @run main TestButtonGroupFocusTraversal */ +import javax.swing.AbstractAction; import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JRadioButton; import javax.swing.JTextField; @@ -43,12 +45,16 @@ import java.awt.KeyboardFocusManager; import java.awt.Point; import java.awt.Robot; +import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; public class TestButtonGroupFocusTraversal { private static JFrame frame; private static JTextField textFieldFirst, textFieldLast; private static JToggleButton toggleButton1, toggleButton2; + private static JCheckBox checkBox1, checkBox2; + private static boolean toggleButtonActionPerformed; + private static boolean checkboxActionPerformed; private static JRadioButton radioButton1, radioButton2; private static Robot robot; @@ -75,6 +81,36 @@ public void run() { toggleButton2 = new JToggleButton("2"); radioButton1 = new JRadioButton("1"); radioButton2 = new JRadioButton("2"); + checkBox1 = new JCheckBox("1"); + checkBox2 = new JCheckBox("2"); + + toggleButton1.setAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + toggleButtonActionPerformed = true; + } + }); + + toggleButton2.setAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + toggleButtonActionPerformed = true; + } + }); + + checkBox1.setAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + checkboxActionPerformed = true; + } + }); + + checkBox2.setAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + checkboxActionPerformed = true; + } + }); ButtonGroup toggleGroup = new ButtonGroup(); toggleGroup.add(toggleButton1); @@ -84,8 +120,13 @@ public void run() { radioGroup.add(radioButton1); radioGroup.add(radioButton2); + ButtonGroup checkboxButtonGroup = new ButtonGroup(); + checkboxButtonGroup.add(checkBox1); + checkboxButtonGroup.add(checkBox2); + toggleButton2.setSelected(true); radioButton2.setSelected(true); + checkBox2.setSelected(true); frame = new JFrame("Test"); frame.setLayout(new FlowLayout()); @@ -96,6 +137,8 @@ public void run() { pane.add(toggleButton2); pane.add(radioButton1); pane.add(radioButton2); + pane.add(checkBox1); + pane.add(checkBox2); pane.add(textFieldLast); frame.pack(); @@ -127,6 +170,20 @@ private static void checkFocusedComponent (Component component) { } } + private static void checkToggleButtonActionPerformed() { + if (toggleButtonActionPerformed) { + throw new RuntimeException("Toggle Button Action should not be" + + "performed"); + } + } + + private static void checkCheckboxActionPerformed() { + if (toggleButtonActionPerformed) { + throw new RuntimeException("Checkbox Action should not be" + + "performed"); + } + } + public static void main(String[] args) throws Exception { robot = new Robot(); robot.setAutoDelay(100); @@ -164,9 +221,15 @@ public static void main(String[] args) throws Exception { pressKey(KeyEvent.VK_TAB); checkFocusedComponent(radioButton2); + pressKey(KeyEvent.VK_TAB); + checkFocusedComponent(checkBox2); + pressKey(KeyEvent.VK_TAB); checkFocusedComponent(textFieldLast); + pressKey(KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); + checkFocusedComponent(checkBox2); + pressKey(KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); checkFocusedComponent(radioButton2); @@ -181,15 +244,19 @@ public static void main(String[] args) throws Exception { pressKey(KeyEvent.VK_LEFT); checkFocusedComponent(toggleButton1); + checkToggleButtonActionPerformed(); pressKey(KeyEvent.VK_RIGHT); checkFocusedComponent(toggleButton2); + checkToggleButtonActionPerformed(); pressKey(KeyEvent.VK_UP); checkFocusedComponent(toggleButton1); + checkToggleButtonActionPerformed(); pressKey(KeyEvent.VK_DOWN); checkFocusedComponent(toggleButton2); + checkToggleButtonActionPerformed(); pressKey(KeyEvent.VK_TAB); checkFocusedComponent(radioButton2); @@ -206,6 +273,24 @@ public static void main(String[] args) throws Exception { pressKey(KeyEvent.VK_DOWN); checkFocusedComponent(radioButton2); + pressKey(KeyEvent.VK_TAB); + checkFocusedComponent(checkBox2); + + pressKey(KeyEvent.VK_LEFT); + checkCheckboxActionPerformed(); + checkFocusedComponent(checkBox1); + + pressKey(KeyEvent.VK_RIGHT); + checkCheckboxActionPerformed(); + checkFocusedComponent(checkBox2); + + pressKey(KeyEvent.VK_UP); + checkCheckboxActionPerformed(); + checkFocusedComponent(checkBox1); + + pressKey(KeyEvent.VK_DOWN); + checkCheckboxActionPerformed(); + checkFocusedComponent(checkBox2); } finally { if (frame != null) { SwingUtilities.invokeAndWait(frame::dispose); @@ -214,4 +299,3 @@ public static void main(String[] args) throws Exception { } } } - diff --git a/test/jdk/javax/swing/JColorChooser/Test6827032.java b/test/jdk/javax/swing/JColorChooser/Test6827032.java index fff9834d687..096d6b1eeba 100644 --- a/test/jdk/javax/swing/JColorChooser/Test6827032.java +++ b/test/jdk/javax/swing/JColorChooser/Test6827032.java @@ -24,7 +24,7 @@ /* * @test * @key headful - * @bug 6827032 + * @bug 6827032 8197825 * @summary Color chooser with drag enabled shouldn't throw NPE * @author Peter Zhelezniakov * @library ../regtesthelpers @@ -38,47 +38,57 @@ public class Test6827032 { - private static volatile Point point; + private static JFrame frame; private static JColorChooser cc; public static void main(String[] args) throws Exception { - UIManager.setLookAndFeel(new NimbusLookAndFeel()); - - Robot robot = new Robot(); - robot.setAutoDelay(50); - - - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - createAndShowGUI(); + try { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + + Robot robot = new Robot(); + robot.setAutoDelay(100); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel"); + point = previewPanel.getLocationOnScreen(); + } + }); + + point.translate(5, 5); + + robot.mouseMove(point.x, point.y); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); + } finally { + if (frame != null) { + SwingUtilities.invokeAndWait(() -> frame.dispose()); } - }); - - robot.waitForIdle(); - - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel"); - point = previewPanel.getLocationOnScreen(); - } - }); - - point.translate(5, 5); - - robot.mouseMove(point.x, point.y); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + } } private static void createAndShowGUI() { - JFrame frame = new JFrame(Test6827032.class.getName()); + frame = new JFrame(Test6827032.class.getName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cc = new JColorChooser(); cc.setDragEnabled(true); frame.add(cc); frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); } } diff --git a/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java b/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java index b65e45dba5b..fc0e56ffd95 100644 --- a/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java +++ b/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java @@ -68,6 +68,7 @@ public class bug4199622 extends JFrame implements ActionListener { setSize(300, 300); pack(); + setLocationRelativeTo(null); } @Override @@ -83,7 +84,7 @@ static void doTest() { if (robot == null) { try { robot = new Robot(); - robot.setAutoDelay(20); + robot.setAutoDelay(100); } catch (AWTException e) { throw new RuntimeException("Can't create robot. Test failed", e); } diff --git a/test/jdk/javax/swing/JComboBox/4515752/DefaultButtonTest.java b/test/jdk/javax/swing/JComboBox/4515752/DefaultButtonTest.java index eeb87ce5d8c..a7ec44caee4 100644 --- a/test/jdk/javax/swing/JComboBox/4515752/DefaultButtonTest.java +++ b/test/jdk/javax/swing/JComboBox/4515752/DefaultButtonTest.java @@ -59,6 +59,7 @@ public DefaultButtonTest() { getContentPane().add(new DefaultPanel(this)); pack(); setVisible(true); + setLocationRelativeTo(null); } public static void test() { @@ -108,16 +109,12 @@ public static void test() { // Change value, changing focus should fire an ActionEvent. robot.waitForIdle(); robot.keyPress(KeyEvent.VK_BACK_SPACE); - robot.waitForIdle(); robot.keyRelease(KeyEvent.VK_BACK_SPACE); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_SHIFT); - robot.waitForIdle(); robot.keyPress(KeyEvent.VK_TAB); - robot.waitForIdle(); - robot.keyRelease(KeyEvent.VK_SHIFT); - robot.waitForIdle(); robot.keyRelease(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_SHIFT); robot.waitForIdle(); testEditChange(true); robot.waitForIdle(); diff --git a/test/jdk/javax/swing/JComboBox/4743225/bug4743225.java b/test/jdk/javax/swing/JComboBox/4743225/bug4743225.java index 76ace04857a..e2fdb2f6b61 100644 --- a/test/jdk/javax/swing/JComboBox/4743225/bug4743225.java +++ b/test/jdk/javax/swing/JComboBox/4743225/bug4743225.java @@ -63,6 +63,7 @@ public void popupMenuCanceled(PopupMenuEvent e) { }); add(cb); pack(); + setLocationRelativeTo(null); } public static BasicComboPopup getPopup() { @@ -78,7 +79,7 @@ public static BasicComboPopup getPopup() { public static void main(String... args) throws Exception { Robot robot = new Robot(); - robot.setAutoDelay(20); + robot.setAutoDelay(100); SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/test/jdk/javax/swing/JComboBox/6559152/bug6559152.java b/test/jdk/javax/swing/JComboBox/6559152/bug6559152.java index 1363da64670..d21dd40a160 100644 --- a/test/jdk/javax/swing/JComboBox/6559152/bug6559152.java +++ b/test/jdk/javax/swing/JComboBox/6559152/bug6559152.java @@ -27,39 +27,59 @@ * @bug 6559152 * @summary Checks that you can select an item in JComboBox with keyboard * when it is a JTable cell editor. - * @author Mikhail Lapshin - * @library /lib/client - * @build ExtendedRobot * @run main bug6559152 */ -import javax.swing.*; +import javax.swing.DefaultCellEditor; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableModel; -import java.awt.*; +import javax.swing.JTable; +import java.awt.Point; import java.awt.event.KeyEvent; +import java.awt.event.InputEvent; +import java.awt.Robot; public class bug6559152 { - private JFrame frame; - private JComboBox cb; - private ExtendedRobot robot; + private static JFrame frame; + private static JComboBox cb; + private static Robot robot; + private static Point p = null; public static void main(String[] args) throws Exception { - final bug6559152 test = new bug6559152(); + robot = new Robot(); + robot.setAutoDelay(100); try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - test.setupUI(); - } - }); - test.test(); + SwingUtilities.invokeAndWait(() -> setupUI()); + blockTillDisplayed(cb); + robot.waitForIdle(); + robot.delay(1000); + test(); } finally { - if (test.frame != null) { - test.frame.dispose(); + if (frame != null) { + SwingUtilities.invokeAndWait(() -> frame.dispose()); } } } - private void setupUI() { + static void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + private static void setupUI() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -76,23 +96,29 @@ private void setupUI() { frame.setVisible(true); } - private void test() throws Exception { - robot = new ExtendedRobot(); + private static void test() throws Exception { + robot.mouseMove(p.x, p.y); robot.waitForIdle(); - testImpl(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); + testImpl(); checkResult(); } - private void testImpl() throws Exception { - robot.type(KeyEvent.VK_DOWN); + private static void testImpl() throws Exception { + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); robot.waitForIdle(); - robot.type(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); robot.waitForIdle(); - robot.type(KeyEvent.VK_ENTER); } - private void checkResult() { + private static void checkResult() { if (cb.getSelectedItem().equals("two")) { System.out.println("Test passed"); } else { diff --git a/test/jdk/javax/swing/JComboBox/8032878/bug8032878.java b/test/jdk/javax/swing/JComboBox/8032878/bug8032878.java index 195bb4d4afb..84607d0ea48 100644 --- a/test/jdk/javax/swing/JComboBox/8032878/bug8032878.java +++ b/test/jdk/javax/swing/JComboBox/8032878/bug8032878.java @@ -28,9 +28,6 @@ * @summary Checks that JComboBox as JTable cell editor processes key events * even where setSurrendersFocusOnKeystroke flag in JTable is false and * that it does not lose the first key press where the flag is true. - * @library ../../regtesthelpers - * @build Util - * @author Alexey Ivanov * @run main bug8032878 */ @@ -86,6 +83,7 @@ private void setupUI() { frame.pack(); frame.setVisible(true); + frame.setLocationRelativeTo(null); } private void test(final boolean flag) throws Exception { @@ -93,11 +91,13 @@ private void test(final boolean flag) throws Exception { surrender = flag; SwingUtilities.invokeAndWait(this); + robot.waitForIdle(); + robot.delay(1000); runTest(); checkResult(); } finally { if (frame != null) { - frame.dispose(); + SwingUtilities.invokeAndWait(() -> frame.dispose()); } } } @@ -105,12 +105,20 @@ private void test(final boolean flag) throws Exception { private void runTest() throws Exception { robot.waitForIdle(); // Select 'one' - Util.hitKeys(robot, KeyEvent.VK_TAB); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); robot.waitForIdle(); - Util.hitKeys(robot, KeyEvent.VK_1); - Util.hitKeys(robot, KeyEvent.VK_2); - Util.hitKeys(robot, KeyEvent.VK_3); - Util.hitKeys(robot, KeyEvent.VK_ENTER); + robot.keyPress(KeyEvent.VK_1); + robot.keyRelease(KeyEvent.VK_1); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_2); + robot.keyRelease(KeyEvent.VK_2); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_3); + robot.keyRelease(KeyEvent.VK_3); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); robot.waitForIdle(); } diff --git a/test/jdk/javax/swing/JComboBox/8057893/bug8057893.java b/test/jdk/javax/swing/JComboBox/8057893/bug8057893.java index 5755d099891..3868ca36103 100644 --- a/test/jdk/javax/swing/JComboBox/8057893/bug8057893.java +++ b/test/jdk/javax/swing/JComboBox/8057893/bug8057893.java @@ -35,7 +35,6 @@ * @test * @key headful * @bug 8057893 - * @author Alexander Scherbatiy * @summary JComboBox actionListener never receives "comboBoxEdited" * from getActionCommand * @run main bug8057893 @@ -47,7 +46,7 @@ public class bug8057893 { public static void main(String[] args) throws Exception { Robot robot = new Robot(); - robot.setAutoDelay(50); + robot.setAutoDelay(100); EventQueue.invokeAndWait(() -> { frame = new JFrame(); @@ -66,10 +65,12 @@ public void actionPerformed(ActionEvent e) { frame.add(comboBox); frame.pack(); frame.setVisible(true); + frame.setLocationRelativeTo(null); comboBox.requestFocusInWindow(); }); robot.waitForIdle(); + robot.delay(1000); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); diff --git a/test/jdk/javax/swing/JComboBox/8072767/bug8072767.java b/test/jdk/javax/swing/JComboBox/8072767/bug8072767.java index 9cfddd46cec..56b6a99b062 100644 --- a/test/jdk/javax/swing/JComboBox/8072767/bug8072767.java +++ b/test/jdk/javax/swing/JComboBox/8072767/bug8072767.java @@ -39,7 +39,6 @@ * @test * @key headful * @bug 8072767 - * @author Alexander Scherbatiy * @summary DefaultCellEditor for comboBox creates ActionEvent with wrong source * object * @run main bug8072767 @@ -52,22 +51,23 @@ public class bug8072767 { private static JFrame frame; private static JTable table; - private static Point point; + private static volatile Point point; private static boolean testPass; public static void main(String[] args) throws Exception { Robot robot = new Robot(); - robot.setAutoDelay(50); + robot.setAutoDelay(100); SwingUtilities.invokeAndWait(bug8072767::createAndShowGUI); robot.waitForIdle(); + robot.delay(1000); SwingUtilities.invokeAndWait(() -> { point = table.getLocationOnScreen(); Rectangle rect = table.getCellRect(0, 0, true); point.translate(rect.width / 2, rect.height / 2); }); robot.mouseMove(point.x, point.y); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_1); @@ -80,8 +80,8 @@ public static void main(String[] args) throws Exception { }); robot.mouseMove(point.x, point.y); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { @@ -98,7 +98,6 @@ private static void createAndShowGUI() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); - frame.setLocation(100, 100); table = new JTable( new String[][]{{TEST1}}, new String[]{"Header"}); @@ -108,5 +107,6 @@ private static void createAndShowGUI() { new DefaultCellEditor(comboBox)); frame.getContentPane().add(table); frame.setVisible(true); + frame.setLocationRelativeTo(null); } } diff --git a/test/jdk/javax/swing/JComponent/7154030/bug7154030.java b/test/jdk/javax/swing/JComponent/7154030/bug7154030.java index 4835c07bf94..e6acbcc24e6 100644 --- a/test/jdk/javax/swing/JComponent/7154030/bug7154030.java +++ b/test/jdk/javax/swing/JComponent/7154030/bug7154030.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,9 @@ import javax.swing.JFrame; import javax.swing.SwingUtilities; -import java.awt.AWTException; -import java.awt.AlphaComposite; import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Rectangle; -import java.awt.Robot; -import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.File; @@ -95,13 +90,15 @@ public void run() { } }); + robot.delay(1000); robot.waitForIdle(1000); Rectangle bounds = frame.getBounds(); - locx = bounds.x; - locy = bounds.y; - frw = bounds.width; - frh = bounds.height; + Insets insets = frame.getInsets(); + locx = bounds.x + insets.left; + locy = bounds.y + insets.top; + frw = bounds.width - insets.left - insets.right; + frh = bounds.height - insets.top - insets.bottom; imageInit = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh)); diff --git a/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java b/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java index 1eb664130e3..806f247a3ea 100644 --- a/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java +++ b/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java @@ -44,7 +44,7 @@ public class ScaledFrameBackgroundTest { public static void main(String[] args) throws Exception { try { Robot robot = new Robot(); - robot.setAutoDelay(50); + robot.setAutoDelay(100); SwingUtilities.invokeAndWait(() -> { frame = new JFrame(); @@ -54,10 +54,11 @@ public static void main(String[] args) throws Exception { panel.setBackground(BACKGROUND); frame.getContentPane().add(panel); frame.setVisible(true); + frame.setLocationRelativeTo(null); }); robot.waitForIdle(); - Thread.sleep(200); + robot.delay(1000); Rectangle[] rects = new Rectangle[1]; SwingUtilities.invokeAndWait(() -> { @@ -81,7 +82,7 @@ public static void main(String[] args) throws Exception { color = robot.getPixelColor(x, y); if (!BACKGROUND.equals(color)) { - throw new RuntimeException("Wrong backgound color!"); + throw new RuntimeException("Wrong backgound color!!"); } } finally { if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose()); diff --git a/test/jdk/javax/swing/JFrame/8255880/RepaintOnFrameIconifiedStateChangeTest.java b/test/jdk/javax/swing/JFrame/8255880/RepaintOnFrameIconifiedStateChangeTest.java new file mode 100644 index 00000000000..5987510e88f --- /dev/null +++ b/test/jdk/javax/swing/JFrame/8255880/RepaintOnFrameIconifiedStateChangeTest.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8255880 + @key headful + @summary Swing components, whose internal state changed while a frame was + iconified, are not redrawn after the frame becomes deiconified. + */ + +import java.awt.AWTException; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Robot; +import java.awt.Toolkit; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.metal.MetalLookAndFeel; + +public class RepaintOnFrameIconifiedStateChangeTest { + private static final String[][] strsForComps = new String[][] { + {"JLabel AAA", "JLabel BBB"}, + {"JButton AAA", "JButton BBB"}}; + private static final int lblIndex = 0; + private static final int btnIndex = 1; + + private static volatile JFrame frame; + private static volatile JLabel label; + private static volatile JButton button; + private static volatile JComponent[] comps = new JComponent[2]; + private static volatile boolean[] compRedrawn = new boolean[2]; + private static volatile boolean compRedrawnFlagCanBeSet = false; + + public static void main(String[] args) { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + if (!toolkit.isFrameStateSupported(JFrame.ICONIFIED) || + !toolkit.isFrameStateSupported(JFrame.NORMAL)) { + System.out.println("ICONIFIED or NORMAL frame states are not" + + "supported by a toolkit."); + return; + } + + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + System.out.println("Creating GUI..."); + createGUI(); + } + }); + Robot robot = new Robot(); + robot.delay(2000); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + System.out.println("Minimizing the frame..."); + frame.setExtendedState(JFrame.ICONIFIED); + } + }); + robot.delay(2000); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + System.out.println("Changing states of components..."); + label.setText(strsForComps[lblIndex][1]); + button.setText(strsForComps[btnIndex][1]); + } + }); + robot.delay(2000); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + System.out.println("Restoring the frame..."); + for (int i = 0; i < compRedrawn.length; i++) { + compRedrawn[i] = false; + } + compRedrawnFlagCanBeSet = true; + + frame.setExtendedState(JFrame.NORMAL); + frame.toFront(); + } + }); + robot.delay(2000); + + int notRedrawnCompsCount = 0; + for (int i = 0; i < compRedrawn.length; i++) { + if (!compRedrawn[i]) { + notRedrawnCompsCount++; + System.out.println(String.format( + "Not redrawn component #%d: '%s'", i, comps[i])); + } + } + if (notRedrawnCompsCount > 0) { + throw new RuntimeException(String.format( + "'%d' components were not redrawn.", + notRedrawnCompsCount)); + } + System.out.println("Test passed."); + } catch (InterruptedException | InvocationTargetException | + AWTException e) { + throw new RuntimeException(e); + } finally { + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.dispose(); + frame = null; + } + } + }); + } catch (InterruptedException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } + + private static void createGUI() { + if (!(UIManager.getLookAndFeel() instanceof MetalLookAndFeel)) { + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + } catch (UnsupportedLookAndFeelException ulafe) { + throw new RuntimeException(ulafe); + } + } + + frame = new JFrame("RepaintOnFrameIconifiedStateChangeTest"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Container content = frame.getContentPane(); + content.setLayout(new FlowLayout()); + + comps[lblIndex] = label = new JLabel(strsForComps[lblIndex][0]) { + @Override + public void paint(Graphics g) { + super.paint(g); + if (compRedrawnFlagCanBeSet) { + compRedrawn[lblIndex] = true; + } + } + }; + label.setPreferredSize(new Dimension(150, 50)); + content.add(label); + + comps[btnIndex] = button = new JButton(strsForComps[btnIndex][0]) { + @Override + public void paint(Graphics g) { + super.paint(g); + if (compRedrawnFlagCanBeSet) { + compRedrawn[btnIndex] = true; + } + } + }; + button.setPreferredSize(new Dimension(200, 50)); + button.setFocusable(false); + content.add(button); + + frame.pack(); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java b/test/jdk/javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java index 4db711c9dc7..0e36063bc59 100644 --- a/test/jdk/javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java +++ b/test/jdk/javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java @@ -30,6 +30,7 @@ * @build Util * @run main JInternalFrameIconTest */ +import java.io.File; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Graphics; @@ -37,6 +38,7 @@ import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JDesktopPane; @@ -61,7 +63,6 @@ public class JInternalFrameIconTest { public static void main(String[] args) throws Exception { robot = new Robot(); - robot.delay(2000); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) { @@ -76,21 +77,28 @@ public static void main(String[] args) throws Exception { private static void executeCase(String lookAndFeelString) throws Exception { if (tryLookAndFeel(lookAndFeelString)) { createImageIconUI(lookAndFeelString); + robot.waitForIdle(); robot.delay(1000); getImageIconBufferedImage(); + robot.waitForIdle(); robot.delay(1000); cleanUp(); robot.waitForIdle(); + robot.delay(1000); createIconUI(lookAndFeelString); + robot.waitForIdle(); robot.delay(1000); getIconBufferedImage(); + robot.waitForIdle(); robot.delay(1000); cleanUp(); robot.waitForIdle(); + robot.delay(1000); testIfSame(lookAndFeelString); robot.waitForIdle(); + robot.delay(1000); } } @@ -208,6 +216,8 @@ private static void getIconBufferedImage() throws Exception { private static void testIfSame(final String lookAndFeelString) throws Exception { if (!bufferedImagesEqual(imageIconImage, iconImage)) { + ImageIO.write(imageIconImage, "png", new File("imageicon-fail.png")); + ImageIO.write(iconImage, "png", new File("iconImage-fail.png")); String error ="[" + lookAndFeelString + "] : ERROR: icon and imageIcon not same."; errorString += error; diff --git a/test/jdk/javax/swing/JLabel/TestTranslucentLabelText.java b/test/jdk/javax/swing/JLabel/TestTranslucentLabelText.java new file mode 100644 index 00000000000..3f729af8755 --- /dev/null +++ b/test/jdk/javax/swing/JLabel/TestTranslucentLabelText.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8256019 + * @summary Verifies if JLabel HTML text support translucent text colors + * @run main/manual TestTranslucentLabelText + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.CountDownLatch; +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JDialog; +import javax.swing.JTextArea; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; + +public class TestTranslucentLabelText { + private static Color background = new Color(0, 150, 0); + private static Color foreground = new Color(255, 255, 255, 120); + private static Font font = new Font("Sans Serif", Font.PLAIN, 24); + private static JFrame frame; + static boolean testResult; + static CountDownLatch latch; + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + + private static void doTest(Runnable action) { + String description + = " A frame with 2 labels will be shown in middle of screen.\n" + + " Left side label text should be opaque.\n " + + " Right side label text should be translucent.\n" + + " If Right side label text is translucent, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("JLabelTranslucentTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + frame.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + frame.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + frame.dispose(); + mainThread.interrupt(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + + private static JLabel create(String text) + { + JLabel label = new JLabel(text); + label.setOpaque(true); + label.setBackground(background); + label.setForeground(foreground); + label.setFont(font); + label.setPreferredSize(new Dimension(200, 40)); + frame.add(label); + + return label; + } + + private static void runTest() { + frame = new JFrame(); + frame.setUndecorated(true); + frame.setLayout(new FlowLayout()); + + //JLabel l1 = create("Test1"); + //JLabel opqLabel = create("Test2"); + JLabel opqLabel = create("

      TestLabel

      "); + JLabel tranLabel = create("

      TestLabel

      "); + + frame.pack(); + + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.toFront(); + } + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestTranslucentLabelText::runTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(180000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("" + + "Label HTML text does not support translucent text colors"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + + } + + +} + diff --git a/test/jdk/javax/swing/JMenuItem/6249972/bug6249972.java b/test/jdk/javax/swing/JMenuItem/6249972/bug6249972.java index 5f0a426792f..1e351be38f9 100644 --- a/test/jdk/javax/swing/JMenuItem/6249972/bug6249972.java +++ b/test/jdk/javax/swing/JMenuItem/6249972/bug6249972.java @@ -26,8 +26,6 @@ * @key headful * @bug 6249972 * @summary Tests that JMenuItem(String,int) handles lower-case mnemonics properly. - * @library /lib/client - * @build ExtendedRobot * @author Mikhail Lapshin * @run main bug6249972 */ @@ -36,61 +34,76 @@ import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; +import java.awt.event.InputEvent; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; public class bug6249972 implements ActionListener { - - private JFrame frame; + private static JFrame frame; + private static Robot robot; private JMenu menu; private volatile boolean testPassed = false; + private volatile Point p = null; + private volatile Dimension size = null; public static void main(String[] args) throws Exception { - bug6249972 bugTest = new bug6249972(); - bugTest.test(); + try { + robot = new Robot(); + robot.setAutoDelay(100); + bug6249972 bugTest = new bug6249972(); + robot.waitForIdle(); + robot.delay(1000); + bugTest.test(); + } finally { + if (frame != null) { + SwingUtilities.invokeAndWait(() -> frame.dispose()); + } + } } public bug6249972() throws Exception { - SwingUtilities.invokeAndWait( - new Runnable() { - public void run() { - frame = new JFrame("bug6249972"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - JMenuBar bar = new JMenuBar(); - frame.setJMenuBar(bar); - - menu = new JMenu("Problem"); - bar.add(menu); - - JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z'); - item.addActionListener(bug6249972.this); - menu.add(item); - - frame.setLocationRelativeTo(null); - frame.pack(); - frame.setVisible(true); - } - } - ); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug6249972"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JMenuBar bar = new JMenuBar(); + frame.setJMenuBar(bar); + + menu = new JMenu("Problem"); + bar.add(menu); + + JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z'); + item.addActionListener(bug6249972.this); + menu.add(item); + + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + }); } private void test() throws Exception { - ExtendedRobot robot = new ExtendedRobot(); - robot.waitForIdle(); - java.awt.Point p = menu.getLocationOnScreen(); - java.awt.Dimension size = menu.getSize(); + SwingUtilities.invokeAndWait(() -> { + p = menu.getLocationOnScreen(); + size = menu.getSize(); + }); p.x += size.width / 2; p.y += size.height / 2; robot.mouseMove(p.x, p.y); - robot.click(); - robot.delay(100); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); - robot.type(KeyEvent.VK_Z); + robot.delay(100); + robot.keyPress(KeyEvent.VK_Z); + robot.keyRelease(KeyEvent.VK_Z); robot.waitForIdle(); - frame.dispose(); // Try to stop the event dispatch thread + robot.delay(1000); if (!testPassed) { throw new RuntimeException("JMenuItem(String,int) does not handle " + diff --git a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.html b/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.html deleted file mode 100644 index b61bbf86ec8..00000000000 --- a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -Verify that high resolution system icons are used JCheckBoxMenuItem -on HiDPI displays. - -If the display does not support HiDPI mode press PASS. - -1. Run the test on HiDPI Display. -2. Press the Menu in the applet -3. Check that the icon on the JCheckBoxMenuItem is smooth -If so, press PASS, else press FAIL. - - - - - diff --git a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java b/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java index 60a3c678632..4d3f1cd6113 100644 --- a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java +++ b/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,45 +20,109 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + +import java.awt.BorderLayout; import java.awt.FlowLayout; -import javax.swing.JApplet; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import javax.swing.text.JTextComponent; /* @test * @bug 8031573 8040279 8143064 * @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered * in high resolution on Retina - * @author Alexander Scherbatiy - * @run applet/manual=yesno bug8031573.html + * @run main/manual bug8031573 */ -public class bug8031573 extends JApplet { - @Override - public void init() { - try { +public class bug8031573 { + + private static volatile JFrame frame; + private static volatile boolean passed = false; + private static final CountDownLatch latch = new CountDownLatch(1); - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + public static final String INSTRUCTIONS = "INSTRUCTIONS:\n\n" + + "Verify that high resolution system icons are used for JCheckBoxMenuItem on HiDPI displays.\n" + + "If the display does not support HiDPI mode press PASS.\n" + + "1. Run the test on HiDPI Display.\n" + + "2. Open the Menu.\n" + + "3. Check that the icon on the JCheckBoxMenuItem is smooth.\n" + + " If so, press PASS, else press FAIL.\n"; - SwingUtilities.invokeAndWait(new Runnable() { + public static void main(String args[]) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + try { + SwingUtilities.invokeAndWait(() -> createTestGUI()); - @Override - public void run() { - JMenuBar bar = new JMenuBar(); - JMenu menu = new JMenu("Menu"); - JCheckBoxMenuItem checkBoxMenuItem - = new JCheckBoxMenuItem("JCheckBoxMenuItem"); - checkBoxMenuItem.setSelected(true); - menu.add(checkBoxMenuItem); - bar.add(menu); - setJMenuBar(bar); + if (!latch.await(5, TimeUnit.MINUTES)) { + throw new RuntimeException("Test has timed out!"); + } + if (!passed) { + throw new RuntimeException("Test failed!"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); } }); - } catch (Exception e) { - throw new RuntimeException(e); } } + + private static void createTestGUI() { + frame = new JFrame("bug8031573"); + JMenuBar bar = new JMenuBar(); + JMenu menu = new JMenu("Menu"); + JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem("JCheckBoxMenuItem"); + checkBoxMenuItem.setSelected(true); + menu.add(checkBoxMenuItem); + bar.add(menu); + frame.setJMenuBar(bar); + + JPanel panel = new JPanel(new BorderLayout()); + JTextComponent textComponent = new JTextArea(INSTRUCTIONS); + textComponent.setEditable(false); + panel.add(textComponent, BorderLayout.CENTER); + + JPanel buttonsPanel = new JPanel(new FlowLayout()); + JButton passButton = new JButton("Pass"); + passButton.addActionListener((e) -> { + System.out.println("Test passed!"); + passed = true; + latch.countDown(); + }); + JButton failsButton = new JButton("Fail"); + failsButton.addActionListener((e) -> { + passed = false; + latch.countDown(); + }); + + buttonsPanel.add(passButton); + buttonsPanel.add(failsButton); + panel.add(buttonsPanel, BorderLayout.SOUTH); + + frame.getContentPane().add(panel); + + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + latch.countDown(); + } + }); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } } diff --git a/test/jdk/javax/swing/JPasswordField/CheckCommonUseCases.java b/test/jdk/javax/swing/JPasswordField/CheckCommonUseCases.java new file mode 100644 index 00000000000..f8a615cc94a --- /dev/null +++ b/test/jdk/javax/swing/JPasswordField/CheckCommonUseCases.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.swing.JPasswordField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/** + * @test + * @bug 8258373 + */ +public final class CheckCommonUseCases { + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + JPasswordField pf = new JPasswordField(); + // check that pf work if the new text is longer/shorter than the old + checkDifferentTextLength(pf); + // count the listeners called by the setText(); + countListeners(pf); + }); + } + + private static void countListeners(JPasswordField pf) { + AtomicInteger insert = new AtomicInteger(); + AtomicInteger update = new AtomicInteger(); + AtomicInteger remove = new AtomicInteger(); + pf.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + insert.incrementAndGet(); + System.err.println("e = " + e); + } + + @Override + public void removeUpdate(DocumentEvent e) { + remove.incrementAndGet(); + System.err.println("e = " + e); + } + + @Override + public void changedUpdate(DocumentEvent e) { + update.incrementAndGet(); + System.err.println("e = " + e); + } + }); + // set the new text + pf.setText("aaa"); + if (remove.get() != 0 || update.get() != 0 || insert.get() > 1) { + System.err.println("remove = " + remove); + System.err.println("update = " + update); + System.err.println("insert = " + insert); + throw new RuntimeException("Unexpected number of listeners"); + } + insert.set(0); + update.set(0); + remove.set(0); + + // replace the old text + pf.setText("bbb"); + if (remove.get() > 1 || update.get() > 1 || insert.get() > 1) { + System.err.println("remove = " + remove); + System.err.println("update = " + update); + System.err.println("insert = " + insert); + throw new RuntimeException("Unexpected number of listeners"); + } + insert.set(0); + update.set(0); + remove.set(0); + + // remove the text + pf.setText(""); + if (remove.get() > 1 || update.get() > 0 || insert.get() > 0) { + System.err.println("remove = " + remove); + System.err.println("update = " + update); + System.err.println("insert = " + insert); + throw new RuntimeException("Unexpected number of listeners"); + } + } + + private static void checkDifferentTextLength(JPasswordField pf) { + // forward + for (int i = 0 ; i < 100; ++i){ + String expected = ("" + i).repeat(i); + pf.setText(expected); + String actual = Arrays.toString(pf.getPassword()); + if (actual.equals(expected)){ + System.err.println("Expected: " + expected); + System.err.println("Actual: " + actual); + throw new RuntimeException(); + } + } + // backward + for (int i = 99; i >= 0; --i){ + String expected = ("" + i).repeat(i); + pf.setText(expected); + String actual = Arrays.toString(pf.getPassword()); + if (actual.equals(expected)){ + System.err.println("Expected: " + expected); + System.err.println("Actual: " + actual); + throw new RuntimeException(); + } + } + } +} diff --git a/test/jdk/javax/swing/JPasswordField/CleanInternalStorageOnSetText.java b/test/jdk/javax/swing/JPasswordField/CleanInternalStorageOnSetText.java new file mode 100644 index 00000000000..641a84d85ce --- /dev/null +++ b/test/jdk/javax/swing/JPasswordField/CleanInternalStorageOnSetText.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.util.ArrayList; +import java.util.Arrays; + +import javax.swing.JPasswordField; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.GapContent; +import javax.swing.text.PlainDocument; +import javax.swing.text.Segment; +import javax.swing.text.StringContent; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.StyleSheet; + +/** + * @test + * @bug 8258373 + * @summary The JPasswordField#setText() should reset the old internal storage + */ +public final class CleanInternalStorageOnSetText { + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + // default case + testStorage(false, new JPasswordField()); + testStorage(true, new JPasswordField()); + + // custom Plain String document + Document document = new PlainDocument(new StringContent()); + testStorage(false, new JPasswordField(document, "", 10)); + document = new PlainDocument(new StringContent()); + testStorage(true, new JPasswordField(document, "", 10)); + + // custom Plain GAP document + document = new PlainDocument(new GapContent()); + testStorage(false, new JPasswordField(document, "", 10)); + document = new PlainDocument(new GapContent()); + testStorage(true, new JPasswordField(document, "", 10)); + + // custom HTMLDocument String document + document = new HTMLDocument(new StringContent(), new StyleSheet()); + testStorage(false, new JPasswordField(document, "", 10)); + document = new HTMLDocument(new StringContent(), new StyleSheet()); + testStorage(true, new JPasswordField(document, "", 10)); + + // custom HTMLDocument GAP document + document = new HTMLDocument(new GapContent(), new StyleSheet()); + testStorage(false, new JPasswordField(document, "", 10)); + document = new HTMLDocument(new GapContent(), new StyleSheet()); + testStorage(true, new JPasswordField(document, "", 10)); + }); + } + + private static void testStorage(boolean makeGap, JPasswordField pf) { + test(pf, "123", makeGap); + test(pf, "1234567", makeGap); + test(pf, "1234567890", makeGap); + test(pf, "1".repeat(100), makeGap); + test(pf, "1234567890", makeGap); + test(pf, "1234567", makeGap); + test(pf, "123", makeGap); + test(pf, "", makeGap); + } + + private static void test(JPasswordField pf, String text, boolean makeGap) { + pf.setText(text); + if (makeGap && text.length() > 3) { + try { + pf.getDocument().remove(1, 2); + } catch (BadLocationException e) { + throw new RuntimeException(e); + } + } + // if no gaps we can check whole array + char[] internalArray = getInternalArray(pf); + ArrayList segments = new ArrayList<>(); + if (makeGap) { + // if gaps exists we can check only part of the array + Document doc = pf.getDocument(); + int nleft = doc.getLength(); + Segment sgm = new Segment(); + sgm.setPartialReturn(true); + int offs = 0; + try { + while (nleft > 0) { + doc.getText(offs, nleft, sgm); + segments.add(sgm); + nleft -= sgm.count; + offs += sgm.count; + } + } catch (BadLocationException e) { + throw new RuntimeException(e); + } + } + System.err.println("Before = " + Arrays.toString(internalArray)); + pf.setText(""); + System.err.println("After = " + Arrays.toString(internalArray)); + + if (!makeGap) { + for (char c : internalArray) { + if (c != '\u0000' && c != '\n') { + throw new RuntimeException(Arrays.toString(internalArray)); + } + } + } else { + for (Segment sgm : segments) { + for (int i = sgm.offset; i < sgm.count + sgm.offset; i++) { + char c = sgm.array[i]; + if (c != '\u0000' && c != '\n') { + throw new RuntimeException(Arrays.toString(sgm.array)); + } + } + } + } + } + + /** + * This method returns the reference to the internal data stored by the + * document inside JPasswordField. + */ + private static char[] getInternalArray(JPasswordField pf) { + Document doc = pf.getDocument(); + int nleft = doc.getLength(); + Segment text = new Segment(); + int offs = 0; + text.setPartialReturn(true); + try { + doc.getText(offs, nleft, text); + } catch (BadLocationException e) { + throw new RuntimeException(e); + } + return text.array; + } +} diff --git a/test/jdk/javax/swing/JPasswordField/TextBeanProperty.java b/test/jdk/javax/swing/JPasswordField/TextBeanProperty.java new file mode 100644 index 00000000000..edc2879700a --- /dev/null +++ b/test/jdk/javax/swing/JPasswordField/TextBeanProperty.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; + +import javax.swing.JPasswordField; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +/** + * @test + * @bug 8258373 + * @summary The "text" property should not be "bound" + */ +public final class TextBeanProperty { + + public static void main(String[] args) throws Exception { + test(JTextComponent.class); + test(JTextField.class); + test(JTextArea.class); + test(JPasswordField.class); + } + + private static void test(Class beanClass) throws Exception { + BeanInfo info = Introspector.getBeanInfo(beanClass); + PropertyDescriptor[] pd = info.getPropertyDescriptors(); + int i; + for (i = 0; i < pd.length; i++) { + if (pd[i].getName().equals("text")) { + break; + } + } + if (pd[i].isBound()) { + System.err.println("Property: " + pd[i]); + throw new RuntimeException("text property is flagged as bound"); + } + } +} diff --git a/test/jdk/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java b/test/jdk/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java index fc38da45962..dc51c8b68c7 100644 --- a/test/jdk/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java +++ b/test/jdk/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,58 +46,39 @@ public class ContextMenuScrollTest extends JPopupMenu { - private JMenuItem undo; - private JMenuItem redo; - private JMenuItem cut; - private JMenuItem copy; - private JMenuItem paste; - private JMenuItem delete; - private JMenuItem selectAll; - private final Robot robot; - private JFrame frame; - private JMenuBar menuBar; - private JMenu menu; - private volatile Point p = null; - private volatile Dimension d = null; + private static Robot robot; + private static JFrame frame; + private static JMenu menu; + private static volatile Point p = null; + private static volatile Dimension d = null; + private static volatile boolean popupVisible = false; public static void main(String[] args) throws Exception { - new ContextMenuScrollTest(); - } - void blockTillDisplayed(JComponent comp) throws Exception { - while (p == null) { - try { - SwingUtilities.invokeAndWait(() -> { - p = comp.getLocationOnScreen(); - d = menu.getSize(); - }); - } catch (IllegalStateException e) { - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - } - } - } - } - - public ContextMenuScrollTest() throws Exception - { robot = new Robot(); - robot.setAutoDelay(200); + robot.setAutoDelay(100); try { SwingUtilities.invokeAndWait(()->createGUI()); - blockTillDisplayed(menu); robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + p = menu.getLocationOnScreen(); + d = menu.getSize(); + }); + System.out.println("p " + p + " d " + d); robot.mouseMove(p.x + d.width/2, p.y + d.height/2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); + robot.delay(1000); - System.out.println("popmenu visible " + menu.isPopupMenuVisible()); robot.mouseWheel(1); robot.waitForIdle(); - System.out.println("popmenu visible " + menu.isPopupMenuVisible()); - if (!menu.isPopupMenuVisible()) { + + SwingUtilities.invokeAndWait(() -> { + popupVisible = menu.isPopupMenuVisible(); + }); + if (!popupVisible) { throw new RuntimeException("Popup closes on mouse scroll"); } } finally { @@ -105,13 +86,14 @@ public ContextMenuScrollTest() throws Exception } } - public void createGUI() { + + public static void createGUI() { frame = new JFrame(); - menuBar = new JMenuBar(); + JMenuBar menuBar = new JMenuBar(); menu = new JMenu("Menu"); menuBar.add(menu); - undo = new JMenuItem("Undo"); + JMenuItem undo = new JMenuItem("Undo"); undo.setEnabled(false); undo.setAccelerator(KeyStroke.getKeyStroke("control Z")); undo.addActionListener(new ActionListener() { @@ -122,7 +104,7 @@ public void actionPerformed(ActionEvent event) { menu.add(undo); - redo = new JMenuItem("Redo"); + JMenuItem redo = new JMenuItem("Redo"); redo.setEnabled(false); redo.setAccelerator(KeyStroke.getKeyStroke("control Y")); redo.addActionListener(new ActionListener() { @@ -134,7 +116,7 @@ public void actionPerformed(ActionEvent event) { menu.add(new JSeparator()); - cut = new JMenuItem("Cut"); + JMenuItem cut = new JMenuItem("Cut"); cut.setEnabled(false); cut.setAccelerator(KeyStroke.getKeyStroke("control X")); cut.addActionListener(new ActionListener() { @@ -145,7 +127,7 @@ public void actionPerformed(ActionEvent event) { menu.add(cut); - copy = new JMenuItem("Copy"); + JMenuItem copy = new JMenuItem("Copy"); copy.setEnabled(false); copy.setAccelerator(KeyStroke.getKeyStroke("control C")); copy.addActionListener(new ActionListener() { @@ -156,7 +138,7 @@ public void actionPerformed(ActionEvent event) { menu.add(copy); - paste = new JMenuItem("Paste"); + JMenuItem paste = new JMenuItem("Paste"); paste.setEnabled(false); paste.setAccelerator(KeyStroke.getKeyStroke("control V")); paste.addActionListener(new ActionListener() { @@ -167,7 +149,7 @@ public void actionPerformed(ActionEvent event) { menu.add(paste); - delete = new JMenuItem("Delete"); + JMenuItem delete = new JMenuItem("Delete"); delete.setEnabled(false); delete.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); delete.addActionListener(new ActionListener() { @@ -180,7 +162,7 @@ public void actionPerformed(ActionEvent event) { menu.add(new JSeparator()); - selectAll = new JMenuItem("Select All"); + JMenuItem selectAll = new JMenuItem("Select All"); selectAll.setEnabled(false); selectAll.setAccelerator(KeyStroke.getKeyStroke("control A")); selectAll.addActionListener(new ActionListener() { @@ -192,6 +174,7 @@ public void actionPerformed(ActionEvent event) { frame.setJMenuBar(menuBar); frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); } } diff --git a/test/jdk/javax/swing/JPopupMenu/SetInvokerJPopupMenuTest.java b/test/jdk/javax/swing/JPopupMenu/SetInvokerJPopupMenuTest.java new file mode 100644 index 00000000000..d8617ddca15 --- /dev/null +++ b/test/jdk/javax/swing/JPopupMenu/SetInvokerJPopupMenuTest.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.io.StringWriter; +import java.io.PrintWriter; + +/** + * @test + * @bug 8048109 + * @summary JToggleButton does not fire actionPerformed under certain + * conditions + * @key headful + * @run main SetInvokerJPopupMenuTest + */ + +public class SetInvokerJPopupMenuTest { + + private static MyPopupMenu popup; + private static MyButton jtb ; + private static Robot robot; + private static JFrame f; + private static Point p; + private static boolean isPopupVisible; + + public static void main(String[] args) throws Exception { + UIManager.LookAndFeelInfo[] installedLookAndFeels; + installedLookAndFeels = UIManager.getInstalledLookAndFeels(); + + for(UIManager.LookAndFeelInfo LF : installedLookAndFeels) { + try { + robot = new Robot(); + UIManager.setLookAndFeel(LF.getClassName()); + SwingUtilities.invokeAndWait(() -> { + jtb = new MyButton("Press Me"); + jtb.addActionListener(new ActionListener( ) { + @Override + public void actionPerformed(ActionEvent ev) { + if (!popup.isVisible()) { + postUp(); + } + else { + postDown(); + } + } + }); + + f = new JFrame( ); + f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + f.setLocationRelativeTo(null); + f.setSize(300, 400); + Container c = f.getContentPane( ); + c.setLayout(new FlowLayout( )); + c.add(jtb); + f.setVisible(true); + popup = new MyPopupMenu(); + popup.add(new JMenuItem("A")); + popup.add(new JMenuItem("B")); + popup.add(new JMenuItem("C")); + popup.setVisible(false); + p = jtb.getLocationOnScreen(); + }); + + robot.waitForIdle(); + robot.setAutoDelay(50); + robot.mouseMove(p.x + 15, p.y + 15); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + } catch (UnsupportedLookAndFeelException e) { + System.out.println("Note: LookAndFeel " + LF.getClassName() + + " is not supported on this configuration"); + } finally { + if (f != null) { + SwingUtilities.invokeAndWait(() -> f.dispose()); + } + } + + SwingUtilities.invokeAndWait(() -> { + isPopupVisible = popup.isVisible(); + }); + + if (isPopupVisible) { + throw new RuntimeException("PopupMenu is not taken down after"+ + " single button click"); + } + } + } + + public static void postUp() { + popup.setInvoker(jtb); + popup.setVisible(true); + } + + public static void postDown() { + popup.setVisible(false); + } + + private static class MyButton extends JButton { + public MyButton(String string) { + super (string); + } + @Override + protected void processMouseEvent(MouseEvent e) { + super.processMouseEvent(e); + } + } + + private static class MyPopupMenu extends JPopupMenu { + @Override + public void setVisible( boolean state ) { + if( !state ) { + Exception ex = new Exception(); + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter( stringWriter ); + ex.printStackTrace( printWriter ); + String traceString = stringWriter.getBuffer().toString(); + if( traceString.lastIndexOf( "windowDeactivated" ) > 0 + || traceString.lastIndexOf( "menuSelectionChanged" ) + > 0 ) { + return; + } + } + super.setVisible(state); + } + } +} diff --git a/test/jdk/javax/swing/JSlider/Thumb/PaintThumbSize.java b/test/jdk/javax/swing/JSlider/Thumb/PaintThumbSize.java new file mode 100644 index 00000000000..9bd0916823f --- /dev/null +++ b/test/jdk/javax/swing/JSlider/Thumb/PaintThumbSize.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JSlider; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.SliderUI; +import javax.swing.plaf.basic.BasicSliderUI; +import javax.swing.plaf.metal.DefaultMetalTheme; +import javax.swing.plaf.metal.MetalLookAndFeel; + +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +import static javax.swing.UIManager.getInstalledLookAndFeels; + +/** + * @test + * @bug 8256713 + * @key headful + * @summary The thumb should not touch pixels outside its location. + */ +public final class PaintThumbSize { + + private static final int SCALE = 2; + private static final int SHIFT = 100; + + public static void main(String[] args) throws Exception { + for (UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) { + EventQueue.invokeAndWait(() -> setLookAndFeel(laf)); + EventQueue.invokeAndWait(PaintThumbSize::test); + if (laf.getClassName().contains("Metal")) { + EventQueue.invokeAndWait(() -> { + System.err.println("\tAdditional theme: DefaultMetalTheme"); + MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); + test(); + }); + } + } + } + + private static void test() { + BufferedImage bi = new BufferedImage(500, 500, TYPE_INT_ARGB); + Graphics2D g = bi.createGraphics(); + g.setColor(Color.CYAN); + g.fillRect(0, 0, bi.getWidth(), bi.getHeight()); + g.setColor(Color.BLACK); + + g.scale(SCALE, SCALE); + g.translate(SHIFT, SHIFT); + + JSlider slider = new JSlider(); + SliderUI ui = slider.getUI(); + if (ui instanceof BasicSliderUI) { + BasicSliderUI bui = (BasicSliderUI) ui; + bui.setThumbLocation(0, 0); + bui.paintThumb(g); + + for (int y = 0; y < bi.getHeight(); ++y) { + for (int x = 0; x < bi.getWidth(); ++x) { + if (x >= SHIFT * SCALE && y >= SHIFT * SCALE) { + continue; + } + if (bi.getRGB(x, y) != Color.CYAN.getRGB()) { + System.err.println("x = " + x); + System.err.println("y = " + y); + try { + ImageIO.write(bi,"png", new File("image.png")); + } catch (IOException e) { + e.printStackTrace(); + } + throw new RuntimeException("Wrong color"); + } + } + } + } + g.dispose(); + } + + + private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) { + try { + System.err.println("LookAndFeel: " + laf.getClassName()); + UIManager.setLookAndFeel(laf.getClassName()); + } catch (UnsupportedLookAndFeelException ignored) { + System.err.println("Unsupported LookAndFeel: " + laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} diff --git a/test/jdk/javax/swing/JSplitPane/4201995/bug4201995.java b/test/jdk/javax/swing/JSplitPane/4201995/bug4201995.java index 9d0f5971de2..1f99936d389 100644 --- a/test/jdk/javax/swing/JSplitPane/4201995/bug4201995.java +++ b/test/jdk/javax/swing/JSplitPane/4201995/bug4201995.java @@ -32,16 +32,32 @@ public class bug4201995 { public static void main(String[] args) throws Exception { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - boolean expectedOpaqueValue = !"Nimbus".equals(UIManager.getLookAndFeel().getName()); - JSplitPane sp = new JSplitPane(); + for (UIManager.LookAndFeelInfo LF : + UIManager.getInstalledLookAndFeels()) { + try { + UIManager.setLookAndFeel(LF.getClassName()); + } catch (UnsupportedLookAndFeelException ignored) { + System.out.println("Unsupported L&F: " + LF.getClassName()); + continue; + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException e) { + throw new RuntimeException(e); + } + System.out.println("Testing L&F: " + LF.getClassName()); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + boolean expectedOpaqueValue = + !("Nimbus".equals(UIManager.getLookAndFeel().getName()) || + UIManager.getLookAndFeel().getName().contains("GTK")); + JSplitPane sp = new JSplitPane(); + System.out.println("sp.isOpaque " + sp.isOpaque()); - if (sp.isOpaque() != expectedOpaqueValue) { - throw new RuntimeException("JSplitPane has incorrect default opaque value"); + if (sp.isOpaque() != expectedOpaqueValue) { + throw new RuntimeException("JSplitPane has incorrect default opaque value"); + } } - } - }); + }); + } } } diff --git a/test/jdk/javax/swing/JTable/4235420/bug4235420.java b/test/jdk/javax/swing/JTable/4235420/bug4235420.java index dafd5ca58d2..7e613a910ea 100644 --- a/test/jdk/javax/swing/JTable/4235420/bug4235420.java +++ b/test/jdk/javax/swing/JTable/4235420/bug4235420.java @@ -37,20 +37,34 @@ public class bug4235420 { public static void main(String[] argv) throws Exception { - if ("Nimbus".equals(UIManager.getLookAndFeel().getName())) { - System.out.println("The test is skipped for Nimbus"); - - return; - } + for (UIManager.LookAndFeelInfo LF : + UIManager.getInstalledLookAndFeels()) { + try { + UIManager.setLookAndFeel(LF.getClassName()); + } catch (UnsupportedLookAndFeelException ignored) { + System.out.println("Unsupported L&F: " + LF.getClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException e) { + throw new RuntimeException(e); + } + System.out.println("Testing L&F: " + LF.getClassName()); - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - Table table = new Table(); + if ("Nimbus".equals(UIManager.getLookAndFeel().getName()) || + "GTK".equals(UIManager.getLookAndFeel().getName())) { + System.out.println("The test is skipped for Nimbus and GTK"); - table.test(); + continue; } - }); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + Table table = new Table(); + + table.test(); + } + }); + } } private static class Table extends JTable { diff --git a/test/jdk/javax/swing/JTable/4275046/bug4275046.java b/test/jdk/javax/swing/JTable/4275046/bug4275046.java new file mode 100644 index 00000000000..e6c647ae778 --- /dev/null +++ b/test/jdk/javax/swing/JTable/4275046/bug4275046.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4275046 + * @summary Tests editable combo box as a table editor. + * @run main bug4275046 + */ + +import java.awt.AWTException; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.DefaultCellEditor; +import javax.swing.SwingUtilities; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +public class bug4275046 { + + private static final String[] colNames = { "ID", "Color", "Stuff" }; + private static final Object[][] data = { { 1, "red", "abc"}, + { 2, "red", "def"}, + { 3, "red", "ghijk"} }; + + private static final String EXPECTED_VALUE = "rededited"; + + private JFrame frame; + private JTable table; + + private volatile Point tableLoc; + private volatile Rectangle cellRect; + + private volatile Object editedValue; + private volatile boolean testResult; + + private final Robot robot; + + public static void main(String[] args) throws Exception { + final bug4275046 test = new bug4275046(); + test.test(); + } + + public bug4275046() throws AWTException { + robot = new Robot(); + robot.setAutoDelay(100); + } + + private void createGUI() { + frame = new JFrame("bug4275046"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JComboBox cb = new JComboBox<>( + new Object[] {"blue", "yellow", "green", "red"}); + cb.setEditable(true); + DefaultCellEditor comboEditor = new DefaultCellEditor(cb); + comboEditor.setClickCountToStart(1); + + DefaultTableModel model = new DefaultTableModel(data, colNames); + table = new JTable(model); + table.getColumnModel().getColumn(1).setCellEditor(comboEditor); + + frame.add(table); + frame.pack(); + frame.setSize(550, 400); + frame.setVisible(true); + } + + private void test() throws Exception { + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createGUI(); + } + }); + + runTest(); + checkResult(); + } finally { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.dispose(); + } + } + }); + } + } + + private void runTest() throws Exception { + robot.waitForIdle(); + + // Click the first cell in the "color" column + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + tableLoc = table.getLocationOnScreen(); + cellRect = table.getCellRect(0, 1, true); + } + }); + + robot.mouseMove(tableLoc.x + cellRect.x + cellRect.width / 2, + tableLoc.y + cellRect.y + cellRect.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + // Edit the cell + robot.keyPress(KeyEvent.VK_E); + robot.keyRelease(KeyEvent.VK_E); + + robot.keyPress(KeyEvent.VK_D); + robot.keyRelease(KeyEvent.VK_D); + + robot.keyPress(KeyEvent.VK_I); + robot.keyRelease(KeyEvent.VK_I); + + robot.keyPress(KeyEvent.VK_T); + robot.keyRelease(KeyEvent.VK_T); + + robot.keyPress(KeyEvent.VK_E); + robot.keyRelease(KeyEvent.VK_E); + + robot.keyPress(KeyEvent.VK_D); + robot.keyRelease(KeyEvent.VK_D); + robot.delay(100); + + // Click another cell + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + cellRect = table.getCellRect(1, 2, true); + } + }); + + robot.mouseMove(tableLoc.x + cellRect.x + cellRect.width / 2, + tableLoc.y + cellRect.y + cellRect.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(100); + } + + private void checkResult() throws Exception { + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + // Read the edited value of from the cell + editedValue = table.getModel().getValueAt(0, 1); + System.out.println("The edited value is = " + editedValue); + testResult = editedValue.equals(EXPECTED_VALUE); + if (testResult) { + System.out.println("Test passed"); + } else { + System.out.println("Test failed"); + } + } + }); + if (!testResult) { + throw new RuntimeException("Expected value in the cell: '" + + EXPECTED_VALUE + "' but found '" + editedValue + "'."); + } + } +} diff --git a/test/jdk/javax/swing/JTree/6263446/bug6263446.java b/test/jdk/javax/swing/JTree/6263446/bug6263446.java index 7094971e383..86b6ee3b59c 100644 --- a/test/jdk/javax/swing/JTree/6263446/bug6263446.java +++ b/test/jdk/javax/swing/JTree/6263446/bug6263446.java @@ -43,83 +43,92 @@ public class bug6263446 { private static final String ALL = FIRST + " " + SECOND; private static JTree tree; private static Robot robot; + private static JFrame frame; public static void main(String[] args) throws Exception { robot = new Robot(); - robot.setAutoDelay(50); + robot.setAutoDelay(100); SwingUtilities.invokeAndWait(new Runnable() { - + @Override public void run() { createAndShowGUI(); } }); robot.waitForIdle(); + robot.delay(1000); - Point point = getClickPoint(); - robot.mouseMove(point.x, point.y); + try { + Point point = getClickPoint(); + robot.mouseMove(point.x, point.y); - // click count 3 - click(1); - assertNotEditing(); + // click count 3 + click(1); + assertNotEditing(); - click(2); - assertNotEditing(); + click(2); + assertNotEditing(); - click(3); - assertEditing(); - cancelCellEditing(); - assertNotEditing(); + click(3); + assertEditing(); + cancelCellEditing(); + assertNotEditing(); - click(4); - checkSelectedText(FIRST); + click(4); + checkSelectedText(FIRST); - click(5); - checkSelectedText(ALL); + click(5); + checkSelectedText(ALL); - // click count 4 - setClickCountToStart(4); + // click count 4 + setClickCountToStart(4); - click(1); - assertNotEditing(); + click(1); + assertNotEditing(); - click(2); - assertNotEditing(); + click(2); + assertNotEditing(); - click(3); - assertNotEditing(); + click(3); + assertNotEditing(); - click(4); - assertEditing(); - cancelCellEditing(); - assertNotEditing(); + click(4); + assertEditing(); + cancelCellEditing(); + assertNotEditing(); - click(5); - checkSelectedText(FIRST); + click(5); + checkSelectedText(FIRST); - click(6); - checkSelectedText(ALL); + click(6); + checkSelectedText(ALL); - // start path editing - startPathEditing(); - assertEditing(); + // start path editing + startPathEditing(); + assertEditing(); - click(1); - checkSelection(null); + click(1); + checkSelection(null); - click(2); - checkSelection(FIRST); + click(2); + checkSelection(FIRST); - click(3); - checkSelection(ALL); + click(3); + checkSelection(ALL); + } finally { + if (frame != null) { + SwingUtilities.invokeAndWait(() -> frame.dispose()); + } + } } private static void click(int times) { robot.delay(500); for (int i = 0; i < times; i++) { - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); } } @@ -148,7 +157,7 @@ private static TreeModel createTreeModel() { private static void createAndShowGUI() { - JFrame frame = new JFrame(); + frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tree = new JTree(createTreeModel()); @@ -158,6 +167,7 @@ private static void createAndShowGUI() { frame.getContentPane().add(tree); frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); } diff --git a/test/jdk/javax/swing/plaf/basic/Test6984643.java b/test/jdk/javax/swing/plaf/basic/Test6984643.java index 57df156026a..1ab879c212e 100644 --- a/test/jdk/javax/swing/plaf/basic/Test6984643.java +++ b/test/jdk/javax/swing/plaf/basic/Test6984643.java @@ -55,7 +55,7 @@ public boolean isSupportedLookAndFeel() { } }); - SwingUtilities.invokeLater(new Runnable() { + SwingUtilities.invokeAndWait(new Runnable() { public void run() { new JFileChooser(); } diff --git a/test/jdk/javax/swing/text/JTextComponent/5074573/bug5074573.java b/test/jdk/javax/swing/text/JTextComponent/5074573/bug5074573.java index bdadb11170e..2c83bf2f3a9 100644 --- a/test/jdk/javax/swing/text/JTextComponent/5074573/bug5074573.java +++ b/test/jdk/javax/swing/text/JTextComponent/5074573/bug5074573.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,27 @@ /* * @test * @key headful - * @bug 5074573 + * @bug 5074573 8196100 * @summary tests delte-next-word and delete-prev-word actions for all text compnents and all look&feels - * @author Igor Kushnirskiy * @run main bug5074573 */ -import java.util.*; import java.awt.Robot; -import java.awt.Toolkit; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; +import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JEditorPane; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPasswordField; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.text.Caret; +import javax.swing.text.JTextComponent; public class bug5074573 { @@ -148,6 +157,7 @@ private static void initialize(Class textComponentClas textComponent.setText(testString); frame.add(textComponent); frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); textComponent.requestFocus(); Caret caret = textComponent.getCaret(); diff --git a/test/jdk/javax/swing/text/html/StyleSheet/TestWrongCSSFontSize.java b/test/jdk/javax/swing/text/html/StyleSheet/TestWrongCSSFontSize.java new file mode 100644 index 00000000000..b1fadc2d621 --- /dev/null +++ b/test/jdk/javax/swing/text/html/StyleSheet/TestWrongCSSFontSize.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import javax.imageio.ImageIO; +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.text.GlyphView; +import javax.swing.text.View; + +/* + * @test + * @bug 8257664 + * @summary Tests inherited font-size with parent percentage specification. + * @run main TestWrongCSSFontSize + */ +public class TestWrongCSSFontSize { + + private static String text = + "" + + + "

      Foo

      " + + "
      Bar
      " + + "
      1. Baz
      " + + "
      Qux
      " + + "
      Qux
      " + + "
      Qux
      " + + "
      Qux
      " + + "
      Quux
      " + + + ""; + + private static int expectedFontSize = 21; + private static int expectedAssertions = 8; + + private JEditorPane editor; + + public void setUp() { + editor = new JEditorPane(); + editor.setContentType("text/html"); + editor.setText(text); + editor.setSize(editor.getPreferredSize()); // layout + } + + public void run() { + int count = forEachTextRun(editor.getUI() + .getRootView(editor), this::assertFontSize); + if (count != expectedAssertions) { + throw new AssertionError("assertion count expected [" + + expectedAssertions + "] but found [" + count + "]"); + } + } + + private int forEachTextRun(View view, Consumer action) { + int tested = 0; + for (int i = 0; i < view.getViewCount(); i++) { + View child = view.getView(i); + if (child instanceof GlyphView) { + if (child.getElement() + .getAttributes().getAttribute("CR") == Boolean.TRUE) { + continue; + } + action.accept((GlyphView) child); + tested += 1; + } else { + tested += forEachTextRun(child, action); + } + } + return tested; + } + + private void assertFontSize(GlyphView child) { + printSource(child); + int actualFontSize = child.getFont().getSize(); + if (actualFontSize != expectedFontSize) { + throw new AssertionError("font size expected [" + + expectedFontSize + "] but found [" + actualFontSize +"]"); + } + } + + private void printSource(View textRun) { + try { + editor.getEditorKit().write(System.out, + editor.getDocument(), textRun.getStartOffset(), + textRun.getEndOffset() - textRun.getStartOffset()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void captureImage(Component comp, String path) { + try { + BufferedImage capture = new BufferedImage(comp.getWidth(), + comp.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics g = capture.getGraphics(); + comp.paint(g); + g.dispose(); + + ImageIO.write(capture, "png", new File(path)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Throwable { + TestWrongCSSFontSize test = new TestWrongCSSFontSize(); + AtomicReference failure = new AtomicReference<>(); + SwingUtilities.invokeAndWait(() -> { + try { + test.setUp(); + test.run(); + } catch (Throwable e) { + failure.set(e); + } finally { + if (args.length == 1) { + captureImage(test.editor, args[0]); + } + } + }); + if (failure.get() != null) { + throw failure.get(); + } + } + +} diff --git a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java index 8ccb522b5f6..9d53a376d63 100644 --- a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java +++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -603,21 +603,21 @@ static void test_create_signature_enveloped_dsa(int size) throws Exception { static void test_create_signature_enveloping_b64_dsa() throws Exception { System.out.println("* Generating signature-enveloping-b64-dsa.xml"); test_create_signature_enveloping - (sha1, dsaSha1, dsa1024, signingKey, kvks, true); + (sha1, dsaSha1, dsa1024, signingKey, kvks, true, true); System.out.println(); } static void test_create_signature_enveloping_dsa() throws Exception { System.out.println("* Generating signature-enveloping-dsa.xml"); test_create_signature_enveloping - (sha1, dsaSha1, dsa1024, signingKey, kvks, false); + (sha1, dsaSha1, dsa1024, signingKey, kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_sha256_dsa() throws Exception { System.out.println("* Generating signature-enveloping-sha256-dsa.xml"); test_create_signature_enveloping - (sha256, dsaSha1, dsa1024, signingKey, kvks, false); + (sha256, dsaSha1, dsa1024, signingKey, kvks, false, true); System.out.println(); } @@ -626,7 +626,7 @@ static void test_create_signature_enveloping_hmac_sha1_40() System.out.println("* Generating signature-enveloping-hmac-sha1-40.xml"); try { test_create_signature_enveloping(sha1, hmacSha1, null, - getSecretKey("secret".getBytes("ASCII")), sks, false); + getSecretKey("secret".getBytes("ASCII")), sks, false, true); } catch (Exception e) { if (!(e instanceof XMLSignatureException)) { throw e; @@ -639,7 +639,7 @@ static void test_create_signature_enveloping_hmac_sha256() throws Exception { System.out.println("* Generating signature-enveloping-hmac-sha256.xml"); test_create_signature_enveloping(sha1, hmacSha256, null, - getSecretKey("secret".getBytes("ASCII")), sks, false); + getSecretKey("secret".getBytes("ASCII")), sks, false, true); System.out.println(); } @@ -647,7 +647,7 @@ static void test_create_signature_enveloping_hmac_sha224() throws Exception { System.out.println("* Generating signature-enveloping-hmac-sha224.xml"); test_create_signature_enveloping(sha1, hmacSha224, null, - getSecretKey("secret".getBytes("ASCII")), sks, false); + getSecretKey("secret".getBytes("ASCII")), sks, false, true); System.out.println(); } @@ -655,7 +655,7 @@ static void test_create_signature_enveloping_hmac_sha384() throws Exception { System.out.println("* Generating signature-enveloping-hmac-sha384.xml"); test_create_signature_enveloping(sha1, hmacSha384, null, - getSecretKey("secret".getBytes("ASCII")), sks, false); + getSecretKey("secret".getBytes("ASCII")), sks, false, true); System.out.println(); } @@ -663,14 +663,14 @@ static void test_create_signature_enveloping_hmac_sha512() throws Exception { System.out.println("* Generating signature-enveloping-hmac-sha512.xml"); test_create_signature_enveloping(sha1, hmacSha512, null, - getSecretKey("secret".getBytes("ASCII")), sks, false); + getSecretKey("secret".getBytes("ASCII")), sks, false, true); System.out.println(); } static void test_create_signature_enveloping_rsa() throws Exception { System.out.println("* Generating signature-enveloping-rsa.xml"); test_create_signature_enveloping(sha1, rsaSha1, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -678,7 +678,7 @@ static void test_create_signature_enveloping_sha384_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha384-rsa_sha256.xml"); test_create_signature_enveloping(sha384, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -686,7 +686,7 @@ static void test_create_signature_enveloping_sha224_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha224-rsa_sha256.xml"); test_create_signature_enveloping(sha224, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -694,7 +694,7 @@ static void test_create_signature_enveloping_sha3_224_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha3_224-rsa_sha256.xml"); test_create_signature_enveloping(sha3_224, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -702,7 +702,7 @@ static void test_create_signature_enveloping_sha3_256_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha3_256-rsa_sha256.xml"); test_create_signature_enveloping(sha3_256, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -710,7 +710,7 @@ static void test_create_signature_enveloping_sha3_384_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha3_384-rsa_sha256.xml"); test_create_signature_enveloping(sha3_384, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -718,7 +718,7 @@ static void test_create_signature_enveloping_sha3_512_rsa_sha256() throws Exception { System.out.println("* Generating signature-enveloping-sha3_512-rsa_sha256.xml"); test_create_signature_enveloping(sha3_512, rsaSha256, rsa, - getPrivateKey("RSA", 512), kvks, false); + getPrivateKey("RSA", 512), kvks, false, false); System.out.println(); } @@ -726,7 +726,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha384() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha384.xml"); test_create_signature_enveloping(sha512, rsaSha384, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -734,7 +734,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha224() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha224.xml"); test_create_signature_enveloping(sha512, rsaSha224, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -742,7 +742,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha512() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha512.xml"); test_create_signature_enveloping(sha512, rsaSha512, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -750,7 +750,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha1_mgf1() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha1_mgf1.xml"); test_create_signature_enveloping(sha512, rsaSha1mgf1, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -758,7 +758,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha224_mgf1() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha224_mgf1.xml"); test_create_signature_enveloping(sha512, rsaSha224mgf1, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -766,7 +766,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha256_mgf1() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha256_mgf1.xml"); test_create_signature_enveloping(sha512, rsaSha256mgf1, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -774,7 +774,7 @@ static void test_create_signature_enveloping_sha512_rsa_sha384_mgf1() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha384_mgf1.xml"); test_create_signature_enveloping(sha512, rsaSha384mgf1, rsa1024, - getPrivateKey("RSA", 1024), kvks, false); + getPrivateKey("RSA", 1024), kvks, false, true); System.out.println(); } @@ -782,56 +782,56 @@ static void test_create_signature_enveloping_sha512_rsa_sha512_mgf1() throws Exception { System.out.println("* Generating signature-enveloping-sha512-rsa_sha512_mgf1.xml"); test_create_signature_enveloping(sha512, rsaSha512mgf1, rsa2048, - getPrivateKey("RSA", 2048), kvks, false); + getPrivateKey("RSA", 2048), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p256_sha1() throws Exception { System.out.println("* Generating signature-enveloping-p256-sha1.xml"); test_create_signature_enveloping(sha1, ecdsaSha1, p256ki, - getECPrivateKey("P256"), kvks, false); + getECPrivateKey("P256"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p256_sha224() throws Exception { System.out.println("* Generating signature-enveloping-p256-sha224.xml"); test_create_signature_enveloping(sha1, ecdsaSha224, p256ki, - getECPrivateKey("P256"), kvks, false); + getECPrivateKey("P256"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p256_sha256() throws Exception { System.out.println("* Generating signature-enveloping-p256-sha256.xml"); test_create_signature_enveloping(sha1, ecdsaSha256, p256ki, - getECPrivateKey("P256"), kvks, false); + getECPrivateKey("P256"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p256_sha384() throws Exception { System.out.println("* Generating signature-enveloping-p256-sha384.xml"); test_create_signature_enveloping(sha1, ecdsaSha384, p256ki, - getECPrivateKey("P256"), kvks, false); + getECPrivateKey("P256"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p256_sha512() throws Exception { System.out.println("* Generating signature-enveloping-p256-sha512.xml"); test_create_signature_enveloping(sha1, ecdsaSha512, p256ki, - getECPrivateKey("P256"), kvks, false); + getECPrivateKey("P256"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p384_sha1() throws Exception { System.out.println("* Generating signature-enveloping-p384-sha1.xml"); test_create_signature_enveloping(sha1, ecdsaSha1, p384ki, - getECPrivateKey("P384"), kvks, false); + getECPrivateKey("P384"), kvks, false, true); System.out.println(); } static void test_create_signature_enveloping_p521_sha1() throws Exception { System.out.println("* Generating signature-enveloping-p521-sha1.xml"); test_create_signature_enveloping(sha1, ecdsaSha1, p521ki, - getECPrivateKey("P521"), kvks, false); + getECPrivateKey("P521"), kvks, false, true); System.out.println(); } @@ -963,6 +963,7 @@ static void test_create_signature_reference_dependency() throws Exception { DOMValidateContext dvc = new DOMValidateContext (kvks, doc.getDocumentElement()); + dvc.setProperty("org.jcp.xml.dsig.secureValidation", false); XMLSignature sig2 = fac.unmarshalXMLSignature(dvc); if (sig.equals(sig2) == false) { @@ -1010,6 +1011,7 @@ static void test_create_signature_with_attr_in_no_namespace() DOMValidateContext dvc = new DOMValidateContext (kvks, doc.getDocumentElement()); + dvc.setProperty("org.jcp.xml.dsig.secureValidation", false); dvc.setIdAttributeNS(nc, null, "Id"); XMLSignature sig2 = fac.unmarshalXMLSignature(dvc); @@ -1451,7 +1453,7 @@ private static void dumpDocument(Document doc, Writer w) throws Exception { private static void test_create_signature_enveloping (DigestMethod dm, SignatureMethod sm, KeyInfo ki, Key signingKey, - KeySelector ks, boolean b64) throws Exception { + KeySelector ks, boolean b64, boolean secVal) throws Exception { // create reference Reference ref; @@ -1486,6 +1488,7 @@ private static void dumpDocument(Document doc, Writer w) throws Exception { DOMValidateContext dvc = new DOMValidateContext (ks, doc.getDocumentElement()); + dvc.setProperty("org.jcp.xml.dsig.secureValidation", secVal); XMLSignature sig2 = fac.unmarshalXMLSignature(dvc); if (sig.equals(sig2) == false) { diff --git a/test/jdk/jdk/incubator/vector/AbstractVectorTest.java b/test/jdk/jdk/incubator/vector/AbstractVectorTest.java index c09ff337586..cf1c8eff20a 100644 --- a/test/jdk/jdk/incubator/vector/AbstractVectorTest.java +++ b/test/jdk/jdk/incubator/vector/AbstractVectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -251,7 +251,7 @@ interface FBooleanBinOp { boolean apply(boolean a, boolean b); } - static void assertArraysEquals(boolean[] a, boolean[] b, boolean[] r, FBooleanBinOp f) { + static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] b, FBooleanBinOp f) { int i = 0; try { for (; i < a.length; i++) { diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java index 5f1c41ffd47..39a053e657d 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Byte128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Byte128VectorLoadStoreTests * */ @@ -57,36 +57,14 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -390,7 +368,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "byteProviderForIOOBE") @@ -461,7 +439,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteMaskProviderForIOOBE") @@ -545,7 +523,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -569,7 +547,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -656,7 +634,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -671,7 +649,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -787,7 +765,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -868,7 +846,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -956,7 +934,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -967,7 +945,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index 538edbbcce8..a7d006daec3 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Byte128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { byte apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { byte[] apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { byte apply(byte[] a); } - static void assertReductionArraysEquals(byte[] a, byte[] b, byte c, + static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { byte apply(byte[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(byte[] a, byte[] b, byte c, boolean[] mask, + static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(byte[] a); } - static void assertReductionLongArraysEquals(byte[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(byte[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(byte[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(byte[] a, byte[] b, byte element, int index) { + static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int v } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boole } } - static void assertBroadcastArraysEquals(byte[]a, byte[]r) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolea } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { byte apply(byte[] a, int b); } - static void assertArraysEquals(byte[] a, byte[] r, FBinArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, FGatherScatterOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FSca } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { byte[] apply(byte[] a, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { byte[] apply(byte[] a, byte[] b, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBo } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { byte[] apply(byte[] a, byte[] b, int origin, int part, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } - static void assertArraysEquals(byte[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -802,7 +802,7 @@ static void assertArraysEquals(byte[] a, int[] r, int offs) { } - static void assertArraysEquals(byte[] a, byte[] r, int offs) { + static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -813,7 +813,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int offs) { } } - static void assertArraysEquals(byte[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -824,7 +824,7 @@ static void assertArraysEquals(byte[] a, long[] r, int offs) { } } - static void assertArraysEquals(byte[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1288,7 +1288,7 @@ static void ADDByte128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::ADD); + assertArraysEquals(r, a, b, Byte128VectorTests::ADD); } static byte add(byte a, byte b) { return (byte)(a + b); @@ -1306,7 +1306,7 @@ static void addByte128VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::add); + assertArraysEquals(r, a, b, Byte128VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1326,7 +1326,7 @@ static void ADDByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::SUB); + assertArraysEquals(r, a, b, Byte128VectorTests::SUB); } static byte sub(byte a, byte b) { return (byte)(a - b); @@ -1382,7 +1382,7 @@ static void subByte128VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::sub); + assertArraysEquals(r, a, b, Byte128VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1402,7 +1402,7 @@ static void SUBByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::MUL); + assertArraysEquals(r, a, b, Byte128VectorTests::MUL); } static byte mul(byte a, byte b) { return (byte)(a * b); @@ -1458,7 +1458,7 @@ static void mulByte128VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::mul); + assertArraysEquals(r, a, b, Byte128VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1478,7 +1478,7 @@ static void MULByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::DIV); + assertArraysEquals(r, a, b, Byte128VectorTests::DIV); } static byte div(byte a, byte b) { return (byte)(a / b); @@ -1543,7 +1543,7 @@ static void divByte128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::div); + assertArraysEquals(r, a, b, Byte128VectorTests::div); } @@ -1567,7 +1567,7 @@ static void DIVByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Byte128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Byte128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1630,7 +1630,7 @@ static void FIRST_NONZEROByte128VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Byte128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Byte128VectorTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -1651,7 +1651,7 @@ static void ANDByte128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::AND); + assertArraysEquals(r, a, b, Byte128VectorTests::AND); } static byte and(byte a, byte b) { return (byte)(a & b); @@ -1669,7 +1669,7 @@ static void andByte128VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::and); + assertArraysEquals(r, a, b, Byte128VectorTests::and); } @@ -1691,7 +1691,7 @@ static void ANDByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Byte128VectorTests::AND_NOT); } @@ -1757,7 +1757,7 @@ static void ORByte128VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte128VectorTests::OR); + assertArraysEquals(r, a, b, Byte128VectorTests::OR); } static byte or(byte a, byte b) { return (byte)(a | b); @@ -1775,7 +1775,7 @@ static void orByte128VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::or); + assertArraysEquals(r, a, b, Byte128VectorTests::or); } @@ -1797,7 +1797,7 @@ static void ORByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::XOR); + assertArraysEquals(r, a, b, Byte128VectorTests::XOR); } @@ -1841,7 +1841,7 @@ static void XORByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1873,7 +1873,7 @@ static void addByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::add); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1887,7 +1887,7 @@ static void subByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1904,7 +1904,7 @@ static void subByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1918,7 +1918,7 @@ static void mulByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1935,7 +1935,7 @@ static void mulByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::mul); } @@ -1954,7 +1954,7 @@ static void divByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::div); } @@ -1975,7 +1975,7 @@ static void divByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::div); } @@ -1991,7 +1991,7 @@ static void ORByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2005,7 +2005,7 @@ static void orByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::or); } @@ -2024,7 +2024,7 @@ static void ORByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::OR); } @@ -2040,7 +2040,7 @@ static void ANDByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2054,7 +2054,7 @@ static void andByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::and); } @@ -2073,7 +2073,7 @@ static void ANDByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::AND); } @@ -2089,7 +2089,7 @@ static void ORByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Byte128VectorTests::OR); } @@ -2108,7 +2108,7 @@ static void ORByte128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte128VectorTests::OR); } @@ -2123,7 +2123,7 @@ static void ADDByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Byte128VectorTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -2140,7 +2140,7 @@ static void ADDByte128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte128VectorTests::LSHL); + assertArraysEquals(r, a, b, Byte128VectorTests::LSHL); } @@ -2185,7 +2185,7 @@ static void LSHLByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte128VectorTests::ASHR); + assertArraysEquals(r, a, b, Byte128VectorTests::ASHR); } @@ -2233,7 +2233,7 @@ static void ASHRByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte128VectorTests::LSHR); + assertArraysEquals(r, a, b, Byte128VectorTests::LSHR); } @@ -2281,7 +2281,7 @@ static void LSHRByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::MIN); + assertArraysEquals(r, a, b, Byte128VectorTests::MIN); } static byte min(byte a, byte b) { return (byte)(Math.min(a, b)); @@ -2460,7 +2460,7 @@ static void minByte128VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::min); + assertArraysEquals(r, a, b, Byte128VectorTests::min); } static byte MAX(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2480,7 +2480,7 @@ static void MAXByte128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte128VectorTests::MAX); + assertArraysEquals(r, a, b, Byte128VectorTests::MAX); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2498,7 +2498,7 @@ static void maxByte128VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::max); + assertArraysEquals(r, a, b, Byte128VectorTests::max); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2512,7 +2512,7 @@ static void MINByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2526,7 +2526,7 @@ static void minByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::min); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2540,7 +2540,7 @@ static void MAXByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2554,7 +2554,7 @@ static void maxByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::max); } static byte ANDReduce(byte[] a, int idx) { @@ -2597,7 +2597,7 @@ static void ANDReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::ANDReduce, Byte128VectorTests::ANDReduceAll); } @@ -2645,7 +2645,7 @@ static void ANDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::ANDReduceMasked, Byte128VectorTests::ANDReduceAllMasked); } @@ -2690,7 +2690,7 @@ static void ORReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::ORReduce, Byte128VectorTests::ORReduceAll); } @@ -2738,7 +2738,7 @@ static void ORReduceByte128VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::ORReduceMasked, Byte128VectorTests::ORReduceAllMasked); } @@ -2783,7 +2783,7 @@ static void XORReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::XORReduce, Byte128VectorTests::XORReduceAll); } @@ -2831,7 +2831,7 @@ static void XORReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::XORReduceMasked, Byte128VectorTests::XORReduceAllMasked); } @@ -2873,7 +2873,7 @@ static void ADDReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::ADDReduce, Byte128VectorTests::ADDReduceAll); } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -2917,7 +2917,7 @@ static void ADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::ADDReduceMasked, Byte128VectorTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { @@ -2958,7 +2958,7 @@ static void MULReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::MULReduce, Byte128VectorTests::MULReduceAll); } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3002,7 +3002,7 @@ static void MULReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::MULReduceMasked, Byte128VectorTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { @@ -3043,7 +3043,7 @@ static void MINReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::MINReduce, Byte128VectorTests::MINReduceAll); } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3088,7 +3088,7 @@ static void MINReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::MINReduceMasked, Byte128VectorTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { @@ -3129,7 +3129,7 @@ static void MAXReduceByte128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte128VectorTests::MAXReduce, Byte128VectorTests::MAXReduceAll); } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3174,7 +3174,7 @@ static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::MAXReduceMasked, Byte128VectorTests::MAXReduceAllMasked); } @@ -3200,7 +3200,7 @@ static void anyTrueByte128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::anyTrue); } @@ -3226,7 +3226,7 @@ static void allTrueByte128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::allTrue); } @@ -3242,7 +3242,7 @@ static void withByte128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (byte)4, 0); + assertInsertArraysEquals(r, a, (byte)4, 0); } static boolean testIS_DEFAULT(byte a) { return bits(a)==0; @@ -3791,7 +3791,7 @@ static void blendByte128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Byte128VectorTests::blend); + assertArraysEquals(r, a, b, mask, Byte128VectorTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") @@ -3808,7 +3808,7 @@ static void RearrangeByte128VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") @@ -3826,7 +3826,7 @@ static void RearrangeByte128VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpProvider") static void getByte128VectorTests(IntFunction fa) { @@ -3981,7 +3981,7 @@ static void getByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::get); + assertArraysEquals(r, a, Byte128VectorTests::get); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3995,7 +3995,7 @@ static void BroadcastByte128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4042,7 +4042,7 @@ static void sliceUnaryByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Byte128VectorTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4071,7 +4071,7 @@ static void sliceBinaryByte128VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Byte128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Byte128VectorTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4104,7 +4104,7 @@ static void sliceByte128VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Byte128VectorTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4170,7 +4170,7 @@ static void unsliceBinaryByte128VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Byte128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Byte128VectorTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4226,7 +4226,7 @@ static void unsliceByte128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Byte128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Byte128VectorTests::unslice); } @@ -4275,7 +4275,7 @@ static void BITWISE_BLENDByte128VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Byte128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Byte128VectorTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") static void bitwiseBlendByte128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4291,7 +4291,7 @@ static void bitwiseBlendByte128VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Byte128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Byte128VectorTests::BITWISE_BLEND); } @@ -4332,7 +4332,7 @@ static void BITWISE_BLENDByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4361,7 +4361,7 @@ static void bitwiseBlendByte128VectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Byte128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4376,7 +4376,7 @@ static void bitwiseBlendByte128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4447,7 +4447,7 @@ static void bitwiseBlendByte128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::NEG); + assertArraysEquals(r, a, Byte128VectorTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4505,7 +4505,7 @@ static void negByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::neg); + assertArraysEquals(r, a, Byte128VectorTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4523,7 +4523,7 @@ static void NEGMaskedByte128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte128VectorTests::NEG); + assertArraysEquals(r, a, mask, Byte128VectorTests::NEG); } static byte ABS(byte a) { @@ -4546,7 +4546,7 @@ static void ABSByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::ABS); + assertArraysEquals(r, a, Byte128VectorTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4561,7 +4561,7 @@ static void absByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::abs); + assertArraysEquals(r, a, Byte128VectorTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4579,7 +4579,7 @@ static void ABSMaskedByte128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte128VectorTests::ABS); + assertArraysEquals(r, a, mask, Byte128VectorTests::ABS); } @@ -4605,7 +4605,7 @@ static void NOTByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::NOT); + assertArraysEquals(r, a, Byte128VectorTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4620,7 +4620,7 @@ static void notByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::not); + assertArraysEquals(r, a, Byte128VectorTests::not); } @@ -4640,7 +4640,7 @@ static void NOTMaskedByte128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte128VectorTests::NOT); + assertArraysEquals(r, a, mask, Byte128VectorTests::NOT); } @@ -4663,7 +4663,7 @@ static void ZOMOByte128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte128VectorTests::ZOMO); + assertArraysEquals(r, a, Byte128VectorTests::ZOMO); } @@ -4683,7 +4683,7 @@ static void ZOMOMaskedByte128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Byte128VectorTests::ZOMO); } @@ -4711,7 +4711,7 @@ static void gatherByte128VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte128VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Byte128VectorTests::scatterMasked); } @@ -4844,8 +4844,8 @@ static void toIntArrayByte128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4855,8 +4855,8 @@ static void toLongArrayByte128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4866,8 +4866,8 @@ static void toDoubleArrayByte128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4907,7 +4907,7 @@ static void reinterpretAsBytesByte128VectorTestsSmokeTest(IntFunction fa ByteVector av = ByteVector.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } static long ADDReduceLong(byte[] a, int idx) { @@ -4944,7 +4944,7 @@ static void ADDReduceLongByte128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Byte128VectorTests::ADDReduceLong, Byte128VectorTests::ADDReduceAllLong); } @@ -4985,7 +4985,7 @@ static void ADDReduceLongByte128VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Byte128VectorTests::ADDReduceLongMasked, Byte128VectorTests::ADDReduceAllLongMasked); } @@ -4997,7 +4997,7 @@ static void BroadcastLongByte128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -5015,7 +5015,7 @@ static void blendByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte128VectorTests::blend); } @@ -5032,7 +5032,7 @@ static void SelectFromByte128VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") @@ -5051,7 +5051,7 @@ static void SelectFromByte128VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5128,7 +5128,7 @@ static void maskEqByte128VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Byte128VectorTests::beq); + assertArraysEquals(r, a, b, Byte128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java index 9eef074186e..c7acbc97f0b 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Byte256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Byte256VectorLoadStoreTests * */ @@ -57,36 +57,14 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -390,7 +368,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "byteProviderForIOOBE") @@ -461,7 +439,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteMaskProviderForIOOBE") @@ -545,7 +523,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -569,7 +547,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -656,7 +634,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -671,7 +649,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -787,7 +765,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -868,7 +846,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -956,7 +934,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -967,7 +945,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index a030f773479..7b68b9a4fef 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Byte256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { byte apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { byte[] apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { byte apply(byte[] a); } - static void assertReductionArraysEquals(byte[] a, byte[] b, byte c, + static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { byte apply(byte[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(byte[] a, byte[] b, byte c, boolean[] mask, + static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(byte[] a); } - static void assertReductionLongArraysEquals(byte[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(byte[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(byte[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(byte[] a, byte[] b, byte element, int index) { + static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int v } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boole } } - static void assertBroadcastArraysEquals(byte[]a, byte[]r) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolea } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { byte apply(byte[] a, int b); } - static void assertArraysEquals(byte[] a, byte[] r, FBinArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, FGatherScatterOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FSca } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { byte[] apply(byte[] a, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { byte[] apply(byte[] a, byte[] b, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBo } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { byte[] apply(byte[] a, byte[] b, int origin, int part, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } - static void assertArraysEquals(byte[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -802,7 +802,7 @@ static void assertArraysEquals(byte[] a, int[] r, int offs) { } - static void assertArraysEquals(byte[] a, byte[] r, int offs) { + static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -813,7 +813,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int offs) { } } - static void assertArraysEquals(byte[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -824,7 +824,7 @@ static void assertArraysEquals(byte[] a, long[] r, int offs) { } } - static void assertArraysEquals(byte[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1288,7 +1288,7 @@ static void ADDByte256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::ADD); + assertArraysEquals(r, a, b, Byte256VectorTests::ADD); } static byte add(byte a, byte b) { return (byte)(a + b); @@ -1306,7 +1306,7 @@ static void addByte256VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::add); + assertArraysEquals(r, a, b, Byte256VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1326,7 +1326,7 @@ static void ADDByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::SUB); + assertArraysEquals(r, a, b, Byte256VectorTests::SUB); } static byte sub(byte a, byte b) { return (byte)(a - b); @@ -1382,7 +1382,7 @@ static void subByte256VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::sub); + assertArraysEquals(r, a, b, Byte256VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1402,7 +1402,7 @@ static void SUBByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::MUL); + assertArraysEquals(r, a, b, Byte256VectorTests::MUL); } static byte mul(byte a, byte b) { return (byte)(a * b); @@ -1458,7 +1458,7 @@ static void mulByte256VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::mul); + assertArraysEquals(r, a, b, Byte256VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1478,7 +1478,7 @@ static void MULByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::DIV); + assertArraysEquals(r, a, b, Byte256VectorTests::DIV); } static byte div(byte a, byte b) { return (byte)(a / b); @@ -1543,7 +1543,7 @@ static void divByte256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::div); + assertArraysEquals(r, a, b, Byte256VectorTests::div); } @@ -1567,7 +1567,7 @@ static void DIVByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Byte256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Byte256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1630,7 +1630,7 @@ static void FIRST_NONZEROByte256VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Byte256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Byte256VectorTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -1651,7 +1651,7 @@ static void ANDByte256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::AND); + assertArraysEquals(r, a, b, Byte256VectorTests::AND); } static byte and(byte a, byte b) { return (byte)(a & b); @@ -1669,7 +1669,7 @@ static void andByte256VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::and); + assertArraysEquals(r, a, b, Byte256VectorTests::and); } @@ -1691,7 +1691,7 @@ static void ANDByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Byte256VectorTests::AND_NOT); } @@ -1757,7 +1757,7 @@ static void ORByte256VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte256VectorTests::OR); + assertArraysEquals(r, a, b, Byte256VectorTests::OR); } static byte or(byte a, byte b) { return (byte)(a | b); @@ -1775,7 +1775,7 @@ static void orByte256VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::or); + assertArraysEquals(r, a, b, Byte256VectorTests::or); } @@ -1797,7 +1797,7 @@ static void ORByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::XOR); + assertArraysEquals(r, a, b, Byte256VectorTests::XOR); } @@ -1841,7 +1841,7 @@ static void XORByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1873,7 +1873,7 @@ static void addByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::add); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1887,7 +1887,7 @@ static void subByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1904,7 +1904,7 @@ static void subByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1918,7 +1918,7 @@ static void mulByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1935,7 +1935,7 @@ static void mulByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::mul); } @@ -1954,7 +1954,7 @@ static void divByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::div); } @@ -1975,7 +1975,7 @@ static void divByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::div); } @@ -1991,7 +1991,7 @@ static void ORByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2005,7 +2005,7 @@ static void orByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::or); } @@ -2024,7 +2024,7 @@ static void ORByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::OR); } @@ -2040,7 +2040,7 @@ static void ANDByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2054,7 +2054,7 @@ static void andByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::and); } @@ -2073,7 +2073,7 @@ static void ANDByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::AND); } @@ -2089,7 +2089,7 @@ static void ORByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Byte256VectorTests::OR); } @@ -2108,7 +2108,7 @@ static void ORByte256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::OR); } @@ -2123,7 +2123,7 @@ static void ADDByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Byte256VectorTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -2140,7 +2140,7 @@ static void ADDByte256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte256VectorTests::LSHL); + assertArraysEquals(r, a, b, Byte256VectorTests::LSHL); } @@ -2185,7 +2185,7 @@ static void LSHLByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte256VectorTests::ASHR); + assertArraysEquals(r, a, b, Byte256VectorTests::ASHR); } @@ -2233,7 +2233,7 @@ static void ASHRByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte256VectorTests::LSHR); + assertArraysEquals(r, a, b, Byte256VectorTests::LSHR); } @@ -2281,7 +2281,7 @@ static void LSHRByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::MIN); + assertArraysEquals(r, a, b, Byte256VectorTests::MIN); } static byte min(byte a, byte b) { return (byte)(Math.min(a, b)); @@ -2460,7 +2460,7 @@ static void minByte256VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::min); + assertArraysEquals(r, a, b, Byte256VectorTests::min); } static byte MAX(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2480,7 +2480,7 @@ static void MAXByte256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte256VectorTests::MAX); + assertArraysEquals(r, a, b, Byte256VectorTests::MAX); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2498,7 +2498,7 @@ static void maxByte256VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::max); + assertArraysEquals(r, a, b, Byte256VectorTests::max); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2512,7 +2512,7 @@ static void MINByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2526,7 +2526,7 @@ static void minByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::min); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2540,7 +2540,7 @@ static void MAXByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2554,7 +2554,7 @@ static void maxByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::max); } static byte ANDReduce(byte[] a, int idx) { @@ -2597,7 +2597,7 @@ static void ANDReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::ANDReduce, Byte256VectorTests::ANDReduceAll); } @@ -2645,7 +2645,7 @@ static void ANDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::ANDReduceMasked, Byte256VectorTests::ANDReduceAllMasked); } @@ -2690,7 +2690,7 @@ static void ORReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::ORReduce, Byte256VectorTests::ORReduceAll); } @@ -2738,7 +2738,7 @@ static void ORReduceByte256VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::ORReduceMasked, Byte256VectorTests::ORReduceAllMasked); } @@ -2783,7 +2783,7 @@ static void XORReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::XORReduce, Byte256VectorTests::XORReduceAll); } @@ -2831,7 +2831,7 @@ static void XORReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::XORReduceMasked, Byte256VectorTests::XORReduceAllMasked); } @@ -2873,7 +2873,7 @@ static void ADDReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::ADDReduce, Byte256VectorTests::ADDReduceAll); } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -2917,7 +2917,7 @@ static void ADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::ADDReduceMasked, Byte256VectorTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { @@ -2958,7 +2958,7 @@ static void MULReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::MULReduce, Byte256VectorTests::MULReduceAll); } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3002,7 +3002,7 @@ static void MULReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::MULReduceMasked, Byte256VectorTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { @@ -3043,7 +3043,7 @@ static void MINReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::MINReduce, Byte256VectorTests::MINReduceAll); } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3088,7 +3088,7 @@ static void MINReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::MINReduceMasked, Byte256VectorTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { @@ -3129,7 +3129,7 @@ static void MAXReduceByte256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte256VectorTests::MAXReduce, Byte256VectorTests::MAXReduceAll); } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3174,7 +3174,7 @@ static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::MAXReduceMasked, Byte256VectorTests::MAXReduceAllMasked); } @@ -3200,7 +3200,7 @@ static void anyTrueByte256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::anyTrue); } @@ -3226,7 +3226,7 @@ static void allTrueByte256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::allTrue); } @@ -3242,7 +3242,7 @@ static void withByte256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (byte)4, 0); + assertInsertArraysEquals(r, a, (byte)4, 0); } static boolean testIS_DEFAULT(byte a) { return bits(a)==0; @@ -3791,7 +3791,7 @@ static void blendByte256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Byte256VectorTests::blend); + assertArraysEquals(r, a, b, mask, Byte256VectorTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") @@ -3808,7 +3808,7 @@ static void RearrangeByte256VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") @@ -3826,7 +3826,7 @@ static void RearrangeByte256VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpProvider") static void getByte256VectorTests(IntFunction fa) { @@ -3981,7 +3981,7 @@ static void getByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::get); + assertArraysEquals(r, a, Byte256VectorTests::get); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3995,7 +3995,7 @@ static void BroadcastByte256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4042,7 +4042,7 @@ static void sliceUnaryByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Byte256VectorTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4071,7 +4071,7 @@ static void sliceBinaryByte256VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Byte256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Byte256VectorTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4104,7 +4104,7 @@ static void sliceByte256VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Byte256VectorTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4170,7 +4170,7 @@ static void unsliceBinaryByte256VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Byte256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Byte256VectorTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4226,7 +4226,7 @@ static void unsliceByte256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Byte256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Byte256VectorTests::unslice); } @@ -4275,7 +4275,7 @@ static void BITWISE_BLENDByte256VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Byte256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") static void bitwiseBlendByte256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4291,7 +4291,7 @@ static void bitwiseBlendByte256VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Byte256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND); } @@ -4332,7 +4332,7 @@ static void BITWISE_BLENDByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4361,7 +4361,7 @@ static void bitwiseBlendByte256VectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Byte256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4376,7 +4376,7 @@ static void bitwiseBlendByte256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4447,7 +4447,7 @@ static void bitwiseBlendByte256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::NEG); + assertArraysEquals(r, a, Byte256VectorTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4505,7 +4505,7 @@ static void negByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::neg); + assertArraysEquals(r, a, Byte256VectorTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4523,7 +4523,7 @@ static void NEGMaskedByte256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte256VectorTests::NEG); + assertArraysEquals(r, a, mask, Byte256VectorTests::NEG); } static byte ABS(byte a) { @@ -4546,7 +4546,7 @@ static void ABSByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::ABS); + assertArraysEquals(r, a, Byte256VectorTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4561,7 +4561,7 @@ static void absByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::abs); + assertArraysEquals(r, a, Byte256VectorTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4579,7 +4579,7 @@ static void ABSMaskedByte256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte256VectorTests::ABS); + assertArraysEquals(r, a, mask, Byte256VectorTests::ABS); } @@ -4605,7 +4605,7 @@ static void NOTByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::NOT); + assertArraysEquals(r, a, Byte256VectorTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4620,7 +4620,7 @@ static void notByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::not); + assertArraysEquals(r, a, Byte256VectorTests::not); } @@ -4640,7 +4640,7 @@ static void NOTMaskedByte256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte256VectorTests::NOT); + assertArraysEquals(r, a, mask, Byte256VectorTests::NOT); } @@ -4663,7 +4663,7 @@ static void ZOMOByte256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte256VectorTests::ZOMO); + assertArraysEquals(r, a, Byte256VectorTests::ZOMO); } @@ -4683,7 +4683,7 @@ static void ZOMOMaskedByte256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Byte256VectorTests::ZOMO); } @@ -4711,7 +4711,7 @@ static void gatherByte256VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte256VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Byte256VectorTests::scatterMasked); } @@ -4844,8 +4844,8 @@ static void toIntArrayByte256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4855,8 +4855,8 @@ static void toLongArrayByte256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4866,8 +4866,8 @@ static void toDoubleArrayByte256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4907,7 +4907,7 @@ static void reinterpretAsBytesByte256VectorTestsSmokeTest(IntFunction fa ByteVector av = ByteVector.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } static long ADDReduceLong(byte[] a, int idx) { @@ -4944,7 +4944,7 @@ static void ADDReduceLongByte256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Byte256VectorTests::ADDReduceLong, Byte256VectorTests::ADDReduceAllLong); } @@ -4985,7 +4985,7 @@ static void ADDReduceLongByte256VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Byte256VectorTests::ADDReduceLongMasked, Byte256VectorTests::ADDReduceAllLongMasked); } @@ -4997,7 +4997,7 @@ static void BroadcastLongByte256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -5015,7 +5015,7 @@ static void blendByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::blend); } @@ -5032,7 +5032,7 @@ static void SelectFromByte256VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") @@ -5051,7 +5051,7 @@ static void SelectFromByte256VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5128,7 +5128,7 @@ static void maskEqByte256VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Byte256VectorTests::beq); + assertArraysEquals(r, a, b, Byte256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java index 9cc119a8ef3..7068d8c7d83 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Byte512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Byte512VectorLoadStoreTests * */ @@ -57,36 +57,14 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -390,7 +368,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "byteProviderForIOOBE") @@ -461,7 +439,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteMaskProviderForIOOBE") @@ -545,7 +523,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -569,7 +547,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -656,7 +634,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -671,7 +649,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -787,7 +765,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -868,7 +846,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -956,7 +934,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -967,7 +945,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index 76530a72326..61e4aa5008d 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Byte512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { byte apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { byte[] apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { byte apply(byte[] a); } - static void assertReductionArraysEquals(byte[] a, byte[] b, byte c, + static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { byte apply(byte[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(byte[] a, byte[] b, byte c, boolean[] mask, + static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(byte[] a); } - static void assertReductionLongArraysEquals(byte[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(byte[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(byte[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(byte[] a, byte[] b, byte element, int index) { + static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int v } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boole } } - static void assertBroadcastArraysEquals(byte[]a, byte[]r) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolea } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { byte apply(byte[] a, int b); } - static void assertArraysEquals(byte[] a, byte[] r, FBinArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, FGatherScatterOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FSca } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { byte[] apply(byte[] a, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { byte[] apply(byte[] a, byte[] b, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBo } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { byte[] apply(byte[] a, byte[] b, int origin, int part, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } - static void assertArraysEquals(byte[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -802,7 +802,7 @@ static void assertArraysEquals(byte[] a, int[] r, int offs) { } - static void assertArraysEquals(byte[] a, byte[] r, int offs) { + static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -813,7 +813,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int offs) { } } - static void assertArraysEquals(byte[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -824,7 +824,7 @@ static void assertArraysEquals(byte[] a, long[] r, int offs) { } } - static void assertArraysEquals(byte[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1288,7 +1288,7 @@ static void ADDByte512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::ADD); + assertArraysEquals(r, a, b, Byte512VectorTests::ADD); } static byte add(byte a, byte b) { return (byte)(a + b); @@ -1306,7 +1306,7 @@ static void addByte512VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::add); + assertArraysEquals(r, a, b, Byte512VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1326,7 +1326,7 @@ static void ADDByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::SUB); + assertArraysEquals(r, a, b, Byte512VectorTests::SUB); } static byte sub(byte a, byte b) { return (byte)(a - b); @@ -1382,7 +1382,7 @@ static void subByte512VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::sub); + assertArraysEquals(r, a, b, Byte512VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1402,7 +1402,7 @@ static void SUBByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::MUL); + assertArraysEquals(r, a, b, Byte512VectorTests::MUL); } static byte mul(byte a, byte b) { return (byte)(a * b); @@ -1458,7 +1458,7 @@ static void mulByte512VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::mul); + assertArraysEquals(r, a, b, Byte512VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1478,7 +1478,7 @@ static void MULByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::DIV); + assertArraysEquals(r, a, b, Byte512VectorTests::DIV); } static byte div(byte a, byte b) { return (byte)(a / b); @@ -1543,7 +1543,7 @@ static void divByte512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::div); + assertArraysEquals(r, a, b, Byte512VectorTests::div); } @@ -1567,7 +1567,7 @@ static void DIVByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Byte512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Byte512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1630,7 +1630,7 @@ static void FIRST_NONZEROByte512VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Byte512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Byte512VectorTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -1651,7 +1651,7 @@ static void ANDByte512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::AND); + assertArraysEquals(r, a, b, Byte512VectorTests::AND); } static byte and(byte a, byte b) { return (byte)(a & b); @@ -1669,7 +1669,7 @@ static void andByte512VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::and); + assertArraysEquals(r, a, b, Byte512VectorTests::and); } @@ -1691,7 +1691,7 @@ static void ANDByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Byte512VectorTests::AND_NOT); } @@ -1757,7 +1757,7 @@ static void ORByte512VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte512VectorTests::OR); + assertArraysEquals(r, a, b, Byte512VectorTests::OR); } static byte or(byte a, byte b) { return (byte)(a | b); @@ -1775,7 +1775,7 @@ static void orByte512VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::or); + assertArraysEquals(r, a, b, Byte512VectorTests::or); } @@ -1797,7 +1797,7 @@ static void ORByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::XOR); + assertArraysEquals(r, a, b, Byte512VectorTests::XOR); } @@ -1841,7 +1841,7 @@ static void XORByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1873,7 +1873,7 @@ static void addByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::add); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1887,7 +1887,7 @@ static void subByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1904,7 +1904,7 @@ static void subByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1918,7 +1918,7 @@ static void mulByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1935,7 +1935,7 @@ static void mulByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::mul); } @@ -1954,7 +1954,7 @@ static void divByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::div); } @@ -1975,7 +1975,7 @@ static void divByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::div); } @@ -1991,7 +1991,7 @@ static void ORByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2005,7 +2005,7 @@ static void orByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::or); } @@ -2024,7 +2024,7 @@ static void ORByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::OR); } @@ -2040,7 +2040,7 @@ static void ANDByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2054,7 +2054,7 @@ static void andByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::and); } @@ -2073,7 +2073,7 @@ static void ANDByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::AND); } @@ -2089,7 +2089,7 @@ static void ORByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Byte512VectorTests::OR); } @@ -2108,7 +2108,7 @@ static void ORByte512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte512VectorTests::OR); } @@ -2123,7 +2123,7 @@ static void ADDByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Byte512VectorTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -2140,7 +2140,7 @@ static void ADDByte512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte512VectorTests::LSHL); + assertArraysEquals(r, a, b, Byte512VectorTests::LSHL); } @@ -2185,7 +2185,7 @@ static void LSHLByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte512VectorTests::ASHR); + assertArraysEquals(r, a, b, Byte512VectorTests::ASHR); } @@ -2233,7 +2233,7 @@ static void ASHRByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Byte512VectorTests::LSHR); + assertArraysEquals(r, a, b, Byte512VectorTests::LSHR); } @@ -2281,7 +2281,7 @@ static void LSHRByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::MIN); + assertArraysEquals(r, a, b, Byte512VectorTests::MIN); } static byte min(byte a, byte b) { return (byte)(Math.min(a, b)); @@ -2460,7 +2460,7 @@ static void minByte512VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::min); + assertArraysEquals(r, a, b, Byte512VectorTests::min); } static byte MAX(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2480,7 +2480,7 @@ static void MAXByte512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte512VectorTests::MAX); + assertArraysEquals(r, a, b, Byte512VectorTests::MAX); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2498,7 +2498,7 @@ static void maxByte512VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::max); + assertArraysEquals(r, a, b, Byte512VectorTests::max); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2512,7 +2512,7 @@ static void MINByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2526,7 +2526,7 @@ static void minByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::min); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2540,7 +2540,7 @@ static void MAXByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2554,7 +2554,7 @@ static void maxByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::max); } static byte ANDReduce(byte[] a, int idx) { @@ -2597,7 +2597,7 @@ static void ANDReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::ANDReduce, Byte512VectorTests::ANDReduceAll); } @@ -2645,7 +2645,7 @@ static void ANDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::ANDReduceMasked, Byte512VectorTests::ANDReduceAllMasked); } @@ -2690,7 +2690,7 @@ static void ORReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::ORReduce, Byte512VectorTests::ORReduceAll); } @@ -2738,7 +2738,7 @@ static void ORReduceByte512VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::ORReduceMasked, Byte512VectorTests::ORReduceAllMasked); } @@ -2783,7 +2783,7 @@ static void XORReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::XORReduce, Byte512VectorTests::XORReduceAll); } @@ -2831,7 +2831,7 @@ static void XORReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::XORReduceMasked, Byte512VectorTests::XORReduceAllMasked); } @@ -2873,7 +2873,7 @@ static void ADDReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::ADDReduce, Byte512VectorTests::ADDReduceAll); } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -2917,7 +2917,7 @@ static void ADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::ADDReduceMasked, Byte512VectorTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { @@ -2958,7 +2958,7 @@ static void MULReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::MULReduce, Byte512VectorTests::MULReduceAll); } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3002,7 +3002,7 @@ static void MULReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::MULReduceMasked, Byte512VectorTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { @@ -3043,7 +3043,7 @@ static void MINReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::MINReduce, Byte512VectorTests::MINReduceAll); } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3088,7 +3088,7 @@ static void MINReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::MINReduceMasked, Byte512VectorTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { @@ -3129,7 +3129,7 @@ static void MAXReduceByte512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte512VectorTests::MAXReduce, Byte512VectorTests::MAXReduceAll); } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3174,7 +3174,7 @@ static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::MAXReduceMasked, Byte512VectorTests::MAXReduceAllMasked); } @@ -3200,7 +3200,7 @@ static void anyTrueByte512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::anyTrue); } @@ -3226,7 +3226,7 @@ static void allTrueByte512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::allTrue); } @@ -3242,7 +3242,7 @@ static void withByte512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (byte)4, 0); + assertInsertArraysEquals(r, a, (byte)4, 0); } static boolean testIS_DEFAULT(byte a) { return bits(a)==0; @@ -3791,7 +3791,7 @@ static void blendByte512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Byte512VectorTests::blend); + assertArraysEquals(r, a, b, mask, Byte512VectorTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") @@ -3808,7 +3808,7 @@ static void RearrangeByte512VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") @@ -3826,7 +3826,7 @@ static void RearrangeByte512VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpProvider") static void getByte512VectorTests(IntFunction fa) { @@ -3981,7 +3981,7 @@ static void getByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::get); + assertArraysEquals(r, a, Byte512VectorTests::get); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3995,7 +3995,7 @@ static void BroadcastByte512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4042,7 +4042,7 @@ static void sliceUnaryByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Byte512VectorTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4071,7 +4071,7 @@ static void sliceBinaryByte512VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Byte512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Byte512VectorTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4104,7 +4104,7 @@ static void sliceByte512VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Byte512VectorTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4170,7 +4170,7 @@ static void unsliceBinaryByte512VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Byte512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Byte512VectorTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4226,7 +4226,7 @@ static void unsliceByte512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Byte512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Byte512VectorTests::unslice); } @@ -4275,7 +4275,7 @@ static void BITWISE_BLENDByte512VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Byte512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Byte512VectorTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") static void bitwiseBlendByte512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4291,7 +4291,7 @@ static void bitwiseBlendByte512VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Byte512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Byte512VectorTests::BITWISE_BLEND); } @@ -4332,7 +4332,7 @@ static void BITWISE_BLENDByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4361,7 +4361,7 @@ static void bitwiseBlendByte512VectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Byte512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4376,7 +4376,7 @@ static void bitwiseBlendByte512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4447,7 +4447,7 @@ static void bitwiseBlendByte512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::NEG); + assertArraysEquals(r, a, Byte512VectorTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4505,7 +4505,7 @@ static void negByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::neg); + assertArraysEquals(r, a, Byte512VectorTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4523,7 +4523,7 @@ static void NEGMaskedByte512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte512VectorTests::NEG); + assertArraysEquals(r, a, mask, Byte512VectorTests::NEG); } static byte ABS(byte a) { @@ -4546,7 +4546,7 @@ static void ABSByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::ABS); + assertArraysEquals(r, a, Byte512VectorTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4561,7 +4561,7 @@ static void absByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::abs); + assertArraysEquals(r, a, Byte512VectorTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4579,7 +4579,7 @@ static void ABSMaskedByte512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte512VectorTests::ABS); + assertArraysEquals(r, a, mask, Byte512VectorTests::ABS); } @@ -4605,7 +4605,7 @@ static void NOTByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::NOT); + assertArraysEquals(r, a, Byte512VectorTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4620,7 +4620,7 @@ static void notByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::not); + assertArraysEquals(r, a, Byte512VectorTests::not); } @@ -4640,7 +4640,7 @@ static void NOTMaskedByte512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte512VectorTests::NOT); + assertArraysEquals(r, a, mask, Byte512VectorTests::NOT); } @@ -4663,7 +4663,7 @@ static void ZOMOByte512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte512VectorTests::ZOMO); + assertArraysEquals(r, a, Byte512VectorTests::ZOMO); } @@ -4683,7 +4683,7 @@ static void ZOMOMaskedByte512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Byte512VectorTests::ZOMO); } @@ -4711,7 +4711,7 @@ static void gatherByte512VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Byte512VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Byte512VectorTests::scatterMasked); } @@ -4844,8 +4844,8 @@ static void toIntArrayByte512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4855,8 +4855,8 @@ static void toLongArrayByte512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4866,8 +4866,8 @@ static void toDoubleArrayByte512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4907,7 +4907,7 @@ static void reinterpretAsBytesByte512VectorTestsSmokeTest(IntFunction fa ByteVector av = ByteVector.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } static long ADDReduceLong(byte[] a, int idx) { @@ -4944,7 +4944,7 @@ static void ADDReduceLongByte512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Byte512VectorTests::ADDReduceLong, Byte512VectorTests::ADDReduceAllLong); } @@ -4985,7 +4985,7 @@ static void ADDReduceLongByte512VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Byte512VectorTests::ADDReduceLongMasked, Byte512VectorTests::ADDReduceAllLongMasked); } @@ -4997,7 +4997,7 @@ static void BroadcastLongByte512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -5015,7 +5015,7 @@ static void blendByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte512VectorTests::blend); } @@ -5032,7 +5032,7 @@ static void SelectFromByte512VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") @@ -5051,7 +5051,7 @@ static void SelectFromByte512VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5128,7 +5128,7 @@ static void maskEqByte512VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Byte512VectorTests::beq); + assertArraysEquals(r, a, b, Byte512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java index b19a4d2c6cb..48e280b3585 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Byte64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Byte64VectorLoadStoreTests * */ @@ -57,36 +57,14 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -390,7 +368,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "byteProviderForIOOBE") @@ -461,7 +439,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteMaskProviderForIOOBE") @@ -545,7 +523,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -569,7 +547,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -656,7 +634,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -671,7 +649,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -787,7 +765,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -868,7 +846,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -956,7 +934,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -967,7 +945,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index 40f22d33911..affeea486e4 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Byte64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { byte apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { byte[] apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { byte apply(byte[] a); } - static void assertReductionArraysEquals(byte[] a, byte[] b, byte c, + static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { byte apply(byte[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(byte[] a, byte[] b, byte c, boolean[] mask, + static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(byte[] a); } - static void assertReductionLongArraysEquals(byte[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(byte[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(byte[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(byte[] a, byte[] b, byte element, int index) { + static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int v } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boole } } - static void assertBroadcastArraysEquals(byte[]a, byte[]r) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolea } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { byte apply(byte[] a, int b); } - static void assertArraysEquals(byte[] a, byte[] r, FBinArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, FGatherScatterOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FSca } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { byte[] apply(byte[] a, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { byte[] apply(byte[] a, byte[] b, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBo } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { byte[] apply(byte[] a, byte[] b, int origin, int part, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } - static void assertArraysEquals(byte[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -802,7 +802,7 @@ static void assertArraysEquals(byte[] a, int[] r, int offs) { } - static void assertArraysEquals(byte[] a, byte[] r, int offs) { + static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -813,7 +813,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int offs) { } } - static void assertArraysEquals(byte[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -824,7 +824,7 @@ static void assertArraysEquals(byte[] a, long[] r, int offs) { } } - static void assertArraysEquals(byte[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1288,7 +1288,7 @@ static void ADDByte64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::ADD); + assertArraysEquals(r, a, b, Byte64VectorTests::ADD); } static byte add(byte a, byte b) { return (byte)(a + b); @@ -1306,7 +1306,7 @@ static void addByte64VectorTests(IntFunction fa, IntFunction fb) av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::add); + assertArraysEquals(r, a, b, Byte64VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1326,7 +1326,7 @@ static void ADDByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::SUB); + assertArraysEquals(r, a, b, Byte64VectorTests::SUB); } static byte sub(byte a, byte b) { return (byte)(a - b); @@ -1382,7 +1382,7 @@ static void subByte64VectorTests(IntFunction fa, IntFunction fb) av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::sub); + assertArraysEquals(r, a, b, Byte64VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1402,7 +1402,7 @@ static void SUBByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::MUL); + assertArraysEquals(r, a, b, Byte64VectorTests::MUL); } static byte mul(byte a, byte b) { return (byte)(a * b); @@ -1458,7 +1458,7 @@ static void mulByte64VectorTests(IntFunction fa, IntFunction fb) av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::mul); + assertArraysEquals(r, a, b, Byte64VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1478,7 +1478,7 @@ static void MULByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::DIV); + assertArraysEquals(r, a, b, Byte64VectorTests::DIV); } static byte div(byte a, byte b) { return (byte)(a / b); @@ -1543,7 +1543,7 @@ static void divByte64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::div); + assertArraysEquals(r, a, b, Byte64VectorTests::div); } @@ -1567,7 +1567,7 @@ static void DIVByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, mask, Byte64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Byte64VectorTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -1651,7 +1651,7 @@ static void ANDByte64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::AND); + assertArraysEquals(r, a, b, Byte64VectorTests::AND); } static byte and(byte a, byte b) { return (byte)(a & b); @@ -1669,7 +1669,7 @@ static void andByte64VectorTests(IntFunction fa, IntFunction fb) av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::and); + assertArraysEquals(r, a, b, Byte64VectorTests::and); } @@ -1691,7 +1691,7 @@ static void ANDByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Byte64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Byte64VectorTests::AND_NOT); } @@ -1735,7 +1735,7 @@ static void AND_NOTByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::OR); + assertArraysEquals(r, a, b, Byte64VectorTests::OR); } static byte or(byte a, byte b) { return (byte)(a | b); @@ -1775,7 +1775,7 @@ static void orByte64VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::or); + assertArraysEquals(r, a, b, Byte64VectorTests::or); } @@ -1797,7 +1797,7 @@ static void ORByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::XOR); + assertArraysEquals(r, a, b, Byte64VectorTests::XOR); } @@ -1841,7 +1841,7 @@ static void XORByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1873,7 +1873,7 @@ static void addByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::add); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1887,7 +1887,7 @@ static void subByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1904,7 +1904,7 @@ static void subByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1918,7 +1918,7 @@ static void mulByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1935,7 +1935,7 @@ static void mulByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::mul); } @@ -1954,7 +1954,7 @@ static void divByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::div); } @@ -1975,7 +1975,7 @@ static void divByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::div); } @@ -1991,7 +1991,7 @@ static void ORByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2005,7 +2005,7 @@ static void orByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::or); } @@ -2024,7 +2024,7 @@ static void ORByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::OR); } @@ -2040,7 +2040,7 @@ static void ANDByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2054,7 +2054,7 @@ static void andByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::and); } @@ -2073,7 +2073,7 @@ static void ANDByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::AND); } @@ -2089,7 +2089,7 @@ static void ORByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Byte64VectorTests::OR); } @@ -2108,7 +2108,7 @@ static void ORByte64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::OR); } @@ -2123,7 +2123,7 @@ static void ADDByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Byte64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Byte64VectorTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -2140,7 +2140,7 @@ static void ADDByte64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::ADD); } @@ -2163,7 +2163,7 @@ static void LSHLByte64VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte64VectorTests::LSHL); + assertArraysEquals(r, a, b, Byte64VectorTests::LSHL); } @@ -2185,7 +2185,7 @@ static void LSHLByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte64VectorTests::ASHR); + assertArraysEquals(r, a, b, Byte64VectorTests::ASHR); } @@ -2233,7 +2233,7 @@ static void ASHRByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Byte64VectorTests::LSHR); + assertArraysEquals(r, a, b, Byte64VectorTests::LSHR); } @@ -2281,7 +2281,7 @@ static void LSHRByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::MIN); + assertArraysEquals(r, a, b, Byte64VectorTests::MIN); } static byte min(byte a, byte b) { return (byte)(Math.min(a, b)); @@ -2460,7 +2460,7 @@ static void minByte64VectorTests(IntFunction fa, IntFunction fb) av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::min); + assertArraysEquals(r, a, b, Byte64VectorTests::min); } static byte MAX(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2480,7 +2480,7 @@ static void MAXByte64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Byte64VectorTests::MAX); + assertArraysEquals(r, a, b, Byte64VectorTests::MAX); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2498,7 +2498,7 @@ static void maxByte64VectorTests(IntFunction fa, IntFunction fb) av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::max); + assertArraysEquals(r, a, b, Byte64VectorTests::max); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2512,7 +2512,7 @@ static void MINByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2526,7 +2526,7 @@ static void minByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::min); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2540,7 +2540,7 @@ static void MAXByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2554,7 +2554,7 @@ static void maxByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::max); } static byte ANDReduce(byte[] a, int idx) { @@ -2597,7 +2597,7 @@ static void ANDReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::ANDReduce, Byte64VectorTests::ANDReduceAll); } @@ -2645,7 +2645,7 @@ static void ANDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::ANDReduceMasked, Byte64VectorTests::ANDReduceAllMasked); } @@ -2690,7 +2690,7 @@ static void ORReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::ORReduce, Byte64VectorTests::ORReduceAll); } @@ -2738,7 +2738,7 @@ static void ORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::ORReduceMasked, Byte64VectorTests::ORReduceAllMasked); } @@ -2783,7 +2783,7 @@ static void XORReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::XORReduce, Byte64VectorTests::XORReduceAll); } @@ -2831,7 +2831,7 @@ static void XORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::XORReduceMasked, Byte64VectorTests::XORReduceAllMasked); } @@ -2873,7 +2873,7 @@ static void ADDReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::ADDReduce, Byte64VectorTests::ADDReduceAll); } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -2917,7 +2917,7 @@ static void ADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::ADDReduceMasked, Byte64VectorTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { @@ -2958,7 +2958,7 @@ static void MULReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::MULReduce, Byte64VectorTests::MULReduceAll); } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3002,7 +3002,7 @@ static void MULReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::MULReduceMasked, Byte64VectorTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { @@ -3043,7 +3043,7 @@ static void MINReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::MINReduce, Byte64VectorTests::MINReduceAll); } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3088,7 +3088,7 @@ static void MINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::MINReduceMasked, Byte64VectorTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { @@ -3129,7 +3129,7 @@ static void MAXReduceByte64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Byte64VectorTests::MAXReduce, Byte64VectorTests::MAXReduceAll); } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3174,7 +3174,7 @@ static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::MAXReduceMasked, Byte64VectorTests::MAXReduceAllMasked); } @@ -3200,7 +3200,7 @@ static void anyTrueByte64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::anyTrue); } @@ -3226,7 +3226,7 @@ static void allTrueByte64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Byte64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::allTrue); } @@ -3242,7 +3242,7 @@ static void withByte64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (byte)4, 0); + assertInsertArraysEquals(r, a, (byte)4, 0); } static boolean testIS_DEFAULT(byte a) { return bits(a)==0; @@ -3791,7 +3791,7 @@ static void blendByte64VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, mask, Byte64VectorTests::blend); + assertArraysEquals(r, a, b, mask, Byte64VectorTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") @@ -3808,7 +3808,7 @@ static void RearrangeByte64VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") @@ -3826,7 +3826,7 @@ static void RearrangeByte64VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpProvider") static void getByte64VectorTests(IntFunction fa) { @@ -3981,7 +3981,7 @@ static void getByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::get); + assertArraysEquals(r, a, Byte64VectorTests::get); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3995,7 +3995,7 @@ static void BroadcastByte64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4042,7 +4042,7 @@ static void sliceUnaryByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Byte64VectorTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4071,7 +4071,7 @@ static void sliceBinaryByte64VectorTestsBinary(IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, origin, Byte64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Byte64VectorTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4104,7 +4104,7 @@ static void sliceByte64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Byte64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Byte64VectorTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4170,7 +4170,7 @@ static void unsliceBinaryByte64VectorTestsBinary(IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, origin, part, Byte64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Byte64VectorTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4226,7 +4226,7 @@ static void unsliceByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4291,7 +4291,7 @@ static void bitwiseBlendByte64VectorTests(IntFunction fa, IntFunction fa, IntFunc } } - assertArraysEquals(a, b, c, r, mask, Byte64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Byte64VectorTests::BITWISE_BLEND); } @@ -4332,7 +4332,7 @@ static void BITWISE_BLENDByte64VectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Byte64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4347,7 +4347,7 @@ static void BITWISE_BLENDByte64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4361,7 +4361,7 @@ static void bitwiseBlendByte64VectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Byte64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4376,7 +4376,7 @@ static void bitwiseBlendByte64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4447,7 +4447,7 @@ static void bitwiseBlendByte64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::NEG); + assertArraysEquals(r, a, Byte64VectorTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4505,7 +4505,7 @@ static void negByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::neg); + assertArraysEquals(r, a, Byte64VectorTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4523,7 +4523,7 @@ static void NEGMaskedByte64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte64VectorTests::NEG); + assertArraysEquals(r, a, mask, Byte64VectorTests::NEG); } static byte ABS(byte a) { @@ -4546,7 +4546,7 @@ static void ABSByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::ABS); + assertArraysEquals(r, a, Byte64VectorTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4561,7 +4561,7 @@ static void absByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::abs); + assertArraysEquals(r, a, Byte64VectorTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4579,7 +4579,7 @@ static void ABSMaskedByte64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte64VectorTests::ABS); + assertArraysEquals(r, a, mask, Byte64VectorTests::ABS); } @@ -4605,7 +4605,7 @@ static void NOTByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::NOT); + assertArraysEquals(r, a, Byte64VectorTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4620,7 +4620,7 @@ static void notByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::not); + assertArraysEquals(r, a, Byte64VectorTests::not); } @@ -4640,7 +4640,7 @@ static void NOTMaskedByte64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte64VectorTests::NOT); + assertArraysEquals(r, a, mask, Byte64VectorTests::NOT); } @@ -4663,7 +4663,7 @@ static void ZOMOByte64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Byte64VectorTests::ZOMO); + assertArraysEquals(r, a, Byte64VectorTests::ZOMO); } @@ -4683,7 +4683,7 @@ static void ZOMOMaskedByte64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Byte64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Byte64VectorTests::ZOMO); } @@ -4711,7 +4711,7 @@ static void gatherByte64VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4855,8 +4855,8 @@ static void toLongArrayByte64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4866,8 +4866,8 @@ static void toDoubleArrayByte64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4907,7 +4907,7 @@ static void reinterpretAsBytesByte64VectorTestsSmokeTest(IntFunction fa) ByteVector av = ByteVector.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } static long ADDReduceLong(byte[] a, int idx) { @@ -4944,7 +4944,7 @@ static void ADDReduceLongByte64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Byte64VectorTests::ADDReduceLong, Byte64VectorTests::ADDReduceAllLong); } @@ -4985,7 +4985,7 @@ static void ADDReduceLongByte64VectorTestsMasked(IntFunction fa, IntFunc ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Byte64VectorTests::ADDReduceLongMasked, Byte64VectorTests::ADDReduceAllLongMasked); } @@ -4997,7 +4997,7 @@ static void BroadcastLongByte64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -5015,7 +5015,7 @@ static void blendByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Byte64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::blend); } @@ -5032,7 +5032,7 @@ static void SelectFromByte64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") @@ -5051,7 +5051,7 @@ static void SelectFromByte64VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5128,7 +5128,7 @@ static void maskEqByte64VectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Byte64VectorTests::beq); + assertArraysEquals(r, a, b, Byte64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java index 2a16b65d4ee..e642f4d780c 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * ByteMaxVectorLoadStoreTests + * -XX:-TieredCompilation ByteMaxVectorLoadStoreTests * */ @@ -66,36 +66,14 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -399,7 +377,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "byteProviderForIOOBE") @@ -470,7 +448,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteMaskProviderForIOOBE") @@ -554,7 +532,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -578,7 +556,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -665,7 +643,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -680,7 +658,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -796,7 +774,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "byteByteProviderForIOOBE") @@ -877,7 +855,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "byteByteMaskProviderForIOOBE") @@ -965,7 +943,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -976,7 +954,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index 3535be3ca39..d6dd82af7ae 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch ByteMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation ByteMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { byte apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { byte[] apply(byte a); } - static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(byte[] a, byte[] r, FUnArrayOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { byte apply(byte[] a); } - static void assertReductionArraysEquals(byte[] a, byte[] b, byte c, + static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { byte apply(byte[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(byte[] a, byte[] b, byte c, boolean[] mask, + static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -167,17 +167,17 @@ interface FReductionAllOpLong { long apply(byte[] a); } - static void assertReductionLongArraysEquals(byte[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -189,17 +189,17 @@ interface FReductionAllMaskedOpLong { long apply(byte[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(byte[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -207,37 +207,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(byte[] a, byte[] b, byte element, int index) { + static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -251,7 +251,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -265,7 +265,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, int v } } - static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -285,7 +285,7 @@ static void assertRearrangeArraysEquals(byte[] a, byte[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -305,7 +305,7 @@ static void assertSelectFromArraysEquals(byte[] a, byte[] r, byte[] order, boole } } - static void assertBroadcastArraysEquals(byte[]a, byte[]r) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -334,7 +334,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -345,7 +345,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -357,7 +357,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -369,11 +369,11 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -384,11 +384,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -402,11 +402,11 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -420,7 +420,7 @@ static void assertBroadcastLongArraysEquals(byte[] a, byte[] b, byte[] r, boolea } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -434,11 +434,11 @@ static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) { } } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -464,7 +464,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -475,11 +475,11 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f } } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -491,7 +491,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -504,7 +504,7 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,12 +517,12 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -538,12 +538,12 @@ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, } } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ static void assertAltBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,12 +574,12 @@ static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte } } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(byte[] a, byte[] b, byte[] c, byte[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -602,7 +602,7 @@ interface FBinArrayOp { byte apply(byte[] a, int b); } - static void assertArraysEquals(byte[] a, byte[] r, FBinArrayOp f) { + static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -617,7 +617,7 @@ interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, FGatherScatterOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -644,7 +644,7 @@ interface FScatterMaskedOp { byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -665,7 +665,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FGat } } - static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -675,7 +675,7 @@ static void assertArraysEquals(byte[] a, int[] b, byte[] r, boolean[] mask, FSca } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -692,7 +692,7 @@ interface FLaneOp { byte[] apply(byte[] a, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { + static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -702,7 +702,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int origin, FLaneOp f) { } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -712,7 +712,7 @@ interface FLaneBop { byte[] apply(byte[] a, byte[] b, int origin, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -722,7 +722,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, FLaneBo } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -733,7 +733,7 @@ interface FLaneMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -743,7 +743,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, boolean } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -754,7 +754,7 @@ interface FLanePartBop { byte[] apply(byte[] a, byte[] b, int origin, int part, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -764,7 +764,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -776,7 +776,7 @@ interface FLanePartMaskedBop { byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -786,7 +786,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -795,7 +795,7 @@ static void assertArraysEquals(byte[] a, byte[] b, byte[] r, int origin, int par } - static void assertArraysEquals(byte[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -807,7 +807,7 @@ static void assertArraysEquals(byte[] a, int[] r, int offs) { } - static void assertArraysEquals(byte[] a, byte[] r, int offs) { + static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -818,7 +818,7 @@ static void assertArraysEquals(byte[] a, byte[] r, int offs) { } } - static void assertArraysEquals(byte[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -829,7 +829,7 @@ static void assertArraysEquals(byte[] a, long[] r, int offs) { } } - static void assertArraysEquals(byte[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1293,7 +1293,7 @@ static void ADDByteMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::ADD); + assertArraysEquals(r, a, b, ByteMaxVectorTests::ADD); } static byte add(byte a, byte b) { return (byte)(a + b); @@ -1311,7 +1311,7 @@ static void addByteMaxVectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::add); + assertArraysEquals(r, a, b, ByteMaxVectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1331,7 +1331,7 @@ static void ADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::SUB); + assertArraysEquals(r, a, b, ByteMaxVectorTests::SUB); } static byte sub(byte a, byte b) { return (byte)(a - b); @@ -1387,7 +1387,7 @@ static void subByteMaxVectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::sub); + assertArraysEquals(r, a, b, ByteMaxVectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1407,7 +1407,7 @@ static void SUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::MUL); + assertArraysEquals(r, a, b, ByteMaxVectorTests::MUL); } static byte mul(byte a, byte b) { return (byte)(a * b); @@ -1463,7 +1463,7 @@ static void mulByteMaxVectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::mul); + assertArraysEquals(r, a, b, ByteMaxVectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1483,7 +1483,7 @@ static void MULByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::DIV); + assertArraysEquals(r, a, b, ByteMaxVectorTests::DIV); } static byte div(byte a, byte b) { return (byte)(a / b); @@ -1548,7 +1548,7 @@ static void divByteMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::div); + assertArraysEquals(r, a, b, ByteMaxVectorTests::div); } @@ -1572,7 +1572,7 @@ static void DIVByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1635,7 +1635,7 @@ static void FIRST_NONZEROByteMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -1656,7 +1656,7 @@ static void ANDByteMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::AND); + assertArraysEquals(r, a, b, ByteMaxVectorTests::AND); } static byte and(byte a, byte b) { return (byte)(a & b); @@ -1674,7 +1674,7 @@ static void andByteMaxVectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::and); + assertArraysEquals(r, a, b, ByteMaxVectorTests::and); } @@ -1696,7 +1696,7 @@ static void ANDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND_NOT); } @@ -1762,7 +1762,7 @@ static void ORByteMaxVectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::OR); + assertArraysEquals(r, a, b, ByteMaxVectorTests::OR); } static byte or(byte a, byte b) { return (byte)(a | b); @@ -1780,7 +1780,7 @@ static void orByteMaxVectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::or); + assertArraysEquals(r, a, b, ByteMaxVectorTests::or); } @@ -1802,7 +1802,7 @@ static void ORByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::XOR); + assertArraysEquals(r, a, b, ByteMaxVectorTests::XOR); } @@ -1846,7 +1846,7 @@ static void XORByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1878,7 +1878,7 @@ static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::add); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1892,7 +1892,7 @@ static void subByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1909,7 +1909,7 @@ static void subByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1923,7 +1923,7 @@ static void mulByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -1940,7 +1940,7 @@ static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul); } @@ -1959,7 +1959,7 @@ static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::div); } @@ -1980,7 +1980,7 @@ static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::div); } @@ -1996,7 +1996,7 @@ static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2010,7 +2010,7 @@ static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::or); } @@ -2029,7 +2029,7 @@ static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR); } @@ -2045,7 +2045,7 @@ static void ANDByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2059,7 +2059,7 @@ static void andByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::and); } @@ -2078,7 +2078,7 @@ static void ANDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ByteMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND); } @@ -2094,7 +2094,7 @@ static void ORByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, ByteMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::OR); } @@ -2113,7 +2113,7 @@ static void ORByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, ByteMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR); } @@ -2128,7 +2128,7 @@ static void ADDByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, ByteMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -2145,7 +2145,7 @@ static void ADDByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHL); } @@ -2190,7 +2190,7 @@ static void LSHLByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, ByteMaxVectorTests::ASHR); } @@ -2238,7 +2238,7 @@ static void ASHRByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHR); } @@ -2286,7 +2286,7 @@ static void LSHRByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::MIN); + assertArraysEquals(r, a, b, ByteMaxVectorTests::MIN); } static byte min(byte a, byte b) { return (byte)(Math.min(a, b)); @@ -2465,7 +2465,7 @@ static void minByteMaxVectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::min); + assertArraysEquals(r, a, b, ByteMaxVectorTests::min); } static byte MAX(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2485,7 +2485,7 @@ static void MAXByteMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, ByteMaxVectorTests::MAX); + assertArraysEquals(r, a, b, ByteMaxVectorTests::MAX); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); @@ -2503,7 +2503,7 @@ static void maxByteMaxVectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::max); + assertArraysEquals(r, a, b, ByteMaxVectorTests::max); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2517,7 +2517,7 @@ static void MINByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2531,7 +2531,7 @@ static void minByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::min); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2545,7 +2545,7 @@ static void MAXByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") @@ -2559,7 +2559,7 @@ static void maxByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ByteMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::max); } static byte ANDReduce(byte[] a, int idx) { @@ -2602,7 +2602,7 @@ static void ANDReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::ANDReduce, ByteMaxVectorTests::ANDReduceAll); } @@ -2650,7 +2650,7 @@ static void ANDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::ANDReduceMasked, ByteMaxVectorTests::ANDReduceAllMasked); } @@ -2695,7 +2695,7 @@ static void ORReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::ORReduce, ByteMaxVectorTests::ORReduceAll); } @@ -2743,7 +2743,7 @@ static void ORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::ORReduceMasked, ByteMaxVectorTests::ORReduceAllMasked); } @@ -2788,7 +2788,7 @@ static void XORReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::XORReduce, ByteMaxVectorTests::XORReduceAll); } @@ -2836,7 +2836,7 @@ static void XORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::XORReduceMasked, ByteMaxVectorTests::XORReduceAllMasked); } @@ -2878,7 +2878,7 @@ static void ADDReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::ADDReduce, ByteMaxVectorTests::ADDReduceAll); } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -2922,7 +2922,7 @@ static void ADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::ADDReduceMasked, ByteMaxVectorTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { @@ -2963,7 +2963,7 @@ static void MULReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::MULReduce, ByteMaxVectorTests::MULReduceAll); } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3007,7 +3007,7 @@ static void MULReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::MULReduceMasked, ByteMaxVectorTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { @@ -3048,7 +3048,7 @@ static void MINReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::MINReduce, ByteMaxVectorTests::MINReduceAll); } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3093,7 +3093,7 @@ static void MINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::MINReduceMasked, ByteMaxVectorTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { @@ -3134,7 +3134,7 @@ static void MAXReduceByteMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ByteMaxVectorTests::MAXReduce, ByteMaxVectorTests::MAXReduceAll); } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { @@ -3179,7 +3179,7 @@ static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked); } @@ -3205,7 +3205,7 @@ static void anyTrueByteMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, ByteMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::anyTrue); } @@ -3231,7 +3231,7 @@ static void allTrueByteMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, ByteMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue); } @@ -3247,7 +3247,7 @@ static void withByteMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (byte)4, 0); + assertInsertArraysEquals(r, a, (byte)4, 0); } static boolean testIS_DEFAULT(byte a) { return bits(a)==0; @@ -3796,7 +3796,7 @@ static void blendByteMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") @@ -3813,7 +3813,7 @@ static void RearrangeByteMaxVectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") @@ -3831,7 +3831,7 @@ static void RearrangeByteMaxVectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpProvider") static void getByteMaxVectorTests(IntFunction fa) { @@ -3986,7 +3986,7 @@ static void getByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::get); + assertArraysEquals(r, a, ByteMaxVectorTests::get); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4000,7 +4000,7 @@ static void BroadcastByteMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4047,7 +4047,7 @@ static void sliceUnaryByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, ByteMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteMaxVectorTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4076,7 +4076,7 @@ static void sliceBinaryByteMaxVectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, ByteMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteMaxVectorTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4109,7 +4109,7 @@ static void sliceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, ByteMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteMaxVectorTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4175,7 +4175,7 @@ static void unsliceBinaryByteMaxVectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, ByteMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteMaxVectorTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { byte[] res = new byte[SPECIES.length()]; @@ -4231,7 +4231,7 @@ static void unsliceByteMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, ByteMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteMaxVectorTests::unslice); } @@ -4280,7 +4280,7 @@ static void BITWISE_BLENDByteMaxVectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, ByteMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") static void bitwiseBlendByteMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4296,7 +4296,7 @@ static void bitwiseBlendByteMaxVectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, ByteMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND); } @@ -4337,7 +4337,7 @@ static void BITWISE_BLENDByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4366,7 +4366,7 @@ static void bitwiseBlendByteMaxVectorTestsBroadcastSmokeTest(IntFunction ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, ByteMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") @@ -4381,7 +4381,7 @@ static void bitwiseBlendByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4452,7 +4452,7 @@ static void bitwiseBlendByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::NEG); + assertArraysEquals(r, a, ByteMaxVectorTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4510,7 +4510,7 @@ static void negByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::neg); + assertArraysEquals(r, a, ByteMaxVectorTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4528,7 +4528,7 @@ static void NEGMaskedByteMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ByteMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, ByteMaxVectorTests::NEG); } static byte ABS(byte a) { @@ -4551,7 +4551,7 @@ static void ABSByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::ABS); + assertArraysEquals(r, a, ByteMaxVectorTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4566,7 +4566,7 @@ static void absByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::abs); + assertArraysEquals(r, a, ByteMaxVectorTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") @@ -4584,7 +4584,7 @@ static void ABSMaskedByteMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ByteMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, ByteMaxVectorTests::ABS); } @@ -4610,7 +4610,7 @@ static void NOTByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::NOT); + assertArraysEquals(r, a, ByteMaxVectorTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4625,7 +4625,7 @@ static void notByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::not); + assertArraysEquals(r, a, ByteMaxVectorTests::not); } @@ -4645,7 +4645,7 @@ static void NOTMaskedByteMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ByteMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, ByteMaxVectorTests::NOT); } @@ -4668,7 +4668,7 @@ static void ZOMOByteMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ByteMaxVectorTests::ZOMO); + assertArraysEquals(r, a, ByteMaxVectorTests::ZOMO); } @@ -4688,7 +4688,7 @@ static void ZOMOMaskedByteMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ByteMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteMaxVectorTests::ZOMO); } @@ -4716,7 +4716,7 @@ static void gatherByteMaxVectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::scatterMasked); } @@ -4849,8 +4849,8 @@ static void toIntArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4860,8 +4860,8 @@ static void toLongArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4871,8 +4871,8 @@ static void toDoubleArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4912,7 +4912,7 @@ static void reinterpretAsBytesByteMaxVectorTestsSmokeTest(IntFunction fa ByteVector av = ByteVector.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } static long ADDReduceLong(byte[] a, int idx) { @@ -4949,7 +4949,7 @@ static void ADDReduceLongByteMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, ByteMaxVectorTests::ADDReduceLong, ByteMaxVectorTests::ADDReduceAllLong); } @@ -4990,7 +4990,7 @@ static void ADDReduceLongByteMaxVectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, ByteMaxVectorTests::ADDReduceLongMasked, ByteMaxVectorTests::ADDReduceAllLongMasked); } @@ -5002,7 +5002,7 @@ static void BroadcastLongByteMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "byteBinaryOpMaskProvider") @@ -5020,7 +5020,7 @@ static void blendByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, ByteMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend); } @@ -5037,7 +5037,7 @@ static void SelectFromByteMaxVectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") @@ -5056,7 +5056,7 @@ static void SelectFromByteMaxVectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5133,7 +5133,7 @@ static void maskEqByteMaxVectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, ByteMaxVectorTests::beq); + assertArraysEquals(r, a, b, ByteMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java index 9668b5b4305..3e5d6f07c4e 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Double128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Double128VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Double128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(double[] a, double[] r, boolean[] mask) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0, "at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(double[] a, double[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "doubleProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new double[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index 72a64d067c2..b1faaf7ced1 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Double128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { double apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { double[] apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { double apply(double[] a); } - static void assertReductionArraysEquals(double[] a, double[] b, double c, + static void assertReductionArraysEquals(double[] r, double rc, double[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { double apply(double[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask, + static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(double[] a); } - static void assertReductionLongArraysEquals(double[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(double[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(double[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) { + static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boo } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertBroadcastArraysEquals(double[]a, double[]r) { + static void assertBroadcastArraysEquals(double[] r, double[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBin } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, bool } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, F } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, b } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(double actual, double expected) { return true; } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, } } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, F } } - static void assertBroadcastArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { double apply(double[] a, int b); } - static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { double[] apply(double[] a, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { + static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { double[] apply(double[] a, double[] b, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, F } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, b } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { double[] apply(double[] a, double[] b, int origin, int part, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(double[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(double[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1396,7 +1396,7 @@ static void ADDDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Double128VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1452,7 +1452,7 @@ static void addDouble128VectorTestsMasked(IntFunction fa, IntFunction< av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double128VectorTests::add); + assertArraysEquals(r, a, b, mask, Double128VectorTests::add); } static double SUB(double a, double b) { return (double)(a - b); @@ -1472,7 +1472,7 @@ static void SUBDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Double128VectorTests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1528,7 +1528,7 @@ static void subDouble128VectorTestsMasked(IntFunction fa, IntFunction< av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double128VectorTests::sub); + assertArraysEquals(r, a, b, mask, Double128VectorTests::sub); } static double MUL(double a, double b) { return (double)(a * b); @@ -1548,7 +1548,7 @@ static void MULDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Double128VectorTests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1604,7 +1604,7 @@ static void mulDouble128VectorTestsMasked(IntFunction fa, IntFunction< av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double128VectorTests::mul); + assertArraysEquals(r, a, b, mask, Double128VectorTests::mul); } static double DIV(double a, double b) { @@ -1625,7 +1625,7 @@ static void DIVDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Double128VectorTests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1683,7 +1683,7 @@ static void divDouble128VectorTestsMasked(IntFunction fa, IntFunction< av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double128VectorTests::div); + assertArraysEquals(r, a, b, mask, Double128VectorTests::div); } @@ -1706,7 +1706,7 @@ static void FIRST_NONZERODouble128VectorTests(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, Double128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Double128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1726,7 +1726,7 @@ static void FIRST_NONZERODouble128VectorTestsMasked(IntFunction fa, In } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Double128VectorTests::FIRST_NONZERO); } @@ -1748,7 +1748,7 @@ static void addDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1765,7 +1765,7 @@ static void addDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1796,7 +1796,7 @@ static void subDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1827,7 +1827,7 @@ static void mulDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::div); } @@ -1861,7 +1861,7 @@ static void divDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Double128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Double128VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void ADDDouble128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void minDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2055,7 +2055,7 @@ static void MAXDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2069,7 +2069,7 @@ static void maxDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Double128VectorTests::max); } @@ -2121,7 +2121,7 @@ static void ADDReduceDouble128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll); } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2165,7 +2165,7 @@ static void ADDReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked); } static double MULReduce(double[] a, int idx) { @@ -2206,7 +2206,7 @@ static void MULReduceDouble128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll); } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2250,7 +2250,7 @@ static void MULReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked); } static double MINReduce(double[] a, int idx) { @@ -2291,7 +2291,7 @@ static void MINReduceDouble128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double128VectorTests::MINReduce, Double128VectorTests::MINReduceAll); } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2336,7 +2336,7 @@ static void MINReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double128VectorTests::MINReduceMasked, Double128VectorTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { @@ -2377,7 +2377,7 @@ static void MAXReduceDouble128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double128VectorTests::MAXReduce, Double128VectorTests::MAXReduceAll); } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2422,7 +2422,7 @@ static void MAXReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double128VectorTests::MAXReduceMasked, Double128VectorTests::MAXReduceAllMasked); } @@ -2442,7 +2442,7 @@ static void withDouble128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (double)4, 0); + assertInsertArraysEquals(r, a, (double)4, 0); } static boolean testIS_DEFAULT(double a) { return bits(a)==0; @@ -3108,7 +3108,7 @@ static void blendDouble128VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") @@ -3143,7 +3143,7 @@ static void RearrangeDouble128VectorTestsMaskedSmokeTest(IntFunction f av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpProvider") static void getDouble128VectorTests(IntFunction fa) { @@ -3298,7 +3298,7 @@ static void getDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::get); + assertArraysEquals(r, a, Double128VectorTests::get); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3312,7 +3312,7 @@ static void BroadcastDouble128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3359,7 +3359,7 @@ static void sliceUnaryDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Double128VectorTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3388,7 +3388,7 @@ static void sliceBinaryDouble128VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, Double128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Double128VectorTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3421,7 +3421,7 @@ static void sliceDouble128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, mask, Double128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Double128VectorTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3448,7 +3448,7 @@ static void unsliceUnaryDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Double128VectorTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { double[] res = new double[SPECIES.length()]; @@ -3487,7 +3487,7 @@ static void unsliceBinaryDouble128VectorTestsBinary(IntFunction fa, In } } - assertArraysEquals(a, b, r, origin, part, Double128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Double128VectorTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3543,7 +3543,7 @@ static void unsliceDouble128VectorTestsMasked(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, mask, Double128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Double128VectorTests::unslice); } static double SIN(double a) { @@ -3566,7 +3566,7 @@ static void SINDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::SIN, Double128VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SIN, Double128VectorTests::strictSIN); } @@ -3590,7 +3590,7 @@ static void EXPDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::EXP, Double128VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXP, Double128VectorTests::strictEXP); } @@ -3614,7 +3614,7 @@ static void LOG1PDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::LOG1P, Double128VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG1P, Double128VectorTests::strictLOG1P); } @@ -3638,7 +3638,7 @@ static void LOGDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::LOG, Double128VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG, Double128VectorTests::strictLOG); } @@ -3662,7 +3662,7 @@ static void LOG10Double128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::LOG10, Double128VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG10, Double128VectorTests::strictLOG10); } @@ -3686,7 +3686,7 @@ static void EXPM1Double128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::EXPM1, Double128VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXPM1, Double128VectorTests::strictEXPM1); } @@ -3710,7 +3710,7 @@ static void COSDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::COS, Double128VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COS, Double128VectorTests::strictCOS); } @@ -3734,7 +3734,7 @@ static void TANDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::TAN, Double128VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TAN, Double128VectorTests::strictTAN); } @@ -3758,7 +3758,7 @@ static void SINHDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::SINH, Double128VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SINH, Double128VectorTests::strictSINH); } @@ -3782,7 +3782,7 @@ static void COSHDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::COSH, Double128VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COSH, Double128VectorTests::strictCOSH); } @@ -3806,7 +3806,7 @@ static void TANHDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::TANH, Double128VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TANH, Double128VectorTests::strictTANH); } @@ -3830,7 +3830,7 @@ static void ASINDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::ASIN, Double128VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ASIN, Double128VectorTests::strictASIN); } @@ -3854,7 +3854,7 @@ static void ACOSDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::ACOS, Double128VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ACOS, Double128VectorTests::strictACOS); } @@ -3878,7 +3878,7 @@ static void ATANDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::ATAN, Double128VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ATAN, Double128VectorTests::strictATAN); } @@ -3902,7 +3902,7 @@ static void CBRTDouble128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double128VectorTests::CBRT, Double128VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::CBRT, Double128VectorTests::strictCBRT); } @@ -3928,7 +3928,7 @@ static void HYPOTDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double128VectorTests::POW, Double128VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4037,7 +4037,7 @@ static void powDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double128VectorTests::pow, Double128VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow); } @@ -4073,7 +4073,7 @@ static void FMADouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4096,7 +4096,7 @@ static void fmaDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, mask, Double128VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA); } @@ -4145,7 +4145,7 @@ static void FMADouble128VectorTestsBroadcastSmokeTest(IntFunction fa, DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Double128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4160,7 +4160,7 @@ static void FMADouble128VectorTestsAltBroadcastSmokeTest(IntFunction f DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Double128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA); } @@ -4180,7 +4180,7 @@ static void FMADouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4245,7 +4245,7 @@ static void fmaDouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::NEG); + assertArraysEquals(r, a, Double128VectorTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4312,7 +4312,7 @@ static void negDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::neg); + assertArraysEquals(r, a, Double128VectorTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4330,7 +4330,7 @@ static void NEGMaskedDouble128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double128VectorTests::NEG); + assertArraysEquals(r, a, mask, Double128VectorTests::NEG); } static double ABS(double a) { @@ -4353,7 +4353,7 @@ static void ABSDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::ABS); + assertArraysEquals(r, a, Double128VectorTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4368,7 +4368,7 @@ static void absDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::abs); + assertArraysEquals(r, a, Double128VectorTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4386,7 +4386,7 @@ static void ABSMaskedDouble128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double128VectorTests::ABS); + assertArraysEquals(r, a, mask, Double128VectorTests::ABS); } @@ -4418,7 +4418,7 @@ static void SQRTDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::SQRT); + assertArraysEquals(r, a, Double128VectorTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4433,7 +4433,7 @@ static void sqrtDouble128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double128VectorTests::sqrt); + assertArraysEquals(r, a, Double128VectorTests::sqrt); } @@ -4453,7 +4453,7 @@ static void SQRTMaskedDouble128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double128VectorTests::SQRT); + assertArraysEquals(r, a, mask, Double128VectorTests::SQRT); } static double[] gather(double a[], int ix, int[] b, int iy) { @@ -4478,7 +4478,7 @@ static void gatherDouble128VectorTests(IntFunction fa, BiFunction fa, BiFunctio } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Double128VectorTests::gatherMasked); } static double[] scatter(double a[], int ix, int[] b, int iy) { @@ -4531,7 +4531,7 @@ static void scatterDouble128VectorTests(IntFunction fa, BiFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Double128VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Double128VectorTests::scatterMasked); } @@ -4611,8 +4611,8 @@ static void toIntArrayDouble128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4622,8 +4622,8 @@ static void toLongArrayDouble128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4690,7 +4690,7 @@ static void ADDReduceLongDouble128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Double128VectorTests::ADDReduceLong, Double128VectorTests::ADDReduceAllLong); } @@ -4731,7 +4731,7 @@ static void ADDReduceLongDouble128VectorTestsMasked(IntFunction fa, In ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Double128VectorTests::ADDReduceLongMasked, Double128VectorTests::ADDReduceAllLongMasked); } @@ -4743,7 +4743,7 @@ static void BroadcastLongDouble128VectorTestsSmokeTest(IntFunction fa) for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -4761,7 +4761,7 @@ static void blendDouble128VectorTestsBroadcastLongSmokeTest(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") @@ -4797,7 +4797,7 @@ static void SelectFromDouble128VectorTestsMaskedSmokeTest(IntFunction bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4874,7 +4874,7 @@ static void maskEqDouble128VectorTestsSmokeTest(IntFunction fa, IntFu var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Double128VectorTests::beq); + assertArraysEquals(r, a, b, Double128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java index 0f70437a4a7..84da6e4648e 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Double256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Double256VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Double256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(double[] a, double[] r, boolean[] mask) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0, "at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(double[] a, double[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "doubleProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new double[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index 17e9a866b9f..1e1a1a851f5 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Double256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { double apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { double[] apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { double apply(double[] a); } - static void assertReductionArraysEquals(double[] a, double[] b, double c, + static void assertReductionArraysEquals(double[] r, double rc, double[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { double apply(double[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask, + static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(double[] a); } - static void assertReductionLongArraysEquals(double[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(double[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(double[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) { + static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boo } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertBroadcastArraysEquals(double[]a, double[]r) { + static void assertBroadcastArraysEquals(double[] r, double[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBin } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, bool } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, F } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, b } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(double actual, double expected) { return true; } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, } } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, F } } - static void assertBroadcastArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { double apply(double[] a, int b); } - static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { double[] apply(double[] a, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { + static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { double[] apply(double[] a, double[] b, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, F } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, b } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { double[] apply(double[] a, double[] b, int origin, int part, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(double[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(double[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1396,7 +1396,7 @@ static void ADDDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Double256VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1452,7 +1452,7 @@ static void addDouble256VectorTestsMasked(IntFunction fa, IntFunction< av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double256VectorTests::add); + assertArraysEquals(r, a, b, mask, Double256VectorTests::add); } static double SUB(double a, double b) { return (double)(a - b); @@ -1472,7 +1472,7 @@ static void SUBDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Double256VectorTests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1528,7 +1528,7 @@ static void subDouble256VectorTestsMasked(IntFunction fa, IntFunction< av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double256VectorTests::sub); + assertArraysEquals(r, a, b, mask, Double256VectorTests::sub); } static double MUL(double a, double b) { return (double)(a * b); @@ -1548,7 +1548,7 @@ static void MULDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Double256VectorTests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1604,7 +1604,7 @@ static void mulDouble256VectorTestsMasked(IntFunction fa, IntFunction< av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double256VectorTests::mul); + assertArraysEquals(r, a, b, mask, Double256VectorTests::mul); } static double DIV(double a, double b) { @@ -1625,7 +1625,7 @@ static void DIVDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Double256VectorTests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1683,7 +1683,7 @@ static void divDouble256VectorTestsMasked(IntFunction fa, IntFunction< av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double256VectorTests::div); + assertArraysEquals(r, a, b, mask, Double256VectorTests::div); } @@ -1706,7 +1706,7 @@ static void FIRST_NONZERODouble256VectorTests(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, Double256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Double256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1726,7 +1726,7 @@ static void FIRST_NONZERODouble256VectorTestsMasked(IntFunction fa, In } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Double256VectorTests::FIRST_NONZERO); } @@ -1748,7 +1748,7 @@ static void addDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1765,7 +1765,7 @@ static void addDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1796,7 +1796,7 @@ static void subDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1827,7 +1827,7 @@ static void mulDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::div); } @@ -1861,7 +1861,7 @@ static void divDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Double256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Double256VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void ADDDouble256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void minDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2055,7 +2055,7 @@ static void MAXDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2069,7 +2069,7 @@ static void maxDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Double256VectorTests::max); } @@ -2121,7 +2121,7 @@ static void ADDReduceDouble256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double256VectorTests::ADDReduce, Double256VectorTests::ADDReduceAll); } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2165,7 +2165,7 @@ static void ADDReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double256VectorTests::ADDReduceMasked, Double256VectorTests::ADDReduceAllMasked); } static double MULReduce(double[] a, int idx) { @@ -2206,7 +2206,7 @@ static void MULReduceDouble256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double256VectorTests::MULReduce, Double256VectorTests::MULReduceAll); } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2250,7 +2250,7 @@ static void MULReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double256VectorTests::MULReduceMasked, Double256VectorTests::MULReduceAllMasked); } static double MINReduce(double[] a, int idx) { @@ -2291,7 +2291,7 @@ static void MINReduceDouble256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double256VectorTests::MINReduce, Double256VectorTests::MINReduceAll); } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2336,7 +2336,7 @@ static void MINReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double256VectorTests::MINReduceMasked, Double256VectorTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { @@ -2377,7 +2377,7 @@ static void MAXReduceDouble256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double256VectorTests::MAXReduce, Double256VectorTests::MAXReduceAll); } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2422,7 +2422,7 @@ static void MAXReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double256VectorTests::MAXReduceMasked, Double256VectorTests::MAXReduceAllMasked); } @@ -2442,7 +2442,7 @@ static void withDouble256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (double)4, 0); + assertInsertArraysEquals(r, a, (double)4, 0); } static boolean testIS_DEFAULT(double a) { return bits(a)==0; @@ -3108,7 +3108,7 @@ static void blendDouble256VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") @@ -3143,7 +3143,7 @@ static void RearrangeDouble256VectorTestsMaskedSmokeTest(IntFunction f av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpProvider") static void getDouble256VectorTests(IntFunction fa) { @@ -3298,7 +3298,7 @@ static void getDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::get); + assertArraysEquals(r, a, Double256VectorTests::get); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3312,7 +3312,7 @@ static void BroadcastDouble256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3359,7 +3359,7 @@ static void sliceUnaryDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Double256VectorTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3388,7 +3388,7 @@ static void sliceBinaryDouble256VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, Double256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Double256VectorTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3421,7 +3421,7 @@ static void sliceDouble256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, mask, Double256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Double256VectorTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3448,7 +3448,7 @@ static void unsliceUnaryDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Double256VectorTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { double[] res = new double[SPECIES.length()]; @@ -3487,7 +3487,7 @@ static void unsliceBinaryDouble256VectorTestsBinary(IntFunction fa, In } } - assertArraysEquals(a, b, r, origin, part, Double256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Double256VectorTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3543,7 +3543,7 @@ static void unsliceDouble256VectorTestsMasked(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, mask, Double256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Double256VectorTests::unslice); } static double SIN(double a) { @@ -3566,7 +3566,7 @@ static void SINDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::SIN, Double256VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SIN, Double256VectorTests::strictSIN); } @@ -3590,7 +3590,7 @@ static void EXPDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::EXP, Double256VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXP, Double256VectorTests::strictEXP); } @@ -3614,7 +3614,7 @@ static void LOG1PDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::LOG1P, Double256VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG1P, Double256VectorTests::strictLOG1P); } @@ -3638,7 +3638,7 @@ static void LOGDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::LOG, Double256VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG, Double256VectorTests::strictLOG); } @@ -3662,7 +3662,7 @@ static void LOG10Double256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::LOG10, Double256VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG10, Double256VectorTests::strictLOG10); } @@ -3686,7 +3686,7 @@ static void EXPM1Double256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::EXPM1, Double256VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXPM1, Double256VectorTests::strictEXPM1); } @@ -3710,7 +3710,7 @@ static void COSDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::COS, Double256VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COS, Double256VectorTests::strictCOS); } @@ -3734,7 +3734,7 @@ static void TANDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::TAN, Double256VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TAN, Double256VectorTests::strictTAN); } @@ -3758,7 +3758,7 @@ static void SINHDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::SINH, Double256VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SINH, Double256VectorTests::strictSINH); } @@ -3782,7 +3782,7 @@ static void COSHDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::COSH, Double256VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COSH, Double256VectorTests::strictCOSH); } @@ -3806,7 +3806,7 @@ static void TANHDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::TANH, Double256VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TANH, Double256VectorTests::strictTANH); } @@ -3830,7 +3830,7 @@ static void ASINDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::ASIN, Double256VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ASIN, Double256VectorTests::strictASIN); } @@ -3854,7 +3854,7 @@ static void ACOSDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::ACOS, Double256VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ACOS, Double256VectorTests::strictACOS); } @@ -3878,7 +3878,7 @@ static void ATANDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::ATAN, Double256VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ATAN, Double256VectorTests::strictATAN); } @@ -3902,7 +3902,7 @@ static void CBRTDouble256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double256VectorTests::CBRT, Double256VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::CBRT, Double256VectorTests::strictCBRT); } @@ -3928,7 +3928,7 @@ static void HYPOTDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double256VectorTests::POW, Double256VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::POW, Double256VectorTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4037,7 +4037,7 @@ static void powDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double256VectorTests::pow, Double256VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::pow, Double256VectorTests::strictpow); } @@ -4073,7 +4073,7 @@ static void FMADouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4096,7 +4096,7 @@ static void fmaDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, mask, Double256VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA); } @@ -4145,7 +4145,7 @@ static void FMADouble256VectorTestsBroadcastSmokeTest(IntFunction fa, DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Double256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4160,7 +4160,7 @@ static void FMADouble256VectorTestsAltBroadcastSmokeTest(IntFunction f DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Double256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA); } @@ -4180,7 +4180,7 @@ static void FMADouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4245,7 +4245,7 @@ static void fmaDouble256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::NEG); + assertArraysEquals(r, a, Double256VectorTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4312,7 +4312,7 @@ static void negDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::neg); + assertArraysEquals(r, a, Double256VectorTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4330,7 +4330,7 @@ static void NEGMaskedDouble256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double256VectorTests::NEG); + assertArraysEquals(r, a, mask, Double256VectorTests::NEG); } static double ABS(double a) { @@ -4353,7 +4353,7 @@ static void ABSDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::ABS); + assertArraysEquals(r, a, Double256VectorTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4368,7 +4368,7 @@ static void absDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::abs); + assertArraysEquals(r, a, Double256VectorTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4386,7 +4386,7 @@ static void ABSMaskedDouble256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double256VectorTests::ABS); + assertArraysEquals(r, a, mask, Double256VectorTests::ABS); } @@ -4418,7 +4418,7 @@ static void SQRTDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::SQRT); + assertArraysEquals(r, a, Double256VectorTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4433,7 +4433,7 @@ static void sqrtDouble256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double256VectorTests::sqrt); + assertArraysEquals(r, a, Double256VectorTests::sqrt); } @@ -4453,7 +4453,7 @@ static void SQRTMaskedDouble256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double256VectorTests::SQRT); + assertArraysEquals(r, a, mask, Double256VectorTests::SQRT); } static double[] gather(double a[], int ix, int[] b, int iy) { @@ -4478,7 +4478,7 @@ static void gatherDouble256VectorTests(IntFunction fa, BiFunction fa, BiFunctio } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Double256VectorTests::gatherMasked); } static double[] scatter(double a[], int ix, int[] b, int iy) { @@ -4531,7 +4531,7 @@ static void scatterDouble256VectorTests(IntFunction fa, BiFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Double256VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Double256VectorTests::scatterMasked); } @@ -4611,8 +4611,8 @@ static void toIntArrayDouble256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4622,8 +4622,8 @@ static void toLongArrayDouble256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4690,7 +4690,7 @@ static void ADDReduceLongDouble256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Double256VectorTests::ADDReduceLong, Double256VectorTests::ADDReduceAllLong); } @@ -4731,7 +4731,7 @@ static void ADDReduceLongDouble256VectorTestsMasked(IntFunction fa, In ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Double256VectorTests::ADDReduceLongMasked, Double256VectorTests::ADDReduceAllLongMasked); } @@ -4743,7 +4743,7 @@ static void BroadcastLongDouble256VectorTestsSmokeTest(IntFunction fa) for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -4761,7 +4761,7 @@ static void blendDouble256VectorTestsBroadcastLongSmokeTest(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") @@ -4797,7 +4797,7 @@ static void SelectFromDouble256VectorTestsMaskedSmokeTest(IntFunction bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4874,7 +4874,7 @@ static void maskEqDouble256VectorTestsSmokeTest(IntFunction fa, IntFu var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Double256VectorTests::beq); + assertArraysEquals(r, a, b, Double256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java index 885730b8046..f2b75b847e0 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Double512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Double512VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Double512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(double[] a, double[] r, boolean[] mask) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0, "at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(double[] a, double[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "doubleProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new double[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index c35b5d7f2f6..86975ef14ee 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Double512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { double apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { double[] apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { double apply(double[] a); } - static void assertReductionArraysEquals(double[] a, double[] b, double c, + static void assertReductionArraysEquals(double[] r, double rc, double[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { double apply(double[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask, + static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(double[] a); } - static void assertReductionLongArraysEquals(double[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(double[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(double[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) { + static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boo } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertBroadcastArraysEquals(double[]a, double[]r) { + static void assertBroadcastArraysEquals(double[] r, double[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBin } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, bool } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, F } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, b } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(double actual, double expected) { return true; } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, } } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, F } } - static void assertBroadcastArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { double apply(double[] a, int b); } - static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { double[] apply(double[] a, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { + static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { double[] apply(double[] a, double[] b, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, F } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, b } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { double[] apply(double[] a, double[] b, int origin, int part, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(double[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(double[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1396,7 +1396,7 @@ static void ADDDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Double512VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1452,7 +1452,7 @@ static void addDouble512VectorTestsMasked(IntFunction fa, IntFunction< av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double512VectorTests::add); + assertArraysEquals(r, a, b, mask, Double512VectorTests::add); } static double SUB(double a, double b) { return (double)(a - b); @@ -1472,7 +1472,7 @@ static void SUBDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Double512VectorTests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1528,7 +1528,7 @@ static void subDouble512VectorTestsMasked(IntFunction fa, IntFunction< av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double512VectorTests::sub); + assertArraysEquals(r, a, b, mask, Double512VectorTests::sub); } static double MUL(double a, double b) { return (double)(a * b); @@ -1548,7 +1548,7 @@ static void MULDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Double512VectorTests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1604,7 +1604,7 @@ static void mulDouble512VectorTestsMasked(IntFunction fa, IntFunction< av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double512VectorTests::mul); + assertArraysEquals(r, a, b, mask, Double512VectorTests::mul); } static double DIV(double a, double b) { @@ -1625,7 +1625,7 @@ static void DIVDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Double512VectorTests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1683,7 +1683,7 @@ static void divDouble512VectorTestsMasked(IntFunction fa, IntFunction< av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Double512VectorTests::div); + assertArraysEquals(r, a, b, mask, Double512VectorTests::div); } @@ -1706,7 +1706,7 @@ static void FIRST_NONZERODouble512VectorTests(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, Double512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Double512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1726,7 +1726,7 @@ static void FIRST_NONZERODouble512VectorTestsMasked(IntFunction fa, In } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Double512VectorTests::FIRST_NONZERO); } @@ -1748,7 +1748,7 @@ static void addDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1765,7 +1765,7 @@ static void addDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1796,7 +1796,7 @@ static void subDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1827,7 +1827,7 @@ static void mulDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::div); } @@ -1861,7 +1861,7 @@ static void divDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Double512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Double512VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void ADDDouble512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void minDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2055,7 +2055,7 @@ static void MAXDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2069,7 +2069,7 @@ static void maxDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Double512VectorTests::max); } @@ -2121,7 +2121,7 @@ static void ADDReduceDouble512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double512VectorTests::ADDReduce, Double512VectorTests::ADDReduceAll); } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2165,7 +2165,7 @@ static void ADDReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double512VectorTests::ADDReduceMasked, Double512VectorTests::ADDReduceAllMasked); } static double MULReduce(double[] a, int idx) { @@ -2206,7 +2206,7 @@ static void MULReduceDouble512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double512VectorTests::MULReduce, Double512VectorTests::MULReduceAll); } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2250,7 +2250,7 @@ static void MULReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double512VectorTests::MULReduceMasked, Double512VectorTests::MULReduceAllMasked); } static double MINReduce(double[] a, int idx) { @@ -2291,7 +2291,7 @@ static void MINReduceDouble512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double512VectorTests::MINReduce, Double512VectorTests::MINReduceAll); } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2336,7 +2336,7 @@ static void MINReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double512VectorTests::MINReduceMasked, Double512VectorTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { @@ -2377,7 +2377,7 @@ static void MAXReduceDouble512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double512VectorTests::MAXReduce, Double512VectorTests::MAXReduceAll); } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2422,7 +2422,7 @@ static void MAXReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double512VectorTests::MAXReduceMasked, Double512VectorTests::MAXReduceAllMasked); } @@ -2442,7 +2442,7 @@ static void withDouble512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (double)4, 0); + assertInsertArraysEquals(r, a, (double)4, 0); } static boolean testIS_DEFAULT(double a) { return bits(a)==0; @@ -3108,7 +3108,7 @@ static void blendDouble512VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") @@ -3143,7 +3143,7 @@ static void RearrangeDouble512VectorTestsMaskedSmokeTest(IntFunction f av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpProvider") static void getDouble512VectorTests(IntFunction fa) { @@ -3298,7 +3298,7 @@ static void getDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::get); + assertArraysEquals(r, a, Double512VectorTests::get); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3312,7 +3312,7 @@ static void BroadcastDouble512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3359,7 +3359,7 @@ static void sliceUnaryDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Double512VectorTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3388,7 +3388,7 @@ static void sliceBinaryDouble512VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, Double512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Double512VectorTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3421,7 +3421,7 @@ static void sliceDouble512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, mask, Double512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Double512VectorTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3448,7 +3448,7 @@ static void unsliceUnaryDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Double512VectorTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { double[] res = new double[SPECIES.length()]; @@ -3487,7 +3487,7 @@ static void unsliceBinaryDouble512VectorTestsBinary(IntFunction fa, In } } - assertArraysEquals(a, b, r, origin, part, Double512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Double512VectorTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3543,7 +3543,7 @@ static void unsliceDouble512VectorTestsMasked(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, mask, Double512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Double512VectorTests::unslice); } static double SIN(double a) { @@ -3566,7 +3566,7 @@ static void SINDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::SIN, Double512VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::SIN, Double512VectorTests::strictSIN); } @@ -3590,7 +3590,7 @@ static void EXPDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::EXP, Double512VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::EXP, Double512VectorTests::strictEXP); } @@ -3614,7 +3614,7 @@ static void LOG1PDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG1P, Double512VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG1P, Double512VectorTests::strictLOG1P); } @@ -3638,7 +3638,7 @@ static void LOGDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG, Double512VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG, Double512VectorTests::strictLOG); } @@ -3662,7 +3662,7 @@ static void LOG10Double512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::LOG10, Double512VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG10, Double512VectorTests::strictLOG10); } @@ -3686,7 +3686,7 @@ static void EXPM1Double512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::EXPM1, Double512VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::EXPM1, Double512VectorTests::strictEXPM1); } @@ -3710,7 +3710,7 @@ static void COSDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::COS, Double512VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::COS, Double512VectorTests::strictCOS); } @@ -3734,7 +3734,7 @@ static void TANDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::TAN, Double512VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::TAN, Double512VectorTests::strictTAN); } @@ -3758,7 +3758,7 @@ static void SINHDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::SINH, Double512VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::SINH, Double512VectorTests::strictSINH); } @@ -3782,7 +3782,7 @@ static void COSHDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::COSH, Double512VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::COSH, Double512VectorTests::strictCOSH); } @@ -3806,7 +3806,7 @@ static void TANHDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::TANH, Double512VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::TANH, Double512VectorTests::strictTANH); } @@ -3830,7 +3830,7 @@ static void ASINDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ASIN, Double512VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ASIN, Double512VectorTests::strictASIN); } @@ -3854,7 +3854,7 @@ static void ACOSDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ACOS, Double512VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ACOS, Double512VectorTests::strictACOS); } @@ -3878,7 +3878,7 @@ static void ATANDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::ATAN, Double512VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ATAN, Double512VectorTests::strictATAN); } @@ -3902,7 +3902,7 @@ static void CBRTDouble512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double512VectorTests::CBRT, Double512VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::CBRT, Double512VectorTests::strictCBRT); } @@ -3928,7 +3928,7 @@ static void HYPOTDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double512VectorTests::POW, Double512VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::POW, Double512VectorTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4037,7 +4037,7 @@ static void powDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double512VectorTests::pow, Double512VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::pow, Double512VectorTests::strictpow); } @@ -4073,7 +4073,7 @@ static void FMADouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4096,7 +4096,7 @@ static void fmaDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, mask, Double512VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, Double512VectorTests::FMA); } @@ -4145,7 +4145,7 @@ static void FMADouble512VectorTestsBroadcastSmokeTest(IntFunction fa, DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Double512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Double512VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4160,7 +4160,7 @@ static void FMADouble512VectorTestsAltBroadcastSmokeTest(IntFunction f DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Double512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Double512VectorTests::FMA); } @@ -4180,7 +4180,7 @@ static void FMADouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4245,7 +4245,7 @@ static void fmaDouble512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::NEG); + assertArraysEquals(r, a, Double512VectorTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4312,7 +4312,7 @@ static void negDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::neg); + assertArraysEquals(r, a, Double512VectorTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4330,7 +4330,7 @@ static void NEGMaskedDouble512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double512VectorTests::NEG); + assertArraysEquals(r, a, mask, Double512VectorTests::NEG); } static double ABS(double a) { @@ -4353,7 +4353,7 @@ static void ABSDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::ABS); + assertArraysEquals(r, a, Double512VectorTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4368,7 +4368,7 @@ static void absDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::abs); + assertArraysEquals(r, a, Double512VectorTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4386,7 +4386,7 @@ static void ABSMaskedDouble512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double512VectorTests::ABS); + assertArraysEquals(r, a, mask, Double512VectorTests::ABS); } @@ -4418,7 +4418,7 @@ static void SQRTDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::SQRT); + assertArraysEquals(r, a, Double512VectorTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4433,7 +4433,7 @@ static void sqrtDouble512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double512VectorTests::sqrt); + assertArraysEquals(r, a, Double512VectorTests::sqrt); } @@ -4453,7 +4453,7 @@ static void SQRTMaskedDouble512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double512VectorTests::SQRT); + assertArraysEquals(r, a, mask, Double512VectorTests::SQRT); } static double[] gather(double a[], int ix, int[] b, int iy) { @@ -4478,7 +4478,7 @@ static void gatherDouble512VectorTests(IntFunction fa, BiFunction fa, BiFunctio } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Double512VectorTests::gatherMasked); } static double[] scatter(double a[], int ix, int[] b, int iy) { @@ -4531,7 +4531,7 @@ static void scatterDouble512VectorTests(IntFunction fa, BiFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Double512VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Double512VectorTests::scatterMasked); } @@ -4611,8 +4611,8 @@ static void toIntArrayDouble512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4622,8 +4622,8 @@ static void toLongArrayDouble512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4690,7 +4690,7 @@ static void ADDReduceLongDouble512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Double512VectorTests::ADDReduceLong, Double512VectorTests::ADDReduceAllLong); } @@ -4731,7 +4731,7 @@ static void ADDReduceLongDouble512VectorTestsMasked(IntFunction fa, In ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Double512VectorTests::ADDReduceLongMasked, Double512VectorTests::ADDReduceAllLongMasked); } @@ -4743,7 +4743,7 @@ static void BroadcastLongDouble512VectorTestsSmokeTest(IntFunction fa) for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -4761,7 +4761,7 @@ static void blendDouble512VectorTestsBroadcastLongSmokeTest(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") @@ -4797,7 +4797,7 @@ static void SelectFromDouble512VectorTestsMaskedSmokeTest(IntFunction bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4874,7 +4874,7 @@ static void maskEqDouble512VectorTestsSmokeTest(IntFunction fa, IntFu var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Double512VectorTests::beq); + assertArraysEquals(r, a, b, Double512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java index d2b565c4837..2716064a781 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Double64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Double64VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Double64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(double[] a, double[] r, boolean[] mask) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0, "at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(double[] a, double[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "doubleProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new double[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index 9171f06b6ef..a4c21b5ff98 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Double64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { double apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { double[] apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { double apply(double[] a); } - static void assertReductionArraysEquals(double[] a, double[] b, double c, + static void assertReductionArraysEquals(double[] r, double rc, double[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { double apply(double[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask, + static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(double[] a); } - static void assertReductionLongArraysEquals(double[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(double[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(double[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) { + static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boo } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertBroadcastArraysEquals(double[]a, double[]r) { + static void assertBroadcastArraysEquals(double[] r, double[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBin } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, bool } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, F } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, b } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(double actual, double expected) { return true; } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, } } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, F } } - static void assertBroadcastArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { double apply(double[] a, int b); } - static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { double[] apply(double[] a, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { + static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { double[] apply(double[] a, double[] b, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, F } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, b } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { double[] apply(double[] a, double[] b, int origin, int part, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(double[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(double[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1396,7 +1396,7 @@ static void ADDDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, Double64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Double64VectorTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1726,7 +1726,7 @@ static void FIRST_NONZERODouble64VectorTestsMasked(IntFunction fa, Int } } - assertArraysEquals(a, b, r, mask, Double64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Double64VectorTests::FIRST_NONZERO); } @@ -1748,7 +1748,7 @@ static void addDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1765,7 +1765,7 @@ static void addDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::add); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1779,7 +1779,7 @@ static void subDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1796,7 +1796,7 @@ static void subDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1810,7 +1810,7 @@ static void mulDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1827,7 +1827,7 @@ static void mulDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::mul); } @@ -1842,7 +1842,7 @@ static void divDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::div); } @@ -1861,7 +1861,7 @@ static void divDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::div); } @@ -1884,7 +1884,7 @@ static void ADDDouble64VectorTestsBroadcastLongSmokeTest(IntFunction f av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Double64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Double64VectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void ADDDouble64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void minDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2055,7 +2055,7 @@ static void MAXDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2069,7 +2069,7 @@ static void maxDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Double64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Double64VectorTests::max); } @@ -2121,7 +2121,7 @@ static void ADDReduceDouble64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double64VectorTests::ADDReduce, Double64VectorTests::ADDReduceAll); } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2165,7 +2165,7 @@ static void ADDReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double64VectorTests::ADDReduceMasked, Double64VectorTests::ADDReduceAllMasked); } static double MULReduce(double[] a, int idx) { @@ -2206,7 +2206,7 @@ static void MULReduceDouble64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double64VectorTests::MULReduce, Double64VectorTests::MULReduceAll); } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2250,7 +2250,7 @@ static void MULReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double64VectorTests::MULReduceMasked, Double64VectorTests::MULReduceAllMasked); } static double MINReduce(double[] a, int idx) { @@ -2291,7 +2291,7 @@ static void MINReduceDouble64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double64VectorTests::MINReduce, Double64VectorTests::MINReduceAll); } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2336,7 +2336,7 @@ static void MINReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double64VectorTests::MINReduceMasked, Double64VectorTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { @@ -2377,7 +2377,7 @@ static void MAXReduceDouble64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Double64VectorTests::MAXReduce, Double64VectorTests::MAXReduceAll); } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2422,7 +2422,7 @@ static void MAXReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Double64VectorTests::MAXReduceMasked, Double64VectorTests::MAXReduceAllMasked); } @@ -2442,7 +2442,7 @@ static void withDouble64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (double)4, 0); + assertInsertArraysEquals(r, a, (double)4, 0); } static boolean testIS_DEFAULT(double a) { return bits(a)==0; @@ -3108,7 +3108,7 @@ static void blendDouble64VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") @@ -3143,7 +3143,7 @@ static void RearrangeDouble64VectorTestsMaskedSmokeTest(IntFunction fa av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpProvider") static void getDouble64VectorTests(IntFunction fa) { @@ -3298,7 +3298,7 @@ static void getDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::get); + assertArraysEquals(r, a, Double64VectorTests::get); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3312,7 +3312,7 @@ static void BroadcastDouble64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3359,7 +3359,7 @@ static void sliceUnaryDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Double64VectorTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3388,7 +3388,7 @@ static void sliceBinaryDouble64VectorTestsBinary(IntFunction fa, IntFu } } - assertArraysEquals(a, b, r, origin, Double64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Double64VectorTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3421,7 +3421,7 @@ static void sliceDouble64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, origin, mask, Double64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Double64VectorTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3448,7 +3448,7 @@ static void unsliceUnaryDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Double64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Double64VectorTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { double[] res = new double[SPECIES.length()]; @@ -3487,7 +3487,7 @@ static void unsliceBinaryDouble64VectorTestsBinary(IntFunction fa, Int } } - assertArraysEquals(a, b, r, origin, part, Double64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Double64VectorTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3543,7 +3543,7 @@ static void unsliceDouble64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, origin, part, mask, Double64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Double64VectorTests::unslice); } static double SIN(double a) { @@ -3566,7 +3566,7 @@ static void SINDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::SIN, Double64VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::SIN, Double64VectorTests::strictSIN); } @@ -3590,7 +3590,7 @@ static void EXPDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::EXP, Double64VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::EXP, Double64VectorTests::strictEXP); } @@ -3614,7 +3614,7 @@ static void LOG1PDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::LOG1P, Double64VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG1P, Double64VectorTests::strictLOG1P); } @@ -3638,7 +3638,7 @@ static void LOGDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::LOG, Double64VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG, Double64VectorTests::strictLOG); } @@ -3662,7 +3662,7 @@ static void LOG10Double64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::LOG10, Double64VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG10, Double64VectorTests::strictLOG10); } @@ -3686,7 +3686,7 @@ static void EXPM1Double64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::EXPM1, Double64VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::EXPM1, Double64VectorTests::strictEXPM1); } @@ -3710,7 +3710,7 @@ static void COSDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::COS, Double64VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::COS, Double64VectorTests::strictCOS); } @@ -3734,7 +3734,7 @@ static void TANDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::TAN, Double64VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::TAN, Double64VectorTests::strictTAN); } @@ -3758,7 +3758,7 @@ static void SINHDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::SINH, Double64VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::SINH, Double64VectorTests::strictSINH); } @@ -3782,7 +3782,7 @@ static void COSHDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::COSH, Double64VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::COSH, Double64VectorTests::strictCOSH); } @@ -3806,7 +3806,7 @@ static void TANHDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::TANH, Double64VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::TANH, Double64VectorTests::strictTANH); } @@ -3830,7 +3830,7 @@ static void ASINDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::ASIN, Double64VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ASIN, Double64VectorTests::strictASIN); } @@ -3854,7 +3854,7 @@ static void ACOSDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::ACOS, Double64VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ACOS, Double64VectorTests::strictACOS); } @@ -3878,7 +3878,7 @@ static void ATANDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::ATAN, Double64VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ATAN, Double64VectorTests::strictATAN); } @@ -3902,7 +3902,7 @@ static void CBRTDouble64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Double64VectorTests::CBRT, Double64VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::CBRT, Double64VectorTests::strictCBRT); } @@ -3928,7 +3928,7 @@ static void HYPOTDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double64VectorTests::POW, Double64VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::POW, Double64VectorTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4037,7 +4037,7 @@ static void powDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, I av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Double64VectorTests::pow, Double64VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::pow, Double64VectorTests::strictpow); } @@ -4073,7 +4073,7 @@ static void FMADouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4096,7 +4096,7 @@ static void fmaDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, I DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Double64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4160,7 +4160,7 @@ static void FMADouble64VectorTestsAltBroadcastSmokeTest(IntFunction fa DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Double64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); } @@ -4180,7 +4180,7 @@ static void FMADouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, Double64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, Double64VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") @@ -4199,7 +4199,7 @@ static void FMADouble64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Double64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") static void fmaDouble64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4245,7 +4245,7 @@ static void fmaDouble64VectorTestsDoubleBroadcastSmokeTest(IntFunction av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Double64VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, Double64VectorTests::fma); } @@ -4271,7 +4271,7 @@ static void FMADouble64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::NEG); + assertArraysEquals(r, a, Double64VectorTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4312,7 +4312,7 @@ static void negDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::neg); + assertArraysEquals(r, a, Double64VectorTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4330,7 +4330,7 @@ static void NEGMaskedDouble64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double64VectorTests::NEG); + assertArraysEquals(r, a, mask, Double64VectorTests::NEG); } static double ABS(double a) { @@ -4353,7 +4353,7 @@ static void ABSDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::ABS); + assertArraysEquals(r, a, Double64VectorTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4368,7 +4368,7 @@ static void absDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::abs); + assertArraysEquals(r, a, Double64VectorTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4386,7 +4386,7 @@ static void ABSMaskedDouble64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double64VectorTests::ABS); + assertArraysEquals(r, a, mask, Double64VectorTests::ABS); } @@ -4418,7 +4418,7 @@ static void SQRTDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::SQRT); + assertArraysEquals(r, a, Double64VectorTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4433,7 +4433,7 @@ static void sqrtDouble64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Double64VectorTests::sqrt); + assertArraysEquals(r, a, Double64VectorTests::sqrt); } @@ -4453,7 +4453,7 @@ static void SQRTMaskedDouble64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Double64VectorTests::SQRT); + assertArraysEquals(r, a, mask, Double64VectorTests::SQRT); } static double[] gather(double a[], int ix, int[] b, int iy) { @@ -4478,7 +4478,7 @@ static void gatherDouble64VectorTests(IntFunction fa, BiFunction fa, BiFunction } } - assertArraysEquals(a, b, r, mask, Double64VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Double64VectorTests::gatherMasked); } static double[] scatter(double a[], int ix, int[] b, int iy) { @@ -4531,7 +4531,7 @@ static void scatterDouble64VectorTests(IntFunction fa, BiFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, mask, Double64VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Double64VectorTests::scatterMasked); } @@ -4611,8 +4611,8 @@ static void toIntArrayDouble64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4622,8 +4622,8 @@ static void toLongArrayDouble64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4690,7 +4690,7 @@ static void ADDReduceLongDouble64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Double64VectorTests::ADDReduceLong, Double64VectorTests::ADDReduceAllLong); } @@ -4731,7 +4731,7 @@ static void ADDReduceLongDouble64VectorTestsMasked(IntFunction fa, Int ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Double64VectorTests::ADDReduceLongMasked, Double64VectorTests::ADDReduceAllLongMasked); } @@ -4743,7 +4743,7 @@ static void BroadcastLongDouble64VectorTestsSmokeTest(IntFunction fa) for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -4761,7 +4761,7 @@ static void blendDouble64VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Double64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Double64VectorTests::blend); } @@ -4778,7 +4778,7 @@ static void SelectFromDouble64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") @@ -4797,7 +4797,7 @@ static void SelectFromDouble64VectorTestsMaskedSmokeTest(IntFunction f bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4874,7 +4874,7 @@ static void maskEqDouble64VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Double64VectorTests::beq); + assertArraysEquals(r, a, b, Double64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java index 289e8780a42..0e0a66f2bd7 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * DoubleMaxVectorLoadStoreTests + * -XX:-TieredCompilation DoubleMaxVectorLoadStoreTests * */ @@ -67,47 +67,25 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(double[] a, double[] r, boolean[] mask) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (double) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (double) 0, "at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(double[] a, double[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (double) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -410,7 +388,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "doubleProviderForIOOBE") @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new double[a.length]; @@ -492,7 +470,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleMaskProviderForIOOBE") @@ -565,7 +543,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -589,7 +567,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -676,7 +654,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -691,7 +669,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -807,7 +785,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "doubleByteProviderForIOOBE") @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -899,7 +877,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "doubleByteMaskProviderForIOOBE") @@ -976,7 +954,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -987,7 +965,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index d45d8cade27..dbe35d51b22 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch DoubleMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation DoubleMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { double apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { double[] apply(double a); } - static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(double[] a, double[] r, FUnArrayOp f) { } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(double[] a, double[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { double apply(double[] a); } - static void assertReductionArraysEquals(double[] a, double[] b, double c, + static void assertReductionArraysEquals(double[] r, double rc, double[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { double apply(double[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(double[] a, double[] b, double c, boolean[] mask, + static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -167,17 +167,17 @@ interface FReductionAllOpLong { long apply(double[] a); } - static void assertReductionLongArraysEquals(double[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -189,17 +189,17 @@ interface FReductionAllMaskedOpLong { long apply(double[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(double[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -207,37 +207,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(double[] a, double[] b, double element, int index) { + static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -251,7 +251,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, int } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -265,7 +265,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -285,7 +285,7 @@ static void assertRearrangeArraysEquals(double[] a, double[] r, int[] order, boo } } - static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -305,7 +305,7 @@ static void assertSelectFromArraysEquals(double[] a, double[] r, double[] order, } } - static void assertBroadcastArraysEquals(double[]a, double[]r) { + static void assertBroadcastArraysEquals(double[] r, double[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -334,7 +334,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -345,7 +345,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -357,7 +357,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, FBin } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -369,11 +369,11 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -384,11 +384,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -402,11 +402,11 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, bool } } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -420,7 +420,7 @@ static void assertBroadcastLongArraysEquals(double[] a, double[] b, double[] r, } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -434,11 +434,11 @@ static void assertShiftArraysEquals(double[] a, double[] b, double[] r, FBinOp f } } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -464,7 +464,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -475,11 +475,11 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, F } } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -491,7 +491,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] c, double[] r, b } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -504,7 +504,7 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,12 +517,12 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -538,12 +538,12 @@ static void assertBroadcastArraysEquals(double[] a, double[] b, double[] c, doub } } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ static void assertAltBroadcastArraysEquals(double[] a, double[] b, double[] c, d } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,12 +574,12 @@ static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c } } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(double[] a, double[] b, double[] c, double[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b, double[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -618,7 +618,7 @@ static boolean isWithin1Ulp(double actual, double expected) { return true; } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -632,7 +632,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] r, FUnOp mathf, } } - static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -646,7 +646,7 @@ static void assertArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, F } } - static void assertBroadcastArraysEqualsWithinOneUlp(double[] a, double[] b, double[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -676,7 +676,7 @@ interface FBinArrayOp { double apply(double[] a, int b); } - static void assertArraysEquals(double[] a, double[] r, FBinArrayOp f) { + static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -691,7 +691,7 @@ interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, FGatherScatterOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -718,7 +718,7 @@ interface FScatterMaskedOp { double[] apply(double[] r, double[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -728,7 +728,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -739,7 +739,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } } - static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -749,7 +749,7 @@ static void assertArraysEquals(double[] a, int[] b, double[] r, boolean[] mask, } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -766,7 +766,7 @@ interface FLaneOp { double[] apply(double[] a, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { + static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -776,7 +776,7 @@ static void assertArraysEquals(double[] a, double[] r, int origin, FLaneOp f) { } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -786,7 +786,7 @@ interface FLaneBop { double[] apply(double[] a, double[] b, int origin, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, FLaneBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -796,7 +796,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, F } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -807,7 +807,7 @@ interface FLaneMaskedBop { double[] apply(double[] a, double[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -817,7 +817,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, b } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -828,7 +828,7 @@ interface FLanePartBop { double[] apply(double[] a, double[] b, int origin, int part, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -838,7 +838,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -850,7 +850,7 @@ interface FLanePartMaskedBop { double[] apply(double[] a, double[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -860,7 +860,7 @@ static void assertArraysEquals(double[] a, double[] b, double[] r, int origin, i } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -902,7 +902,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(double[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -948,7 +948,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(double[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1401,7 +1401,7 @@ static void ADDDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1457,7 +1457,7 @@ static void addDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction< av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add); } static double SUB(double a, double b) { return (double)(a - b); @@ -1477,7 +1477,7 @@ static void SUBDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1533,7 +1533,7 @@ static void subDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction< av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub); } static double MUL(double a, double b) { return (double)(a * b); @@ -1553,7 +1553,7 @@ static void MULDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1609,7 +1609,7 @@ static void mulDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction< av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul); } static double DIV(double a, double b) { @@ -1630,7 +1630,7 @@ static void DIVDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1688,7 +1688,7 @@ static void divDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction< av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div); } @@ -1711,7 +1711,7 @@ static void FIRST_NONZERODoubleMaxVectorTests(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, DoubleMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1731,7 +1731,7 @@ static void FIRST_NONZERODoubleMaxVectorTestsMasked(IntFunction fa, In } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::FIRST_NONZERO); } @@ -1753,7 +1753,7 @@ static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1770,7 +1770,7 @@ static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1801,7 +1801,7 @@ static void subDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1832,7 +1832,7 @@ static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::div); } @@ -1866,7 +1866,7 @@ static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, DoubleMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleMaxVectorTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -1906,7 +1906,7 @@ static void ADDDoubleMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2046,7 +2046,7 @@ static void minDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2060,7 +2060,7 @@ static void MAXDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2074,7 +2074,7 @@ static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::max); } @@ -2126,7 +2126,7 @@ static void ADDReduceDoubleMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll); } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2170,7 +2170,7 @@ static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked); } static double MULReduce(double[] a, int idx) { @@ -2211,7 +2211,7 @@ static void MULReduceDoubleMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll); } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2255,7 +2255,7 @@ static void MULReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked); } static double MINReduce(double[] a, int idx) { @@ -2296,7 +2296,7 @@ static void MINReduceDoubleMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, DoubleMaxVectorTests::MINReduce, DoubleMaxVectorTests::MINReduceAll); } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2341,7 +2341,7 @@ static void MINReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, DoubleMaxVectorTests::MINReduceMasked, DoubleMaxVectorTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { @@ -2382,7 +2382,7 @@ static void MAXReduceDoubleMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, DoubleMaxVectorTests::MAXReduce, DoubleMaxVectorTests::MAXReduceAll); } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { @@ -2427,7 +2427,7 @@ static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, DoubleMaxVectorTests::MAXReduceMasked, DoubleMaxVectorTests::MAXReduceAllMasked); } @@ -2447,7 +2447,7 @@ static void withDoubleMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (double)4, 0); + assertInsertArraysEquals(r, a, (double)4, 0); } static boolean testIS_DEFAULT(double a) { return bits(a)==0; @@ -3113,7 +3113,7 @@ static void blendDoubleMaxVectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") @@ -3148,7 +3148,7 @@ static void RearrangeDoubleMaxVectorTestsMaskedSmokeTest(IntFunction f av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpProvider") static void getDoubleMaxVectorTests(IntFunction fa) { @@ -3303,7 +3303,7 @@ static void getDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::get); + assertArraysEquals(r, a, DoubleMaxVectorTests::get); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3317,7 +3317,7 @@ static void BroadcastDoubleMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3364,7 +3364,7 @@ static void sliceUnaryDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, DoubleMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleMaxVectorTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3393,7 +3393,7 @@ static void sliceBinaryDoubleMaxVectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, DoubleMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleMaxVectorTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3426,7 +3426,7 @@ static void sliceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, mask, DoubleMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleMaxVectorTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { double[] res = new double[SPECIES.length()]; @@ -3453,7 +3453,7 @@ static void unsliceUnaryDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, DoubleMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleMaxVectorTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { double[] res = new double[SPECIES.length()]; @@ -3492,7 +3492,7 @@ static void unsliceBinaryDoubleMaxVectorTestsBinary(IntFunction fa, In } } - assertArraysEquals(a, b, r, origin, part, DoubleMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleMaxVectorTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { double[] res = new double[SPECIES.length()]; @@ -3548,7 +3548,7 @@ static void unsliceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, mask, DoubleMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleMaxVectorTests::unslice); } static double SIN(double a) { @@ -3571,7 +3571,7 @@ static void SINDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN); } @@ -3595,7 +3595,7 @@ static void EXPDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP); } @@ -3619,7 +3619,7 @@ static void LOG1PDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P); } @@ -3643,7 +3643,7 @@ static void LOGDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG); } @@ -3667,7 +3667,7 @@ static void LOG10DoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10); } @@ -3691,7 +3691,7 @@ static void EXPM1DoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1); } @@ -3715,7 +3715,7 @@ static void COSDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS); } @@ -3739,7 +3739,7 @@ static void TANDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN); } @@ -3763,7 +3763,7 @@ static void SINHDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH); } @@ -3787,7 +3787,7 @@ static void COSHDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH); } @@ -3811,7 +3811,7 @@ static void TANHDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH); } @@ -3835,7 +3835,7 @@ static void ASINDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN); } @@ -3859,7 +3859,7 @@ static void ACOSDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS); } @@ -3883,7 +3883,7 @@ static void ATANDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN); } @@ -3907,7 +3907,7 @@ static void CBRTDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT); } @@ -3933,7 +3933,7 @@ static void HYPOTDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4042,7 +4042,7 @@ static void powDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow); } @@ -4078,7 +4078,7 @@ static void FMADoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4101,7 +4101,7 @@ static void fmaDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, mask, DoubleMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA); } @@ -4150,7 +4150,7 @@ static void FMADoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, DoubleMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4165,7 +4165,7 @@ static void FMADoubleMaxVectorTestsAltBroadcastSmokeTest(IntFunction f DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, DoubleMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); } @@ -4185,7 +4185,7 @@ static void FMADoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4250,7 +4250,7 @@ static void fmaDoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::NEG); + assertArraysEquals(r, a, DoubleMaxVectorTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4317,7 +4317,7 @@ static void negDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::neg); + assertArraysEquals(r, a, DoubleMaxVectorTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4335,7 +4335,7 @@ static void NEGMaskedDoubleMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, DoubleMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleMaxVectorTests::NEG); } static double ABS(double a) { @@ -4358,7 +4358,7 @@ static void ABSDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::ABS); + assertArraysEquals(r, a, DoubleMaxVectorTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4373,7 +4373,7 @@ static void absDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::abs); + assertArraysEquals(r, a, DoubleMaxVectorTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") @@ -4391,7 +4391,7 @@ static void ABSMaskedDoubleMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, DoubleMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleMaxVectorTests::ABS); } @@ -4423,7 +4423,7 @@ static void SQRTDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::SQRT); + assertArraysEquals(r, a, DoubleMaxVectorTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4438,7 +4438,7 @@ static void sqrtDoubleMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, DoubleMaxVectorTests::sqrt); + assertArraysEquals(r, a, DoubleMaxVectorTests::sqrt); } @@ -4458,7 +4458,7 @@ static void SQRTMaskedDoubleMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, DoubleMaxVectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT); } static double[] gather(double a[], int ix, int[] b, int iy) { @@ -4483,7 +4483,7 @@ static void gatherDoubleMaxVectorTests(IntFunction fa, BiFunction fa, BiFunctio } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::gatherMasked); } static double[] scatter(double a[], int ix, int[] b, int iy) { @@ -4536,7 +4536,7 @@ static void scatterDoubleMaxVectorTests(IntFunction fa, BiFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, DoubleMaxVectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::scatterMasked); } @@ -4616,8 +4616,8 @@ static void toIntArrayDoubleMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4627,8 +4627,8 @@ static void toLongArrayDoubleMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4695,7 +4695,7 @@ static void ADDReduceLongDoubleMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, DoubleMaxVectorTests::ADDReduceLong, DoubleMaxVectorTests::ADDReduceAllLong); } @@ -4736,7 +4736,7 @@ static void ADDReduceLongDoubleMaxVectorTestsMasked(IntFunction fa, In ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, DoubleMaxVectorTests::ADDReduceLongMasked, DoubleMaxVectorTests::ADDReduceAllLongMasked); } @@ -4748,7 +4748,7 @@ static void BroadcastLongDoubleMaxVectorTestsSmokeTest(IntFunction fa) for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "doubleBinaryOpMaskProvider") @@ -4766,7 +4766,7 @@ static void blendDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") @@ -4802,7 +4802,7 @@ static void SelectFromDoubleMaxVectorTestsMaskedSmokeTest(IntFunction bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4879,7 +4879,7 @@ static void maskEqDoubleMaxVectorTestsSmokeTest(IntFunction fa, IntFu var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, DoubleMaxVectorTests::beq); + assertArraysEquals(r, a, b, DoubleMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java index 0f6a15a60f6..c8b847b3fbe 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Float128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Float128VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Float128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(float[] a, float[] r, boolean[] mask) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0, "at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(float[] a, float[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "floatProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new float[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index 753a5f5a96c..3f2e01c0343 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Float128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { float apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { float[] apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { float apply(float[] a); } - static void assertReductionArraysEquals(float[] a, float[] b, float c, + static void assertReductionArraysEquals(float[] r, float rc, float[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { float apply(float[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(float[] a, float[] b, float c, boolean[] mask, + static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(float[] a); } - static void assertReductionLongArraysEquals(float[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(float[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(float[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) { + static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, in } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, bo } } - static void assertBroadcastArraysEquals(float[]a, float[]r) { + static void assertBroadcastArraysEquals(float[] r, float[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBi } } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boo } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTern } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boole } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, f } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(float actual, float expected) { return true; } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FU } } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBin } } - static void assertBroadcastArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { float apply(float[] a, int b); } - static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FS } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { float[] apply(float[] a, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { + static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { float[] apply(float[] a, float[] b, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLaneBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLan } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, bool } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { float[] apply(float[] a, float[] b, int origin, int part, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(float[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(float[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -954,7 +954,7 @@ static void assertArraysEquals(float[] a, long[] r, int offs) { } } - static void assertArraysEquals(float[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1406,7 +1406,7 @@ static void ADDFloat128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::ADD); + assertArraysEquals(r, a, b, Float128VectorTests::ADD); } static float add(float a, float b) { return (float)(a + b); @@ -1424,7 +1424,7 @@ static void addFloat128VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::add); + assertArraysEquals(r, a, b, Float128VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void ADDFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::SUB); + assertArraysEquals(r, a, b, Float128VectorTests::SUB); } static float sub(float a, float b) { return (float)(a - b); @@ -1500,7 +1500,7 @@ static void subFloat128VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::sub); + assertArraysEquals(r, a, b, Float128VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1520,7 +1520,7 @@ static void SUBFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::MUL); + assertArraysEquals(r, a, b, Float128VectorTests::MUL); } static float mul(float a, float b) { return (float)(a * b); @@ -1576,7 +1576,7 @@ static void mulFloat128VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::mul); + assertArraysEquals(r, a, b, Float128VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1596,7 +1596,7 @@ static void MULFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::DIV); + assertArraysEquals(r, a, b, Float128VectorTests::DIV); } static float div(float a, float b) { return (float)(a / b); @@ -1653,7 +1653,7 @@ static void divFloat128VectorTests(IntFunction fa, IntFunction av.div(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::div); + assertArraysEquals(r, a, b, Float128VectorTests::div); } @@ -1675,7 +1675,7 @@ static void DIVFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Float128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Float128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1736,7 +1736,7 @@ static void FIRST_NONZEROFloat128VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Float128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Float128VectorTests::FIRST_NONZERO); } @@ -1758,7 +1758,7 @@ static void addFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1775,7 +1775,7 @@ static void addFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::add); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1789,7 +1789,7 @@ static void subFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1806,7 +1806,7 @@ static void subFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1820,7 +1820,7 @@ static void mulFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1837,7 +1837,7 @@ static void mulFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::mul); } @@ -1852,7 +1852,7 @@ static void divFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::div); } @@ -1871,7 +1871,7 @@ static void divFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::div); } @@ -1894,7 +1894,7 @@ static void ADDFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Float128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Float128VectorTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1911,7 +1911,7 @@ static void ADDFloat128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::MIN); + assertArraysEquals(r, a, b, Float128VectorTests::MIN); } static float min(float a, float b) { return (float)(Math.min(a, b)); @@ -1985,7 +1985,7 @@ static void minFloat128VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::min); + assertArraysEquals(r, a, b, Float128VectorTests::min); } static float MAX(float a, float b) { return (float)(Math.max(a, b)); @@ -2005,7 +2005,7 @@ static void MAXFloat128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float128VectorTests::MAX); + assertArraysEquals(r, a, b, Float128VectorTests::MAX); } static float max(float a, float b) { return (float)(Math.max(a, b)); @@ -2023,7 +2023,7 @@ static void maxFloat128VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::max); + assertArraysEquals(r, a, b, Float128VectorTests::max); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2037,7 +2037,7 @@ static void MINFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2051,7 +2051,7 @@ static void minFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::min); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2065,7 +2065,7 @@ static void MAXFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2079,7 +2079,7 @@ static void maxFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Float128VectorTests::max); } @@ -2131,7 +2131,7 @@ static void ADDReduceFloat128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float128VectorTests::ADDReduce, Float128VectorTests::ADDReduceAll); } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2175,7 +2175,7 @@ static void ADDReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float128VectorTests::ADDReduceMasked, Float128VectorTests::ADDReduceAllMasked); } static float MULReduce(float[] a, int idx) { @@ -2216,7 +2216,7 @@ static void MULReduceFloat128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float128VectorTests::MULReduce, Float128VectorTests::MULReduceAll); } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2260,7 +2260,7 @@ static void MULReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float128VectorTests::MULReduceMasked, Float128VectorTests::MULReduceAllMasked); } static float MINReduce(float[] a, int idx) { @@ -2301,7 +2301,7 @@ static void MINReduceFloat128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float128VectorTests::MINReduce, Float128VectorTests::MINReduceAll); } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2346,7 +2346,7 @@ static void MINReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float128VectorTests::MINReduceMasked, Float128VectorTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { @@ -2387,7 +2387,7 @@ static void MAXReduceFloat128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float128VectorTests::MAXReduce, Float128VectorTests::MAXReduceAll); } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2432,7 +2432,7 @@ static void MAXReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float128VectorTests::MAXReduceMasked, Float128VectorTests::MAXReduceAllMasked); } @@ -2452,7 +2452,7 @@ static void withFloat128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (float)4, 0); + assertInsertArraysEquals(r, a, (float)4, 0); } static boolean testIS_DEFAULT(float a) { return bits(a)==0; @@ -3118,7 +3118,7 @@ static void blendFloat128VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") @@ -3153,7 +3153,7 @@ static void RearrangeFloat128VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpProvider") static void getFloat128VectorTests(IntFunction fa) { @@ -3308,7 +3308,7 @@ static void getFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::get); + assertArraysEquals(r, a, Float128VectorTests::get); } @Test(dataProvider = "floatUnaryOpProvider") @@ -3322,7 +3322,7 @@ static void BroadcastFloat128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3369,7 +3369,7 @@ static void sliceUnaryFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Float128VectorTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3398,7 +3398,7 @@ static void sliceBinaryFloat128VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Float128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Float128VectorTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3431,7 +3431,7 @@ static void sliceFloat128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Float128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Float128VectorTests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3458,7 +3458,7 @@ static void unsliceUnaryFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Float128VectorTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { float[] res = new float[SPECIES.length()]; @@ -3497,7 +3497,7 @@ static void unsliceBinaryFloat128VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Float128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Float128VectorTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3553,7 +3553,7 @@ static void unsliceFloat128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Float128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Float128VectorTests::unslice); } static float SIN(float a) { @@ -3576,7 +3576,7 @@ static void SINFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::SIN, Float128VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SIN, Float128VectorTests::strictSIN); } @@ -3600,7 +3600,7 @@ static void EXPFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::EXP, Float128VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXP, Float128VectorTests::strictEXP); } @@ -3624,7 +3624,7 @@ static void LOG1PFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::LOG1P, Float128VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG1P, Float128VectorTests::strictLOG1P); } @@ -3648,7 +3648,7 @@ static void LOGFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::LOG, Float128VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG, Float128VectorTests::strictLOG); } @@ -3672,7 +3672,7 @@ static void LOG10Float128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::LOG10, Float128VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG10, Float128VectorTests::strictLOG10); } @@ -3696,7 +3696,7 @@ static void EXPM1Float128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::EXPM1, Float128VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXPM1, Float128VectorTests::strictEXPM1); } @@ -3720,7 +3720,7 @@ static void COSFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::COS, Float128VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COS, Float128VectorTests::strictCOS); } @@ -3744,7 +3744,7 @@ static void TANFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::TAN, Float128VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TAN, Float128VectorTests::strictTAN); } @@ -3768,7 +3768,7 @@ static void SINHFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::SINH, Float128VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SINH, Float128VectorTests::strictSINH); } @@ -3792,7 +3792,7 @@ static void COSHFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::COSH, Float128VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COSH, Float128VectorTests::strictCOSH); } @@ -3816,7 +3816,7 @@ static void TANHFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::TANH, Float128VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TANH, Float128VectorTests::strictTANH); } @@ -3840,7 +3840,7 @@ static void ASINFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::ASIN, Float128VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ASIN, Float128VectorTests::strictASIN); } @@ -3864,7 +3864,7 @@ static void ACOSFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::ACOS, Float128VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ACOS, Float128VectorTests::strictACOS); } @@ -3888,7 +3888,7 @@ static void ATANFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::ATAN, Float128VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ATAN, Float128VectorTests::strictATAN); } @@ -3912,7 +3912,7 @@ static void CBRTFloat128VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float128VectorTests::CBRT, Float128VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::CBRT, Float128VectorTests::strictCBRT); } @@ -3938,7 +3938,7 @@ static void HYPOTFloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float128VectorTests::POW, Float128VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW); } static float pow(float a, float b) { @@ -3990,7 +3990,7 @@ static void powFloat128VectorTests(IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float128VectorTests::pow, Float128VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow); } @@ -4017,7 +4017,7 @@ static void ATAN2Float128VectorTests(IntFunction fa, IntFunction fa, In av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float128VectorTests::POW, Float128VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4047,7 +4047,7 @@ static void powFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float128VectorTests::pow, Float128VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow); } @@ -4076,7 +4076,7 @@ static void FMAFloat128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, Float128VectorTests::FMA); + assertArraysEquals(r, a, b, c, Float128VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4092,7 +4092,7 @@ static void fmaFloat128VectorTests(IntFunction fa, IntFunction av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Float128VectorTests::fma); + assertArraysEquals(r, a, b, c, Float128VectorTests::fma); } @@ -4115,7 +4115,7 @@ static void FMAFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, In FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Float128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4149,7 +4149,7 @@ static void FMAFloat128VectorTestsAltBroadcastSmokeTest(IntFunction fa, FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Float128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); } @@ -4169,7 +4169,7 @@ static void FMAFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, Float128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") @@ -4188,7 +4188,7 @@ static void FMAFloat128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float128VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4220,7 +4220,7 @@ static void fmaFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float128VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::fma); } @@ -4239,7 +4239,7 @@ static void FMAFloat128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::NEG); + assertArraysEquals(r, a, Float128VectorTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4280,7 +4280,7 @@ static void negFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::neg); + assertArraysEquals(r, a, Float128VectorTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4298,7 +4298,7 @@ static void NEGMaskedFloat128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float128VectorTests::NEG); + assertArraysEquals(r, a, mask, Float128VectorTests::NEG); } static float ABS(float a) { @@ -4321,7 +4321,7 @@ static void ABSFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::ABS); + assertArraysEquals(r, a, Float128VectorTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,7 +4336,7 @@ static void absFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::abs); + assertArraysEquals(r, a, Float128VectorTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4354,7 +4354,7 @@ static void ABSMaskedFloat128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float128VectorTests::ABS); + assertArraysEquals(r, a, mask, Float128VectorTests::ABS); } @@ -4386,7 +4386,7 @@ static void SQRTFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::SQRT); + assertArraysEquals(r, a, Float128VectorTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4401,7 +4401,7 @@ static void sqrtFloat128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float128VectorTests::sqrt); + assertArraysEquals(r, a, Float128VectorTests::sqrt); } @@ -4421,7 +4421,7 @@ static void SQRTMaskedFloat128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float128VectorTests::SQRT); + assertArraysEquals(r, a, mask, Float128VectorTests::SQRT); } static float[] gather(float a[], int ix, int[] b, int iy) { @@ -4446,7 +4446,7 @@ static void gatherFloat128VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Float128VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Float128VectorTests::gatherMasked); } static float[] scatter(float a[], int ix, int[] b, int iy) { @@ -4499,7 +4499,7 @@ static void scatterFloat128VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Float128VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Float128VectorTests::scatterMasked); } @@ -4579,8 +4579,8 @@ static void toIntArrayFloat128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4590,8 +4590,8 @@ static void toLongArrayFloat128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4601,8 +4601,8 @@ static void toDoubleArrayFloat128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4668,7 +4668,7 @@ static void ADDReduceLongFloat128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Float128VectorTests::ADDReduceLong, Float128VectorTests::ADDReduceAllLong); } @@ -4709,7 +4709,7 @@ static void ADDReduceLongFloat128VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Float128VectorTests::ADDReduceLongMasked, Float128VectorTests::ADDReduceAllLongMasked); } @@ -4721,7 +4721,7 @@ static void BroadcastLongFloat128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -4739,7 +4739,7 @@ static void blendFloat128VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Float128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Float128VectorTests::blend); } @@ -4756,7 +4756,7 @@ static void SelectFromFloat128VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") @@ -4775,7 +4775,7 @@ static void SelectFromFloat128VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4852,7 +4852,7 @@ static void maskEqFloat128VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Float128VectorTests::beq); + assertArraysEquals(r, a, b, Float128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java index 349fca44b4f..5b504a31fd2 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Float256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Float256VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Float256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(float[] a, float[] r, boolean[] mask) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0, "at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(float[] a, float[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "floatProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new float[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index 2ef46ccbf3c..40a561c5260 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Float256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { float apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { float[] apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { float apply(float[] a); } - static void assertReductionArraysEquals(float[] a, float[] b, float c, + static void assertReductionArraysEquals(float[] r, float rc, float[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { float apply(float[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(float[] a, float[] b, float c, boolean[] mask, + static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(float[] a); } - static void assertReductionLongArraysEquals(float[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(float[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(float[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) { + static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, in } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, bo } } - static void assertBroadcastArraysEquals(float[]a, float[]r) { + static void assertBroadcastArraysEquals(float[] r, float[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBi } } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boo } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTern } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boole } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, f } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(float actual, float expected) { return true; } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FU } } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBin } } - static void assertBroadcastArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { float apply(float[] a, int b); } - static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FS } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { float[] apply(float[] a, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { + static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { float[] apply(float[] a, float[] b, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLaneBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLan } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, bool } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { float[] apply(float[] a, float[] b, int origin, int part, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(float[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(float[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -954,7 +954,7 @@ static void assertArraysEquals(float[] a, long[] r, int offs) { } } - static void assertArraysEquals(float[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1406,7 +1406,7 @@ static void ADDFloat256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::ADD); + assertArraysEquals(r, a, b, Float256VectorTests::ADD); } static float add(float a, float b) { return (float)(a + b); @@ -1424,7 +1424,7 @@ static void addFloat256VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::add); + assertArraysEquals(r, a, b, Float256VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void ADDFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::SUB); + assertArraysEquals(r, a, b, Float256VectorTests::SUB); } static float sub(float a, float b) { return (float)(a - b); @@ -1500,7 +1500,7 @@ static void subFloat256VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::sub); + assertArraysEquals(r, a, b, Float256VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1520,7 +1520,7 @@ static void SUBFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::MUL); + assertArraysEquals(r, a, b, Float256VectorTests::MUL); } static float mul(float a, float b) { return (float)(a * b); @@ -1576,7 +1576,7 @@ static void mulFloat256VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::mul); + assertArraysEquals(r, a, b, Float256VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1596,7 +1596,7 @@ static void MULFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::DIV); + assertArraysEquals(r, a, b, Float256VectorTests::DIV); } static float div(float a, float b) { return (float)(a / b); @@ -1653,7 +1653,7 @@ static void divFloat256VectorTests(IntFunction fa, IntFunction av.div(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::div); + assertArraysEquals(r, a, b, Float256VectorTests::div); } @@ -1675,7 +1675,7 @@ static void DIVFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Float256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Float256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1736,7 +1736,7 @@ static void FIRST_NONZEROFloat256VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Float256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Float256VectorTests::FIRST_NONZERO); } @@ -1758,7 +1758,7 @@ static void addFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1775,7 +1775,7 @@ static void addFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::add); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1789,7 +1789,7 @@ static void subFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1806,7 +1806,7 @@ static void subFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1820,7 +1820,7 @@ static void mulFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1837,7 +1837,7 @@ static void mulFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::mul); } @@ -1852,7 +1852,7 @@ static void divFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::div); } @@ -1871,7 +1871,7 @@ static void divFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::div); } @@ -1894,7 +1894,7 @@ static void ADDFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Float256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Float256VectorTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1911,7 +1911,7 @@ static void ADDFloat256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::MIN); + assertArraysEquals(r, a, b, Float256VectorTests::MIN); } static float min(float a, float b) { return (float)(Math.min(a, b)); @@ -1985,7 +1985,7 @@ static void minFloat256VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::min); + assertArraysEquals(r, a, b, Float256VectorTests::min); } static float MAX(float a, float b) { return (float)(Math.max(a, b)); @@ -2005,7 +2005,7 @@ static void MAXFloat256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float256VectorTests::MAX); + assertArraysEquals(r, a, b, Float256VectorTests::MAX); } static float max(float a, float b) { return (float)(Math.max(a, b)); @@ -2023,7 +2023,7 @@ static void maxFloat256VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::max); + assertArraysEquals(r, a, b, Float256VectorTests::max); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2037,7 +2037,7 @@ static void MINFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2051,7 +2051,7 @@ static void minFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::min); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2065,7 +2065,7 @@ static void MAXFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2079,7 +2079,7 @@ static void maxFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Float256VectorTests::max); } @@ -2131,7 +2131,7 @@ static void ADDReduceFloat256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float256VectorTests::ADDReduce, Float256VectorTests::ADDReduceAll); } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2175,7 +2175,7 @@ static void ADDReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float256VectorTests::ADDReduceMasked, Float256VectorTests::ADDReduceAllMasked); } static float MULReduce(float[] a, int idx) { @@ -2216,7 +2216,7 @@ static void MULReduceFloat256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float256VectorTests::MULReduce, Float256VectorTests::MULReduceAll); } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2260,7 +2260,7 @@ static void MULReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float256VectorTests::MULReduceMasked, Float256VectorTests::MULReduceAllMasked); } static float MINReduce(float[] a, int idx) { @@ -2301,7 +2301,7 @@ static void MINReduceFloat256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float256VectorTests::MINReduce, Float256VectorTests::MINReduceAll); } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2346,7 +2346,7 @@ static void MINReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float256VectorTests::MINReduceMasked, Float256VectorTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { @@ -2387,7 +2387,7 @@ static void MAXReduceFloat256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float256VectorTests::MAXReduce, Float256VectorTests::MAXReduceAll); } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2432,7 +2432,7 @@ static void MAXReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float256VectorTests::MAXReduceMasked, Float256VectorTests::MAXReduceAllMasked); } @@ -2452,7 +2452,7 @@ static void withFloat256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (float)4, 0); + assertInsertArraysEquals(r, a, (float)4, 0); } static boolean testIS_DEFAULT(float a) { return bits(a)==0; @@ -3118,7 +3118,7 @@ static void blendFloat256VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") @@ -3153,7 +3153,7 @@ static void RearrangeFloat256VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpProvider") static void getFloat256VectorTests(IntFunction fa) { @@ -3308,7 +3308,7 @@ static void getFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::get); + assertArraysEquals(r, a, Float256VectorTests::get); } @Test(dataProvider = "floatUnaryOpProvider") @@ -3322,7 +3322,7 @@ static void BroadcastFloat256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3369,7 +3369,7 @@ static void sliceUnaryFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Float256VectorTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3398,7 +3398,7 @@ static void sliceBinaryFloat256VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Float256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Float256VectorTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3431,7 +3431,7 @@ static void sliceFloat256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Float256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Float256VectorTests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3458,7 +3458,7 @@ static void unsliceUnaryFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Float256VectorTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { float[] res = new float[SPECIES.length()]; @@ -3497,7 +3497,7 @@ static void unsliceBinaryFloat256VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Float256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Float256VectorTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3553,7 +3553,7 @@ static void unsliceFloat256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Float256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Float256VectorTests::unslice); } static float SIN(float a) { @@ -3576,7 +3576,7 @@ static void SINFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::SIN, Float256VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::SIN, Float256VectorTests::strictSIN); } @@ -3600,7 +3600,7 @@ static void EXPFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::EXP, Float256VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::EXP, Float256VectorTests::strictEXP); } @@ -3624,7 +3624,7 @@ static void LOG1PFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::LOG1P, Float256VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG1P, Float256VectorTests::strictLOG1P); } @@ -3648,7 +3648,7 @@ static void LOGFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::LOG, Float256VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG, Float256VectorTests::strictLOG); } @@ -3672,7 +3672,7 @@ static void LOG10Float256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::LOG10, Float256VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG10, Float256VectorTests::strictLOG10); } @@ -3696,7 +3696,7 @@ static void EXPM1Float256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::EXPM1, Float256VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::EXPM1, Float256VectorTests::strictEXPM1); } @@ -3720,7 +3720,7 @@ static void COSFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::COS, Float256VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::COS, Float256VectorTests::strictCOS); } @@ -3744,7 +3744,7 @@ static void TANFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::TAN, Float256VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::TAN, Float256VectorTests::strictTAN); } @@ -3768,7 +3768,7 @@ static void SINHFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::SINH, Float256VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::SINH, Float256VectorTests::strictSINH); } @@ -3792,7 +3792,7 @@ static void COSHFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::COSH, Float256VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::COSH, Float256VectorTests::strictCOSH); } @@ -3816,7 +3816,7 @@ static void TANHFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::TANH, Float256VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::TANH, Float256VectorTests::strictTANH); } @@ -3840,7 +3840,7 @@ static void ASINFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::ASIN, Float256VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ASIN, Float256VectorTests::strictASIN); } @@ -3864,7 +3864,7 @@ static void ACOSFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::ACOS, Float256VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ACOS, Float256VectorTests::strictACOS); } @@ -3888,7 +3888,7 @@ static void ATANFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::ATAN, Float256VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ATAN, Float256VectorTests::strictATAN); } @@ -3912,7 +3912,7 @@ static void CBRTFloat256VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::CBRT, Float256VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::CBRT, Float256VectorTests::strictCBRT); } @@ -3938,7 +3938,7 @@ static void HYPOTFloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::POW, Float256VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::POW, Float256VectorTests::strictPOW); } static float pow(float a, float b) { @@ -3990,7 +3990,7 @@ static void powFloat256VectorTests(IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::pow, Float256VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::pow, Float256VectorTests::strictpow); } @@ -4017,7 +4017,7 @@ static void ATAN2Float256VectorTests(IntFunction fa, IntFunction fa, In av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::POW, Float256VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::POW, Float256VectorTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4047,7 +4047,7 @@ static void powFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::pow, Float256VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::pow, Float256VectorTests::strictpow); } @@ -4076,7 +4076,7 @@ static void FMAFloat256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, Float256VectorTests::FMA); + assertArraysEquals(r, a, b, c, Float256VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4092,7 +4092,7 @@ static void fmaFloat256VectorTests(IntFunction fa, IntFunction av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Float256VectorTests::fma); + assertArraysEquals(r, a, b, c, Float256VectorTests::fma); } @@ -4115,7 +4115,7 @@ static void FMAFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, In FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Float256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4149,7 +4149,7 @@ static void FMAFloat256VectorTestsAltBroadcastSmokeTest(IntFunction fa, FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Float256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); } @@ -4169,7 +4169,7 @@ static void FMAFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, Float256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, Float256VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") @@ -4188,7 +4188,7 @@ static void FMAFloat256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float256VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4220,7 +4220,7 @@ static void fmaFloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float256VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float256VectorTests::fma); } @@ -4239,7 +4239,7 @@ static void FMAFloat256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::NEG); + assertArraysEquals(r, a, Float256VectorTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4280,7 +4280,7 @@ static void negFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::neg); + assertArraysEquals(r, a, Float256VectorTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4298,7 +4298,7 @@ static void NEGMaskedFloat256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float256VectorTests::NEG); + assertArraysEquals(r, a, mask, Float256VectorTests::NEG); } static float ABS(float a) { @@ -4321,7 +4321,7 @@ static void ABSFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::ABS); + assertArraysEquals(r, a, Float256VectorTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,7 +4336,7 @@ static void absFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::abs); + assertArraysEquals(r, a, Float256VectorTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4354,7 +4354,7 @@ static void ABSMaskedFloat256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float256VectorTests::ABS); + assertArraysEquals(r, a, mask, Float256VectorTests::ABS); } @@ -4386,7 +4386,7 @@ static void SQRTFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::SQRT); + assertArraysEquals(r, a, Float256VectorTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4401,7 +4401,7 @@ static void sqrtFloat256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float256VectorTests::sqrt); + assertArraysEquals(r, a, Float256VectorTests::sqrt); } @@ -4421,7 +4421,7 @@ static void SQRTMaskedFloat256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float256VectorTests::SQRT); + assertArraysEquals(r, a, mask, Float256VectorTests::SQRT); } static float[] gather(float a[], int ix, int[] b, int iy) { @@ -4446,7 +4446,7 @@ static void gatherFloat256VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Float256VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Float256VectorTests::gatherMasked); } static float[] scatter(float a[], int ix, int[] b, int iy) { @@ -4499,7 +4499,7 @@ static void scatterFloat256VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Float256VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Float256VectorTests::scatterMasked); } @@ -4579,8 +4579,8 @@ static void toIntArrayFloat256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4590,8 +4590,8 @@ static void toLongArrayFloat256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4601,8 +4601,8 @@ static void toDoubleArrayFloat256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4668,7 +4668,7 @@ static void ADDReduceLongFloat256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Float256VectorTests::ADDReduceLong, Float256VectorTests::ADDReduceAllLong); } @@ -4709,7 +4709,7 @@ static void ADDReduceLongFloat256VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Float256VectorTests::ADDReduceLongMasked, Float256VectorTests::ADDReduceAllLongMasked); } @@ -4721,7 +4721,7 @@ static void BroadcastLongFloat256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -4739,7 +4739,7 @@ static void blendFloat256VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Float256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Float256VectorTests::blend); } @@ -4756,7 +4756,7 @@ static void SelectFromFloat256VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") @@ -4775,7 +4775,7 @@ static void SelectFromFloat256VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4852,7 +4852,7 @@ static void maskEqFloat256VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Float256VectorTests::beq); + assertArraysEquals(r, a, b, Float256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java index 75ebc602bd3..0aa356dd9c8 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Float512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Float512VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Float512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(float[] a, float[] r, boolean[] mask) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0, "at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(float[] a, float[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "floatProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new float[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index 93e3c8b9e2f..91556d5d9df 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Float512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { float apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { float[] apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { float apply(float[] a); } - static void assertReductionArraysEquals(float[] a, float[] b, float c, + static void assertReductionArraysEquals(float[] r, float rc, float[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { float apply(float[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(float[] a, float[] b, float c, boolean[] mask, + static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(float[] a); } - static void assertReductionLongArraysEquals(float[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(float[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(float[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) { + static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, in } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, bo } } - static void assertBroadcastArraysEquals(float[]a, float[]r) { + static void assertBroadcastArraysEquals(float[] r, float[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBi } } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boo } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTern } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boole } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, f } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(float actual, float expected) { return true; } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FU } } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBin } } - static void assertBroadcastArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { float apply(float[] a, int b); } - static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FS } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { float[] apply(float[] a, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { + static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { float[] apply(float[] a, float[] b, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLaneBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLan } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, bool } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { float[] apply(float[] a, float[] b, int origin, int part, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(float[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(float[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -954,7 +954,7 @@ static void assertArraysEquals(float[] a, long[] r, int offs) { } } - static void assertArraysEquals(float[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1406,7 +1406,7 @@ static void ADDFloat512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::ADD); + assertArraysEquals(r, a, b, Float512VectorTests::ADD); } static float add(float a, float b) { return (float)(a + b); @@ -1424,7 +1424,7 @@ static void addFloat512VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::add); + assertArraysEquals(r, a, b, Float512VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void ADDFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::SUB); + assertArraysEquals(r, a, b, Float512VectorTests::SUB); } static float sub(float a, float b) { return (float)(a - b); @@ -1500,7 +1500,7 @@ static void subFloat512VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::sub); + assertArraysEquals(r, a, b, Float512VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1520,7 +1520,7 @@ static void SUBFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::MUL); + assertArraysEquals(r, a, b, Float512VectorTests::MUL); } static float mul(float a, float b) { return (float)(a * b); @@ -1576,7 +1576,7 @@ static void mulFloat512VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::mul); + assertArraysEquals(r, a, b, Float512VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1596,7 +1596,7 @@ static void MULFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::DIV); + assertArraysEquals(r, a, b, Float512VectorTests::DIV); } static float div(float a, float b) { return (float)(a / b); @@ -1653,7 +1653,7 @@ static void divFloat512VectorTests(IntFunction fa, IntFunction av.div(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::div); + assertArraysEquals(r, a, b, Float512VectorTests::div); } @@ -1675,7 +1675,7 @@ static void DIVFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Float512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Float512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1736,7 +1736,7 @@ static void FIRST_NONZEROFloat512VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Float512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Float512VectorTests::FIRST_NONZERO); } @@ -1758,7 +1758,7 @@ static void addFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1775,7 +1775,7 @@ static void addFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::add); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1789,7 +1789,7 @@ static void subFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1806,7 +1806,7 @@ static void subFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1820,7 +1820,7 @@ static void mulFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1837,7 +1837,7 @@ static void mulFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::mul); } @@ -1852,7 +1852,7 @@ static void divFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::div); } @@ -1871,7 +1871,7 @@ static void divFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::div); } @@ -1894,7 +1894,7 @@ static void ADDFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Float512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Float512VectorTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1911,7 +1911,7 @@ static void ADDFloat512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::MIN); + assertArraysEquals(r, a, b, Float512VectorTests::MIN); } static float min(float a, float b) { return (float)(Math.min(a, b)); @@ -1985,7 +1985,7 @@ static void minFloat512VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::min); + assertArraysEquals(r, a, b, Float512VectorTests::min); } static float MAX(float a, float b) { return (float)(Math.max(a, b)); @@ -2005,7 +2005,7 @@ static void MAXFloat512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float512VectorTests::MAX); + assertArraysEquals(r, a, b, Float512VectorTests::MAX); } static float max(float a, float b) { return (float)(Math.max(a, b)); @@ -2023,7 +2023,7 @@ static void maxFloat512VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::max); + assertArraysEquals(r, a, b, Float512VectorTests::max); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2037,7 +2037,7 @@ static void MINFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2051,7 +2051,7 @@ static void minFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::min); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2065,7 +2065,7 @@ static void MAXFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2079,7 +2079,7 @@ static void maxFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Float512VectorTests::max); } @@ -2131,7 +2131,7 @@ static void ADDReduceFloat512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float512VectorTests::ADDReduce, Float512VectorTests::ADDReduceAll); } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2175,7 +2175,7 @@ static void ADDReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float512VectorTests::ADDReduceMasked, Float512VectorTests::ADDReduceAllMasked); } static float MULReduce(float[] a, int idx) { @@ -2216,7 +2216,7 @@ static void MULReduceFloat512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float512VectorTests::MULReduce, Float512VectorTests::MULReduceAll); } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2260,7 +2260,7 @@ static void MULReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float512VectorTests::MULReduceMasked, Float512VectorTests::MULReduceAllMasked); } static float MINReduce(float[] a, int idx) { @@ -2301,7 +2301,7 @@ static void MINReduceFloat512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float512VectorTests::MINReduce, Float512VectorTests::MINReduceAll); } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2346,7 +2346,7 @@ static void MINReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float512VectorTests::MINReduceMasked, Float512VectorTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { @@ -2387,7 +2387,7 @@ static void MAXReduceFloat512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float512VectorTests::MAXReduce, Float512VectorTests::MAXReduceAll); } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2432,7 +2432,7 @@ static void MAXReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float512VectorTests::MAXReduceMasked, Float512VectorTests::MAXReduceAllMasked); } @@ -2452,7 +2452,7 @@ static void withFloat512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (float)4, 0); + assertInsertArraysEquals(r, a, (float)4, 0); } static boolean testIS_DEFAULT(float a) { return bits(a)==0; @@ -3118,7 +3118,7 @@ static void blendFloat512VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") @@ -3153,7 +3153,7 @@ static void RearrangeFloat512VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpProvider") static void getFloat512VectorTests(IntFunction fa) { @@ -3308,7 +3308,7 @@ static void getFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::get); + assertArraysEquals(r, a, Float512VectorTests::get); } @Test(dataProvider = "floatUnaryOpProvider") @@ -3322,7 +3322,7 @@ static void BroadcastFloat512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3369,7 +3369,7 @@ static void sliceUnaryFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Float512VectorTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3398,7 +3398,7 @@ static void sliceBinaryFloat512VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Float512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Float512VectorTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3431,7 +3431,7 @@ static void sliceFloat512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Float512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Float512VectorTests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3458,7 +3458,7 @@ static void unsliceUnaryFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Float512VectorTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { float[] res = new float[SPECIES.length()]; @@ -3497,7 +3497,7 @@ static void unsliceBinaryFloat512VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Float512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Float512VectorTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3553,7 +3553,7 @@ static void unsliceFloat512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Float512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Float512VectorTests::unslice); } static float SIN(float a) { @@ -3576,7 +3576,7 @@ static void SINFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::SIN, Float512VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::SIN, Float512VectorTests::strictSIN); } @@ -3600,7 +3600,7 @@ static void EXPFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::EXP, Float512VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::EXP, Float512VectorTests::strictEXP); } @@ -3624,7 +3624,7 @@ static void LOG1PFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::LOG1P, Float512VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG1P, Float512VectorTests::strictLOG1P); } @@ -3648,7 +3648,7 @@ static void LOGFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::LOG, Float512VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG, Float512VectorTests::strictLOG); } @@ -3672,7 +3672,7 @@ static void LOG10Float512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::LOG10, Float512VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG10, Float512VectorTests::strictLOG10); } @@ -3696,7 +3696,7 @@ static void EXPM1Float512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::EXPM1, Float512VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::EXPM1, Float512VectorTests::strictEXPM1); } @@ -3720,7 +3720,7 @@ static void COSFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::COS, Float512VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::COS, Float512VectorTests::strictCOS); } @@ -3744,7 +3744,7 @@ static void TANFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::TAN, Float512VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::TAN, Float512VectorTests::strictTAN); } @@ -3768,7 +3768,7 @@ static void SINHFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::SINH, Float512VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::SINH, Float512VectorTests::strictSINH); } @@ -3792,7 +3792,7 @@ static void COSHFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::COSH, Float512VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::COSH, Float512VectorTests::strictCOSH); } @@ -3816,7 +3816,7 @@ static void TANHFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::TANH, Float512VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::TANH, Float512VectorTests::strictTANH); } @@ -3840,7 +3840,7 @@ static void ASINFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::ASIN, Float512VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ASIN, Float512VectorTests::strictASIN); } @@ -3864,7 +3864,7 @@ static void ACOSFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::ACOS, Float512VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ACOS, Float512VectorTests::strictACOS); } @@ -3888,7 +3888,7 @@ static void ATANFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::ATAN, Float512VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ATAN, Float512VectorTests::strictATAN); } @@ -3912,7 +3912,7 @@ static void CBRTFloat512VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float512VectorTests::CBRT, Float512VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::CBRT, Float512VectorTests::strictCBRT); } @@ -3938,7 +3938,7 @@ static void HYPOTFloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float512VectorTests::POW, Float512VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::POW, Float512VectorTests::strictPOW); } static float pow(float a, float b) { @@ -3990,7 +3990,7 @@ static void powFloat512VectorTests(IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float512VectorTests::pow, Float512VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::pow, Float512VectorTests::strictpow); } @@ -4017,7 +4017,7 @@ static void ATAN2Float512VectorTests(IntFunction fa, IntFunction fa, In av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float512VectorTests::POW, Float512VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::POW, Float512VectorTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4047,7 +4047,7 @@ static void powFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float512VectorTests::pow, Float512VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::pow, Float512VectorTests::strictpow); } @@ -4076,7 +4076,7 @@ static void FMAFloat512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, Float512VectorTests::FMA); + assertArraysEquals(r, a, b, c, Float512VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4092,7 +4092,7 @@ static void fmaFloat512VectorTests(IntFunction fa, IntFunction av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Float512VectorTests::fma); + assertArraysEquals(r, a, b, c, Float512VectorTests::fma); } @@ -4115,7 +4115,7 @@ static void FMAFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, In FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Float512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4149,7 +4149,7 @@ static void FMAFloat512VectorTestsAltBroadcastSmokeTest(IntFunction fa, FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Float512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); } @@ -4169,7 +4169,7 @@ static void FMAFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, Float512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, Float512VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") @@ -4188,7 +4188,7 @@ static void FMAFloat512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float512VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4220,7 +4220,7 @@ static void fmaFloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float512VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float512VectorTests::fma); } @@ -4239,7 +4239,7 @@ static void FMAFloat512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::NEG); + assertArraysEquals(r, a, Float512VectorTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4280,7 +4280,7 @@ static void negFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::neg); + assertArraysEquals(r, a, Float512VectorTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4298,7 +4298,7 @@ static void NEGMaskedFloat512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float512VectorTests::NEG); + assertArraysEquals(r, a, mask, Float512VectorTests::NEG); } static float ABS(float a) { @@ -4321,7 +4321,7 @@ static void ABSFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::ABS); + assertArraysEquals(r, a, Float512VectorTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,7 +4336,7 @@ static void absFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::abs); + assertArraysEquals(r, a, Float512VectorTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4354,7 +4354,7 @@ static void ABSMaskedFloat512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float512VectorTests::ABS); + assertArraysEquals(r, a, mask, Float512VectorTests::ABS); } @@ -4386,7 +4386,7 @@ static void SQRTFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::SQRT); + assertArraysEquals(r, a, Float512VectorTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4401,7 +4401,7 @@ static void sqrtFloat512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float512VectorTests::sqrt); + assertArraysEquals(r, a, Float512VectorTests::sqrt); } @@ -4421,7 +4421,7 @@ static void SQRTMaskedFloat512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float512VectorTests::SQRT); + assertArraysEquals(r, a, mask, Float512VectorTests::SQRT); } static float[] gather(float a[], int ix, int[] b, int iy) { @@ -4446,7 +4446,7 @@ static void gatherFloat512VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Float512VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Float512VectorTests::gatherMasked); } static float[] scatter(float a[], int ix, int[] b, int iy) { @@ -4499,7 +4499,7 @@ static void scatterFloat512VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Float512VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Float512VectorTests::scatterMasked); } @@ -4579,8 +4579,8 @@ static void toIntArrayFloat512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4590,8 +4590,8 @@ static void toLongArrayFloat512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4601,8 +4601,8 @@ static void toDoubleArrayFloat512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4668,7 +4668,7 @@ static void ADDReduceLongFloat512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Float512VectorTests::ADDReduceLong, Float512VectorTests::ADDReduceAllLong); } @@ -4709,7 +4709,7 @@ static void ADDReduceLongFloat512VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Float512VectorTests::ADDReduceLongMasked, Float512VectorTests::ADDReduceAllLongMasked); } @@ -4721,7 +4721,7 @@ static void BroadcastLongFloat512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -4739,7 +4739,7 @@ static void blendFloat512VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Float512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Float512VectorTests::blend); } @@ -4756,7 +4756,7 @@ static void SelectFromFloat512VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") @@ -4775,7 +4775,7 @@ static void SelectFromFloat512VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4852,7 +4852,7 @@ static void maskEqFloat512VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Float512VectorTests::beq); + assertArraysEquals(r, a, b, Float512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java index d2f7bc0719c..166a171582d 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Float64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Float64VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Float64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(float[] a, float[] r, boolean[] mask) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0, "at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(float[] a, float[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "floatProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new float[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index 737301de6a9..9e00b5bfc36 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Float64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { float apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { float[] apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { float apply(float[] a); } - static void assertReductionArraysEquals(float[] a, float[] b, float c, + static void assertReductionArraysEquals(float[] r, float rc, float[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { float apply(float[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(float[] a, float[] b, float c, boolean[] mask, + static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(float[] a); } - static void assertReductionLongArraysEquals(float[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(float[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(float[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) { + static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, in } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, bo } } - static void assertBroadcastArraysEquals(float[]a, float[]r) { + static void assertBroadcastArraysEquals(float[] r, float[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBi } } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boo } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTern } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boole } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, f } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -613,7 +613,7 @@ static boolean isWithin1Ulp(float actual, float expected) { return true; } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -627,7 +627,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FU } } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -641,7 +641,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBin } } - static void assertBroadcastArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -671,7 +671,7 @@ interface FBinArrayOp { float apply(float[] a, int b); } - static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -686,7 +686,7 @@ interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -713,7 +713,7 @@ interface FScatterMaskedOp { float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -723,7 +723,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -734,7 +734,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -744,7 +744,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FS } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -761,7 +761,7 @@ interface FLaneOp { float[] apply(float[] a, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { + static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -771,7 +771,7 @@ static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -781,7 +781,7 @@ interface FLaneBop { float[] apply(float[] a, float[] b, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLaneBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -791,7 +791,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLan } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -802,7 +802,7 @@ interface FLaneMaskedBop { float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -812,7 +812,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, bool } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -823,7 +823,7 @@ interface FLanePartBop { float[] apply(float[] a, float[] b, int origin, int part, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -833,7 +833,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -845,7 +845,7 @@ interface FLanePartMaskedBop { float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -855,7 +855,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -897,7 +897,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(float[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -943,7 +943,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(float[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -954,7 +954,7 @@ static void assertArraysEquals(float[] a, long[] r, int offs) { } } - static void assertArraysEquals(float[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1406,7 +1406,7 @@ static void ADDFloat64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::ADD); + assertArraysEquals(r, a, b, Float64VectorTests::ADD); } static float add(float a, float b) { return (float)(a + b); @@ -1424,7 +1424,7 @@ static void addFloat64VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::add); + assertArraysEquals(r, a, b, Float64VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void ADDFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::SUB); + assertArraysEquals(r, a, b, Float64VectorTests::SUB); } static float sub(float a, float b) { return (float)(a - b); @@ -1500,7 +1500,7 @@ static void subFloat64VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::sub); + assertArraysEquals(r, a, b, Float64VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1520,7 +1520,7 @@ static void SUBFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::MUL); + assertArraysEquals(r, a, b, Float64VectorTests::MUL); } static float mul(float a, float b) { return (float)(a * b); @@ -1576,7 +1576,7 @@ static void mulFloat64VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::mul); + assertArraysEquals(r, a, b, Float64VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1596,7 +1596,7 @@ static void MULFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::DIV); + assertArraysEquals(r, a, b, Float64VectorTests::DIV); } static float div(float a, float b) { return (float)(a / b); @@ -1653,7 +1653,7 @@ static void divFloat64VectorTests(IntFunction fa, IntFunction av.div(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::div); + assertArraysEquals(r, a, b, Float64VectorTests::div); } @@ -1675,7 +1675,7 @@ static void DIVFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Float64VectorTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1736,7 +1736,7 @@ static void FIRST_NONZEROFloat64VectorTestsMasked(IntFunction fa, IntFu } } - assertArraysEquals(a, b, r, mask, Float64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Float64VectorTests::FIRST_NONZERO); } @@ -1758,7 +1758,7 @@ static void addFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1775,7 +1775,7 @@ static void addFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::add); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1789,7 +1789,7 @@ static void subFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1806,7 +1806,7 @@ static void subFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1820,7 +1820,7 @@ static void mulFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1837,7 +1837,7 @@ static void mulFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::mul); } @@ -1852,7 +1852,7 @@ static void divFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::div); } @@ -1871,7 +1871,7 @@ static void divFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::div); } @@ -1894,7 +1894,7 @@ static void ADDFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Float64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Float64VectorTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1911,7 +1911,7 @@ static void ADDFloat64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::MIN); + assertArraysEquals(r, a, b, Float64VectorTests::MIN); } static float min(float a, float b) { return (float)(Math.min(a, b)); @@ -1985,7 +1985,7 @@ static void minFloat64VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::min); + assertArraysEquals(r, a, b, Float64VectorTests::min); } static float MAX(float a, float b) { return (float)(Math.max(a, b)); @@ -2005,7 +2005,7 @@ static void MAXFloat64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Float64VectorTests::MAX); + assertArraysEquals(r, a, b, Float64VectorTests::MAX); } static float max(float a, float b) { return (float)(Math.max(a, b)); @@ -2023,7 +2023,7 @@ static void maxFloat64VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::max); + assertArraysEquals(r, a, b, Float64VectorTests::max); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2037,7 +2037,7 @@ static void MINFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2051,7 +2051,7 @@ static void minFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::min); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2065,7 +2065,7 @@ static void MAXFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2079,7 +2079,7 @@ static void maxFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Float64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Float64VectorTests::max); } @@ -2131,7 +2131,7 @@ static void ADDReduceFloat64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float64VectorTests::ADDReduce, Float64VectorTests::ADDReduceAll); } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2175,7 +2175,7 @@ static void ADDReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float64VectorTests::ADDReduceMasked, Float64VectorTests::ADDReduceAllMasked); } static float MULReduce(float[] a, int idx) { @@ -2216,7 +2216,7 @@ static void MULReduceFloat64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float64VectorTests::MULReduce, Float64VectorTests::MULReduceAll); } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2260,7 +2260,7 @@ static void MULReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float64VectorTests::MULReduceMasked, Float64VectorTests::MULReduceAllMasked); } static float MINReduce(float[] a, int idx) { @@ -2301,7 +2301,7 @@ static void MINReduceFloat64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float64VectorTests::MINReduce, Float64VectorTests::MINReduceAll); } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2346,7 +2346,7 @@ static void MINReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float64VectorTests::MINReduceMasked, Float64VectorTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { @@ -2387,7 +2387,7 @@ static void MAXReduceFloat64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Float64VectorTests::MAXReduce, Float64VectorTests::MAXReduceAll); } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2432,7 +2432,7 @@ static void MAXReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Float64VectorTests::MAXReduceMasked, Float64VectorTests::MAXReduceAllMasked); } @@ -2452,7 +2452,7 @@ static void withFloat64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (float)4, 0); + assertInsertArraysEquals(r, a, (float)4, 0); } static boolean testIS_DEFAULT(float a) { return bits(a)==0; @@ -3118,7 +3118,7 @@ static void blendFloat64VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") @@ -3153,7 +3153,7 @@ static void RearrangeFloat64VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpProvider") static void getFloat64VectorTests(IntFunction fa) { @@ -3308,7 +3308,7 @@ static void getFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::get); + assertArraysEquals(r, a, Float64VectorTests::get); } @Test(dataProvider = "floatUnaryOpProvider") @@ -3322,7 +3322,7 @@ static void BroadcastFloat64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3369,7 +3369,7 @@ static void sliceUnaryFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Float64VectorTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3398,7 +3398,7 @@ static void sliceBinaryFloat64VectorTestsBinary(IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, origin, Float64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Float64VectorTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3431,7 +3431,7 @@ static void sliceFloat64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Float64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Float64VectorTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { float[] res = new float[SPECIES.length()]; @@ -3497,7 +3497,7 @@ static void unsliceBinaryFloat64VectorTestsBinary(IntFunction fa, IntFu } } - assertArraysEquals(a, b, r, origin, part, Float64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Float64VectorTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3553,7 +3553,7 @@ static void unsliceFloat64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, origin, part, mask, Float64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Float64VectorTests::unslice); } static float SIN(float a) { @@ -3576,7 +3576,7 @@ static void SINFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::SIN, Float64VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::SIN, Float64VectorTests::strictSIN); } @@ -3600,7 +3600,7 @@ static void EXPFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::EXP, Float64VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXP, Float64VectorTests::strictEXP); } @@ -3624,7 +3624,7 @@ static void LOG1PFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::LOG1P, Float64VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG1P, Float64VectorTests::strictLOG1P); } @@ -3648,7 +3648,7 @@ static void LOGFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::LOG, Float64VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG, Float64VectorTests::strictLOG); } @@ -3672,7 +3672,7 @@ static void LOG10Float64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::LOG10, Float64VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG10, Float64VectorTests::strictLOG10); } @@ -3696,7 +3696,7 @@ static void EXPM1Float64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::EXPM1, Float64VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXPM1, Float64VectorTests::strictEXPM1); } @@ -3720,7 +3720,7 @@ static void COSFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::COS, Float64VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COS, Float64VectorTests::strictCOS); } @@ -3744,7 +3744,7 @@ static void TANFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::TAN, Float64VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TAN, Float64VectorTests::strictTAN); } @@ -3768,7 +3768,7 @@ static void SINHFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::SINH, Float64VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::SINH, Float64VectorTests::strictSINH); } @@ -3792,7 +3792,7 @@ static void COSHFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::COSH, Float64VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COSH, Float64VectorTests::strictCOSH); } @@ -3816,7 +3816,7 @@ static void TANHFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::TANH, Float64VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TANH, Float64VectorTests::strictTANH); } @@ -3840,7 +3840,7 @@ static void ASINFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::ASIN, Float64VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ASIN, Float64VectorTests::strictASIN); } @@ -3864,7 +3864,7 @@ static void ACOSFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::ACOS, Float64VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ACOS, Float64VectorTests::strictACOS); } @@ -3888,7 +3888,7 @@ static void ATANFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::ATAN, Float64VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ATAN, Float64VectorTests::strictATAN); } @@ -3912,7 +3912,7 @@ static void CBRTFloat64VectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, Float64VectorTests::CBRT, Float64VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::CBRT, Float64VectorTests::strictCBRT); } @@ -3938,7 +3938,7 @@ static void HYPOTFloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float64VectorTests::POW, Float64VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW); } static float pow(float a, float b) { @@ -3990,7 +3990,7 @@ static void powFloat64VectorTests(IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, Float64VectorTests::pow, Float64VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow); } @@ -4017,7 +4017,7 @@ static void ATAN2Float64VectorTests(IntFunction fa, IntFunction fa, Int av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float64VectorTests::POW, Float64VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4047,7 +4047,7 @@ static void powFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, Float64VectorTests::pow, Float64VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow); } @@ -4076,7 +4076,7 @@ static void FMAFloat64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, Float64VectorTests::FMA); + assertArraysEquals(r, a, b, c, Float64VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4092,7 +4092,7 @@ static void fmaFloat64VectorTests(IntFunction fa, IntFunction av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Float64VectorTests::fma); + assertArraysEquals(r, a, b, c, Float64VectorTests::fma); } @@ -4115,7 +4115,7 @@ static void FMAFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, Int FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Float64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4149,7 +4149,7 @@ static void FMAFloat64VectorTestsAltBroadcastSmokeTest(IntFunction fa, FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Float64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); } @@ -4169,7 +4169,7 @@ static void FMAFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, Float64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") @@ -4188,7 +4188,7 @@ static void FMAFloat64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4220,7 +4220,7 @@ static void fmaFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction f av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Float64VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::fma); } @@ -4239,7 +4239,7 @@ static void FMAFloat64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::NEG); + assertArraysEquals(r, a, Float64VectorTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4280,7 +4280,7 @@ static void negFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::neg); + assertArraysEquals(r, a, Float64VectorTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4298,7 +4298,7 @@ static void NEGMaskedFloat64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float64VectorTests::NEG); + assertArraysEquals(r, a, mask, Float64VectorTests::NEG); } static float ABS(float a) { @@ -4321,7 +4321,7 @@ static void ABSFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::ABS); + assertArraysEquals(r, a, Float64VectorTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,7 +4336,7 @@ static void absFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::abs); + assertArraysEquals(r, a, Float64VectorTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4354,7 +4354,7 @@ static void ABSMaskedFloat64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float64VectorTests::ABS); + assertArraysEquals(r, a, mask, Float64VectorTests::ABS); } @@ -4386,7 +4386,7 @@ static void SQRTFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::SQRT); + assertArraysEquals(r, a, Float64VectorTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4401,7 +4401,7 @@ static void sqrtFloat64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Float64VectorTests::sqrt); + assertArraysEquals(r, a, Float64VectorTests::sqrt); } @@ -4421,7 +4421,7 @@ static void SQRTMaskedFloat64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Float64VectorTests::SQRT); + assertArraysEquals(r, a, mask, Float64VectorTests::SQRT); } static float[] gather(float a[], int ix, int[] b, int iy) { @@ -4446,7 +4446,7 @@ static void gatherFloat64VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Float64VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Float64VectorTests::scatterMasked); } @@ -4579,8 +4579,8 @@ static void toIntArrayFloat64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4590,8 +4590,8 @@ static void toLongArrayFloat64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4601,8 +4601,8 @@ static void toDoubleArrayFloat64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4668,7 +4668,7 @@ static void ADDReduceLongFloat64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Float64VectorTests::ADDReduceLong, Float64VectorTests::ADDReduceAllLong); } @@ -4709,7 +4709,7 @@ static void ADDReduceLongFloat64VectorTestsMasked(IntFunction fa, IntFu ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Float64VectorTests::ADDReduceLongMasked, Float64VectorTests::ADDReduceAllLongMasked); } @@ -4721,7 +4721,7 @@ static void BroadcastLongFloat64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -4739,7 +4739,7 @@ static void blendFloat64VectorTestsBroadcastLongSmokeTest(IntFunction f av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Float64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Float64VectorTests::blend); } @@ -4756,7 +4756,7 @@ static void SelectFromFloat64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") @@ -4775,7 +4775,7 @@ static void SelectFromFloat64VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4852,7 +4852,7 @@ static void maskEqFloat64VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Float64VectorTests::beq); + assertArraysEquals(r, a, b, Float64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java index df4abd7b76d..ed32c12a778 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * FloatMaxVectorLoadStoreTests + * -XX:-TieredCompilation FloatMaxVectorLoadStoreTests * */ @@ -67,47 +67,25 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(float[] a, float[] r, boolean[] mask) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (float) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (float) 0, "at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(float[] a, float[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (float) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -410,7 +388,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "floatProviderForIOOBE") @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new float[a.length]; @@ -492,7 +470,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatMaskProviderForIOOBE") @@ -565,7 +543,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -589,7 +567,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -676,7 +654,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -691,7 +669,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -807,7 +785,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "floatByteProviderForIOOBE") @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -899,7 +877,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "floatByteMaskProviderForIOOBE") @@ -976,7 +954,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -987,7 +965,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index 9062ef5905a..842c4f93075 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch FloatMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation FloatMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { float apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { float[] apply(float a); } - static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(float[] a, float[] r, FUnArrayOp f) { } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { float apply(float[] a); } - static void assertReductionArraysEquals(float[] a, float[] b, float c, + static void assertReductionArraysEquals(float[] r, float rc, float[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { float apply(float[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(float[] a, float[] b, float c, boolean[] mask, + static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -167,17 +167,17 @@ interface FReductionAllOpLong { long apply(float[] a); } - static void assertReductionLongArraysEquals(float[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -189,17 +189,17 @@ interface FReductionAllMaskedOpLong { long apply(float[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(float[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -207,37 +207,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) { + static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -251,7 +251,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -265,7 +265,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, in } } - static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -285,7 +285,7 @@ static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -305,7 +305,7 @@ static void assertSelectFromArraysEquals(float[] a, float[] r, float[] order, bo } } - static void assertBroadcastArraysEquals(float[]a, float[]r) { + static void assertBroadcastArraysEquals(float[] r, float[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -334,7 +334,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -345,7 +345,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -357,7 +357,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -369,11 +369,11 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, FBi } } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -384,11 +384,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -402,11 +402,11 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean } } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -420,7 +420,7 @@ static void assertBroadcastLongArraysEquals(float[] a, float[] b, float[] r, boo } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -434,11 +434,11 @@ static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) { } } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -464,7 +464,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -475,11 +475,11 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTern } } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -491,7 +491,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boole } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -504,7 +504,7 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,12 +517,12 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -538,12 +538,12 @@ static void assertBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] } } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ static void assertAltBroadcastArraysEquals(float[] a, float[] b, float[] c, floa } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,12 +574,12 @@ static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, f } } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -618,7 +618,7 @@ static boolean isWithin1Ulp(float actual, float expected) { return true; } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -632,7 +632,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FU } } - static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -646,7 +646,7 @@ static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBin } } - static void assertBroadcastArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, + static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -676,7 +676,7 @@ interface FBinArrayOp { float apply(float[] a, int b); } - static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) { + static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -691,7 +691,7 @@ interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -718,7 +718,7 @@ interface FScatterMaskedOp { float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -728,7 +728,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -739,7 +739,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FG } } - static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -749,7 +749,7 @@ static void assertArraysEquals(float[] a, int[] b, float[] r, boolean[] mask, FS } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -766,7 +766,7 @@ interface FLaneOp { float[] apply(float[] a, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { + static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -776,7 +776,7 @@ static void assertArraysEquals(float[] a, float[] r, int origin, FLaneOp f) { } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -786,7 +786,7 @@ interface FLaneBop { float[] apply(float[] a, float[] b, int origin, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLaneBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -796,7 +796,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, FLan } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -807,7 +807,7 @@ interface FLaneMaskedBop { float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -817,7 +817,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, bool } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -828,7 +828,7 @@ interface FLanePartBop { float[] apply(float[] a, float[] b, int origin, int part, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -838,7 +838,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -850,7 +850,7 @@ interface FLanePartMaskedBop { float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -860,7 +860,7 @@ static void assertArraysEquals(float[] a, float[] b, float[] r, int origin, int } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -902,7 +902,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(float[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -948,7 +948,7 @@ static long longCornerCaseValue(int i) { ); - static void assertArraysEquals(float[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -959,7 +959,7 @@ static void assertArraysEquals(float[] a, long[] r, int offs) { } } - static void assertArraysEquals(float[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1411,7 +1411,7 @@ static void ADDFloatMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::ADD); + assertArraysEquals(r, a, b, FloatMaxVectorTests::ADD); } static float add(float a, float b) { return (float)(a + b); @@ -1429,7 +1429,7 @@ static void addFloatMaxVectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::add); + assertArraysEquals(r, a, b, FloatMaxVectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1449,7 +1449,7 @@ static void ADDFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::SUB); + assertArraysEquals(r, a, b, FloatMaxVectorTests::SUB); } static float sub(float a, float b) { return (float)(a - b); @@ -1505,7 +1505,7 @@ static void subFloatMaxVectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::sub); + assertArraysEquals(r, a, b, FloatMaxVectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1525,7 +1525,7 @@ static void SUBFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::MUL); + assertArraysEquals(r, a, b, FloatMaxVectorTests::MUL); } static float mul(float a, float b) { return (float)(a * b); @@ -1581,7 +1581,7 @@ static void mulFloatMaxVectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::mul); + assertArraysEquals(r, a, b, FloatMaxVectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1601,7 +1601,7 @@ static void MULFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::DIV); + assertArraysEquals(r, a, b, FloatMaxVectorTests::DIV); } static float div(float a, float b) { return (float)(a / b); @@ -1658,7 +1658,7 @@ static void divFloatMaxVectorTests(IntFunction fa, IntFunction av.div(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::div); + assertArraysEquals(r, a, b, FloatMaxVectorTests::div); } @@ -1680,7 +1680,7 @@ static void DIVFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1741,7 +1741,7 @@ static void FIRST_NONZEROFloatMaxVectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, FloatMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::FIRST_NONZERO); } @@ -1763,7 +1763,7 @@ static void addFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1780,7 +1780,7 @@ static void addFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::add); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1794,7 +1794,7 @@ static void subFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1811,7 +1811,7 @@ static void subFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1825,7 +1825,7 @@ static void mulFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1842,7 +1842,7 @@ static void mulFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::mul); } @@ -1857,7 +1857,7 @@ static void divFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::div); } @@ -1876,7 +1876,7 @@ static void divFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::div); } @@ -1899,7 +1899,7 @@ static void ADDFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, FloatMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatMaxVectorTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -1916,7 +1916,7 @@ static void ADDFloatMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::MIN); + assertArraysEquals(r, a, b, FloatMaxVectorTests::MIN); } static float min(float a, float b) { return (float)(Math.min(a, b)); @@ -1990,7 +1990,7 @@ static void minFloatMaxVectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::min); + assertArraysEquals(r, a, b, FloatMaxVectorTests::min); } static float MAX(float a, float b) { return (float)(Math.max(a, b)); @@ -2010,7 +2010,7 @@ static void MAXFloatMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, FloatMaxVectorTests::MAX); + assertArraysEquals(r, a, b, FloatMaxVectorTests::MAX); } static float max(float a, float b) { return (float)(Math.max(a, b)); @@ -2028,7 +2028,7 @@ static void maxFloatMaxVectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::max); + assertArraysEquals(r, a, b, FloatMaxVectorTests::max); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2042,7 +2042,7 @@ static void MINFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2056,7 +2056,7 @@ static void minFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::min); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2070,7 +2070,7 @@ static void MAXFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2084,7 +2084,7 @@ static void maxFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::max); } @@ -2136,7 +2136,7 @@ static void ADDReduceFloatMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, FloatMaxVectorTests::ADDReduce, FloatMaxVectorTests::ADDReduceAll); } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2180,7 +2180,7 @@ static void ADDReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, FloatMaxVectorTests::ADDReduceMasked, FloatMaxVectorTests::ADDReduceAllMasked); } static float MULReduce(float[] a, int idx) { @@ -2221,7 +2221,7 @@ static void MULReduceFloatMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, FloatMaxVectorTests::MULReduce, FloatMaxVectorTests::MULReduceAll); } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2265,7 +2265,7 @@ static void MULReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, FloatMaxVectorTests::MULReduceMasked, FloatMaxVectorTests::MULReduceAllMasked); } static float MINReduce(float[] a, int idx) { @@ -2306,7 +2306,7 @@ static void MINReduceFloatMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, FloatMaxVectorTests::MINReduce, FloatMaxVectorTests::MINReduceAll); } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2351,7 +2351,7 @@ static void MINReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, FloatMaxVectorTests::MINReduceMasked, FloatMaxVectorTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { @@ -2392,7 +2392,7 @@ static void MAXReduceFloatMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, FloatMaxVectorTests::MAXReduce, FloatMaxVectorTests::MAXReduceAll); } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { @@ -2437,7 +2437,7 @@ static void MAXReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, FloatMaxVectorTests::MAXReduceMasked, FloatMaxVectorTests::MAXReduceAllMasked); } @@ -2457,7 +2457,7 @@ static void withFloatMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (float)4, 0); + assertInsertArraysEquals(r, a, (float)4, 0); } static boolean testIS_DEFAULT(float a) { return bits(a)==0; @@ -3123,7 +3123,7 @@ static void blendFloatMaxVectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") @@ -3158,7 +3158,7 @@ static void RearrangeFloatMaxVectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpProvider") static void getFloatMaxVectorTests(IntFunction fa) { @@ -3313,7 +3313,7 @@ static void getFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::get); + assertArraysEquals(r, a, FloatMaxVectorTests::get); } @Test(dataProvider = "floatUnaryOpProvider") @@ -3327,7 +3327,7 @@ static void BroadcastFloatMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3374,7 +3374,7 @@ static void sliceUnaryFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, FloatMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatMaxVectorTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3403,7 +3403,7 @@ static void sliceBinaryFloatMaxVectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, FloatMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatMaxVectorTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3436,7 +3436,7 @@ static void sliceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, FloatMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatMaxVectorTests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { float[] res = new float[SPECIES.length()]; @@ -3463,7 +3463,7 @@ static void unsliceUnaryFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, FloatMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatMaxVectorTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { float[] res = new float[SPECIES.length()]; @@ -3502,7 +3502,7 @@ static void unsliceBinaryFloatMaxVectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, FloatMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatMaxVectorTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { float[] res = new float[SPECIES.length()]; @@ -3558,7 +3558,7 @@ static void unsliceFloatMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, FloatMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatMaxVectorTests::unslice); } static float SIN(float a) { @@ -3581,7 +3581,7 @@ static void SINFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::SIN, FloatMaxVectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::SIN, FloatMaxVectorTests::strictSIN); } @@ -3605,7 +3605,7 @@ static void EXPFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::EXP, FloatMaxVectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::EXP, FloatMaxVectorTests::strictEXP); } @@ -3629,7 +3629,7 @@ static void LOG1PFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::LOG1P, FloatMaxVectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG1P, FloatMaxVectorTests::strictLOG1P); } @@ -3653,7 +3653,7 @@ static void LOGFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::LOG, FloatMaxVectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG, FloatMaxVectorTests::strictLOG); } @@ -3677,7 +3677,7 @@ static void LOG10FloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::LOG10, FloatMaxVectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG10, FloatMaxVectorTests::strictLOG10); } @@ -3701,7 +3701,7 @@ static void EXPM1FloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::EXPM1, FloatMaxVectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::EXPM1, FloatMaxVectorTests::strictEXPM1); } @@ -3725,7 +3725,7 @@ static void COSFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::COS, FloatMaxVectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::COS, FloatMaxVectorTests::strictCOS); } @@ -3749,7 +3749,7 @@ static void TANFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::TAN, FloatMaxVectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::TAN, FloatMaxVectorTests::strictTAN); } @@ -3773,7 +3773,7 @@ static void SINHFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::SINH, FloatMaxVectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::SINH, FloatMaxVectorTests::strictSINH); } @@ -3797,7 +3797,7 @@ static void COSHFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::COSH, FloatMaxVectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::COSH, FloatMaxVectorTests::strictCOSH); } @@ -3821,7 +3821,7 @@ static void TANHFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::TANH, FloatMaxVectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::TANH, FloatMaxVectorTests::strictTANH); } @@ -3845,7 +3845,7 @@ static void ASINFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::ASIN, FloatMaxVectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ASIN, FloatMaxVectorTests::strictASIN); } @@ -3869,7 +3869,7 @@ static void ACOSFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::ACOS, FloatMaxVectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ACOS, FloatMaxVectorTests::strictACOS); } @@ -3893,7 +3893,7 @@ static void ATANFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::ATAN, FloatMaxVectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ATAN, FloatMaxVectorTests::strictATAN); } @@ -3917,7 +3917,7 @@ static void CBRTFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEqualsWithinOneUlp(a, r, FloatMaxVectorTests::CBRT, FloatMaxVectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::CBRT, FloatMaxVectorTests::strictCBRT); } @@ -3943,7 +3943,7 @@ static void HYPOTFloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); } static float pow(float a, float b) { @@ -3995,7 +3995,7 @@ static void powFloatMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEqualsWithinOneUlp(a, b, r, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); } @@ -4022,7 +4022,7 @@ static void ATAN2FloatMaxVectorTests(IntFunction fa, IntFunction fa, In av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4052,7 +4052,7 @@ static void powFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); } @@ -4081,7 +4081,7 @@ static void FMAFloatMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, FloatMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4097,7 +4097,7 @@ static void fmaFloatMaxVectorTests(IntFunction fa, IntFunction av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, FloatMaxVectorTests::fma); + assertArraysEquals(r, a, b, c, FloatMaxVectorTests::fma); } @@ -4120,7 +4120,7 @@ static void FMAFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, In FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, FloatMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4154,7 +4154,7 @@ static void FMAFloatMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, FloatMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); } @@ -4174,7 +4174,7 @@ static void FMAFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, FloatMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatMaxVectorTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") @@ -4193,7 +4193,7 @@ static void FMAFloatMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, FloatMaxVectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") static void fmaFloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4225,7 +4225,7 @@ static void fmaFloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, FloatMaxVectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::fma); } @@ -4244,7 +4244,7 @@ static void FMAFloatMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::NEG); + assertArraysEquals(r, a, FloatMaxVectorTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4285,7 +4285,7 @@ static void negFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::neg); + assertArraysEquals(r, a, FloatMaxVectorTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4303,7 +4303,7 @@ static void NEGMaskedFloatMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, FloatMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, FloatMaxVectorTests::NEG); } static float ABS(float a) { @@ -4326,7 +4326,7 @@ static void ABSFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::ABS); + assertArraysEquals(r, a, FloatMaxVectorTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4341,7 +4341,7 @@ static void absFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::abs); + assertArraysEquals(r, a, FloatMaxVectorTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") @@ -4359,7 +4359,7 @@ static void ABSMaskedFloatMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, FloatMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, FloatMaxVectorTests::ABS); } @@ -4391,7 +4391,7 @@ static void SQRTFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::SQRT); + assertArraysEquals(r, a, FloatMaxVectorTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4406,7 +4406,7 @@ static void sqrtFloatMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, FloatMaxVectorTests::sqrt); + assertArraysEquals(r, a, FloatMaxVectorTests::sqrt); } @@ -4426,7 +4426,7 @@ static void SQRTMaskedFloatMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, FloatMaxVectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatMaxVectorTests::SQRT); } static float[] gather(float a[], int ix, int[] b, int iy) { @@ -4451,7 +4451,7 @@ static void gatherFloatMaxVectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, FloatMaxVectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::gatherMasked); } static float[] scatter(float a[], int ix, int[] b, int iy) { @@ -4504,7 +4504,7 @@ static void scatterFloatMaxVectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, FloatMaxVectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::scatterMasked); } @@ -4584,8 +4584,8 @@ static void toIntArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4595,8 +4595,8 @@ static void toLongArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4606,8 +4606,8 @@ static void toDoubleArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4673,7 +4673,7 @@ static void ADDReduceLongFloatMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, FloatMaxVectorTests::ADDReduceLong, FloatMaxVectorTests::ADDReduceAllLong); } @@ -4714,7 +4714,7 @@ static void ADDReduceLongFloatMaxVectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, FloatMaxVectorTests::ADDReduceLongMasked, FloatMaxVectorTests::ADDReduceAllLongMasked); } @@ -4726,7 +4726,7 @@ static void BroadcastLongFloatMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "floatBinaryOpMaskProvider") @@ -4744,7 +4744,7 @@ static void blendFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, FloatMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatMaxVectorTests::blend); } @@ -4761,7 +4761,7 @@ static void SelectFromFloatMaxVectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") @@ -4780,7 +4780,7 @@ static void SelectFromFloatMaxVectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4857,7 +4857,7 @@ static void maskEqFloatMaxVectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, FloatMaxVectorTests::beq); + assertArraysEquals(r, a, b, FloatMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java index 3a9dd68b0f0..92bf7df4d11 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Int128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Int128VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Int128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(int[] a, int[] r, boolean[] mask) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0, "at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(int[] a, int[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "intProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new int[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index aff5150fc53..5139c08801d 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Int128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { int apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { int[] apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { int apply(int[] a); } - static void assertReductionArraysEquals(int[] a, int[] b, int c, + static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { int apply(int[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(int[] a, int[] b, int c, boolean[] mask, + static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(int[] a); } - static void assertReductionLongArraysEquals(int[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(int[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(int[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(int[] a, int[] b, int element, int index) { + static void assertInsertArraysEquals(int[] r, int[] a, int element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vecto } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vect } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[ } } - static void assertBroadcastArraysEquals(int[]a, int[]r) { + static void assertBroadcastArraysEquals(int[] r, int[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMa } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mas } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTer } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, F } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, bool } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, b } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { int apply(int[] a, int b); } - static void assertArraysEquals(int[] a, int[] r, FBinArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, FGatherScatterOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatt } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { int[] apply(int[] a, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { + static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { int[] apply(int[] a, int[] b, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { int[] apply(int[] a, int[] b, int origin, int part, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } - static void assertArraysEquals(int[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(int[] a, int[] r, int offs) { - static void assertArraysEquals(int[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(int[] a, long[] r, int offs) { } } - static void assertArraysEquals(int[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1254,7 +1254,7 @@ static void ADDInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::ADD); + assertArraysEquals(r, a, b, Int128VectorTests::ADD); } static int add(int a, int b) { return (int)(a + b); @@ -1272,7 +1272,7 @@ static void addInt128VectorTests(IntFunction fa, IntFunction fb) { av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::add); + assertArraysEquals(r, a, b, Int128VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1292,7 +1292,7 @@ static void ADDInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Int128VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1310,7 +1310,7 @@ static void addInt128VectorTestsMasked(IntFunction fa, IntFunction av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int128VectorTests::add); + assertArraysEquals(r, a, b, mask, Int128VectorTests::add); } static int SUB(int a, int b) { return (int)(a - b); @@ -1330,7 +1330,7 @@ static void SUBInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::SUB); + assertArraysEquals(r, a, b, Int128VectorTests::SUB); } static int sub(int a, int b) { return (int)(a - b); @@ -1348,7 +1348,7 @@ static void subInt128VectorTests(IntFunction fa, IntFunction fb) { av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::sub); + assertArraysEquals(r, a, b, Int128VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1368,7 +1368,7 @@ static void SUBInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Int128VectorTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1386,7 +1386,7 @@ static void subInt128VectorTestsMasked(IntFunction fa, IntFunction av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int128VectorTests::sub); + assertArraysEquals(r, a, b, mask, Int128VectorTests::sub); } static int MUL(int a, int b) { return (int)(a * b); @@ -1406,7 +1406,7 @@ static void MULInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::MUL); + assertArraysEquals(r, a, b, Int128VectorTests::MUL); } static int mul(int a, int b) { return (int)(a * b); @@ -1424,7 +1424,7 @@ static void mulInt128VectorTests(IntFunction fa, IntFunction fb) { av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::mul); + assertArraysEquals(r, a, b, Int128VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void MULInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Int128VectorTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1462,7 +1462,7 @@ static void mulInt128VectorTestsMasked(IntFunction fa, IntFunction av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int128VectorTests::mul); + assertArraysEquals(r, a, b, mask, Int128VectorTests::mul); } @@ -1487,7 +1487,7 @@ static void DIVInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::DIV); + assertArraysEquals(r, a, b, Int128VectorTests::DIV); } static int div(int a, int b) { return (int)(a / b); @@ -1509,7 +1509,7 @@ static void divInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::div); + assertArraysEquals(r, a, b, Int128VectorTests::div); } @@ -1533,7 +1533,7 @@ static void DIVInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Int128VectorTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1555,7 +1555,7 @@ static void divInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::div); + assertArraysEquals(r, a, b, mask, Int128VectorTests::div); } static int FIRST_NONZERO(int a, int b) { @@ -1576,7 +1576,7 @@ static void FIRST_NONZEROInt128VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Int128VectorTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -1617,7 +1617,7 @@ static void ANDInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::AND); + assertArraysEquals(r, a, b, Int128VectorTests::AND); } static int and(int a, int b) { return (int)(a & b); @@ -1635,7 +1635,7 @@ static void andInt128VectorTests(IntFunction fa, IntFunction fb) { av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::and); + assertArraysEquals(r, a, b, Int128VectorTests::and); } @@ -1657,7 +1657,7 @@ static void ANDInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::AND); + assertArraysEquals(r, a, b, mask, Int128VectorTests::AND); } @@ -1679,7 +1679,7 @@ static void AND_NOTInt128VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Int128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Int128VectorTests::AND_NOT); } @@ -1701,7 +1701,7 @@ static void AND_NOTInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::OR); + assertArraysEquals(r, a, b, Int128VectorTests::OR); } static int or(int a, int b) { return (int)(a | b); @@ -1741,7 +1741,7 @@ static void orInt128VectorTests(IntFunction fa, IntFunction fb) { av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::or); + assertArraysEquals(r, a, b, Int128VectorTests::or); } @@ -1763,7 +1763,7 @@ static void ORInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::OR); + assertArraysEquals(r, a, b, mask, Int128VectorTests::OR); } @@ -1785,7 +1785,7 @@ static void XORInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::XOR); + assertArraysEquals(r, a, b, Int128VectorTests::XOR); } @@ -1807,7 +1807,7 @@ static void XORInt128VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::XOR); + assertArraysEquals(r, a, b, mask, Int128VectorTests::XOR); } @@ -1822,7 +1822,7 @@ static void addInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1839,7 +1839,7 @@ static void addInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::add); } @Test(dataProvider = "intBinaryOpProvider") @@ -1853,7 +1853,7 @@ static void subInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1870,7 +1870,7 @@ static void subInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::sub); } @Test(dataProvider = "intBinaryOpProvider") @@ -1884,7 +1884,7 @@ static void mulInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void mulInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::mul); } @@ -1920,7 +1920,7 @@ static void divInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::div); } @@ -1941,7 +1941,7 @@ static void divInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::div); } @@ -1957,7 +1957,7 @@ static void ORInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::OR); } @Test(dataProvider = "intBinaryOpProvider") @@ -1971,7 +1971,7 @@ static void orInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::or); } @@ -1990,7 +1990,7 @@ static void ORInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::OR); } @@ -2006,7 +2006,7 @@ static void ANDInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::AND); } @Test(dataProvider = "intBinaryOpProvider") @@ -2020,7 +2020,7 @@ static void andInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::and); } @@ -2039,7 +2039,7 @@ static void ANDInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::AND); } @@ -2055,7 +2055,7 @@ static void ORInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::OR); } @@ -2074,7 +2074,7 @@ static void ORInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::OR); } @@ -2089,7 +2089,7 @@ static void ADDInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -2106,7 +2106,7 @@ static void ADDInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::ADD); } static int LSHL(int a, int b) { @@ -2127,7 +2127,7 @@ static void LSHLInt128VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int128VectorTests::LSHL); + assertArraysEquals(r, a, b, Int128VectorTests::LSHL); } @@ -2149,7 +2149,7 @@ static void LSHLInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int128VectorTests::ASHR); + assertArraysEquals(r, a, b, Int128VectorTests::ASHR); } @@ -2197,7 +2197,7 @@ static void ASHRInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int128VectorTests::LSHR); + assertArraysEquals(r, a, b, Int128VectorTests::LSHR); } @@ -2245,7 +2245,7 @@ static void LSHRInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHL_unary); } @@ -2291,7 +2291,7 @@ static void LSHLInt128VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHL_unary); } @@ -2316,7 +2316,7 @@ static void LSHRInt128VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHR_unary); } @@ -2337,7 +2337,7 @@ static void LSHRInt128VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHR_unary); } @@ -2362,7 +2362,7 @@ static void ASHRInt128VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, Int128VectorTests::ASHR_unary); } @@ -2383,7 +2383,7 @@ static void ASHRInt128VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ASHR_unary); } @@ -2408,7 +2408,7 @@ static void MINInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::MIN); + assertArraysEquals(r, a, b, Int128VectorTests::MIN); } static int min(int a, int b) { return (int)(Math.min(a, b)); @@ -2426,7 +2426,7 @@ static void minInt128VectorTests(IntFunction fa, IntFunction fb) { av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::min); + assertArraysEquals(r, a, b, Int128VectorTests::min); } static int MAX(int a, int b) { return (int)(Math.max(a, b)); @@ -2446,7 +2446,7 @@ static void MAXInt128VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int128VectorTests::MAX); + assertArraysEquals(r, a, b, Int128VectorTests::MAX); } static int max(int a, int b) { return (int)(Math.max(a, b)); @@ -2464,7 +2464,7 @@ static void maxInt128VectorTests(IntFunction fa, IntFunction fb) { av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::max); + assertArraysEquals(r, a, b, Int128VectorTests::max); } @Test(dataProvider = "intBinaryOpProvider") @@ -2478,7 +2478,7 @@ static void MINInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") @@ -2492,7 +2492,7 @@ static void minInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::min); } @Test(dataProvider = "intBinaryOpProvider") @@ -2506,7 +2506,7 @@ static void MAXInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") @@ -2520,7 +2520,7 @@ static void maxInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Int128VectorTests::max); } static int ANDReduce(int[] a, int idx) { @@ -2563,7 +2563,7 @@ static void ANDReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::ANDReduce, Int128VectorTests::ANDReduceAll); } @@ -2611,7 +2611,7 @@ static void ANDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::ANDReduceMasked, Int128VectorTests::ANDReduceAllMasked); } @@ -2656,7 +2656,7 @@ static void ORReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::ORReduce, Int128VectorTests::ORReduceAll); } @@ -2704,7 +2704,7 @@ static void ORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::XORReduce, Int128VectorTests::XORReduceAll); } @@ -2797,7 +2797,7 @@ static void XORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::XORReduceMasked, Int128VectorTests::XORReduceAllMasked); } @@ -2839,7 +2839,7 @@ static void ADDReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::ADDReduce, Int128VectorTests::ADDReduceAll); } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2883,7 +2883,7 @@ static void ADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::ADDReduceMasked, Int128VectorTests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { @@ -2924,7 +2924,7 @@ static void MULReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::MULReduce, Int128VectorTests::MULReduceAll); } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2968,7 +2968,7 @@ static void MULReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::MULReduceMasked, Int128VectorTests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { @@ -3009,7 +3009,7 @@ static void MINReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::MINReduce, Int128VectorTests::MINReduceAll); } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3054,7 +3054,7 @@ static void MINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::MINReduceMasked, Int128VectorTests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { @@ -3095,7 +3095,7 @@ static void MAXReduceInt128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int128VectorTests::MAXReduce, Int128VectorTests::MAXReduceAll); } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3140,7 +3140,7 @@ static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::MAXReduceMasked, Int128VectorTests::MAXReduceAllMasked); } @@ -3166,7 +3166,7 @@ static void anyTrueInt128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Int128VectorTests::anyTrue); } @@ -3192,7 +3192,7 @@ static void allTrueInt128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Int128VectorTests::allTrue); } @@ -3208,7 +3208,7 @@ static void withInt128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (int)4, 0); + assertInsertArraysEquals(r, a, (int)4, 0); } static boolean testIS_DEFAULT(int a) { return bits(a)==0; @@ -3757,7 +3757,7 @@ static void blendInt128VectorTests(IntFunction fa, IntFunction fb, } } - assertArraysEquals(a, b, r, mask, Int128VectorTests::blend); + assertArraysEquals(r, a, b, mask, Int128VectorTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") @@ -3774,7 +3774,7 @@ static void RearrangeInt128VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -3792,7 +3792,7 @@ static void RearrangeInt128VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "intUnaryOpProvider") static void getInt128VectorTests(IntFunction fa) { @@ -3947,7 +3947,7 @@ static void getInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::get); + assertArraysEquals(r, a, Int128VectorTests::get); } @Test(dataProvider = "intUnaryOpProvider") @@ -3961,7 +3961,7 @@ static void BroadcastInt128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4008,7 +4008,7 @@ static void sliceUnaryInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Int128VectorTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { int[] res = new int[SPECIES.length()]; @@ -4037,7 +4037,7 @@ static void sliceBinaryInt128VectorTestsBinary(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, Int128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Int128VectorTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4070,7 +4070,7 @@ static void sliceInt128VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Int128VectorTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { int[] res = new int[SPECIES.length()]; @@ -4136,7 +4136,7 @@ static void unsliceBinaryInt128VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, Int128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Int128VectorTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4192,7 +4192,7 @@ static void unsliceInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4257,7 +4257,7 @@ static void bitwiseBlendInt128VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, c, r, mask, Int128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND); } @@ -4298,7 +4298,7 @@ static void BITWISE_BLENDInt128VectorTestsBroadcastSmokeTest(IntFunction IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") @@ -4313,7 +4313,7 @@ static void BITWISE_BLENDInt128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4327,7 +4327,7 @@ static void bitwiseBlendInt128VectorTestsBroadcastSmokeTest(IntFunction f IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") @@ -4342,7 +4342,7 @@ static void bitwiseBlendInt128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4413,7 +4413,7 @@ static void bitwiseBlendInt128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::NEG); + assertArraysEquals(r, a, Int128VectorTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") @@ -4471,7 +4471,7 @@ static void negInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::neg); + assertArraysEquals(r, a, Int128VectorTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4489,7 +4489,7 @@ static void NEGMaskedInt128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int128VectorTests::NEG); + assertArraysEquals(r, a, mask, Int128VectorTests::NEG); } static int ABS(int a) { @@ -4512,7 +4512,7 @@ static void ABSInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::ABS); + assertArraysEquals(r, a, Int128VectorTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") @@ -4527,7 +4527,7 @@ static void absInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::abs); + assertArraysEquals(r, a, Int128VectorTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4545,7 +4545,7 @@ static void ABSMaskedInt128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int128VectorTests::ABS); + assertArraysEquals(r, a, mask, Int128VectorTests::ABS); } @@ -4571,7 +4571,7 @@ static void NOTInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::NOT); + assertArraysEquals(r, a, Int128VectorTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") @@ -4586,7 +4586,7 @@ static void notInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::not); + assertArraysEquals(r, a, Int128VectorTests::not); } @@ -4606,7 +4606,7 @@ static void NOTMaskedInt128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int128VectorTests::NOT); + assertArraysEquals(r, a, mask, Int128VectorTests::NOT); } @@ -4629,7 +4629,7 @@ static void ZOMOInt128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int128VectorTests::ZOMO); + assertArraysEquals(r, a, Int128VectorTests::ZOMO); } @@ -4649,7 +4649,7 @@ static void ZOMOMaskedInt128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Int128VectorTests::ZOMO); } @@ -4677,7 +4677,7 @@ static void gatherInt128VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4821,8 +4821,8 @@ static void toLongArrayInt128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4832,8 +4832,8 @@ static void toDoubleArrayInt128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4899,7 +4899,7 @@ static void ADDReduceLongInt128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Int128VectorTests::ADDReduceLong, Int128VectorTests::ADDReduceAllLong); } @@ -4940,7 +4940,7 @@ static void ADDReduceLongInt128VectorTestsMasked(IntFunction fa, IntFunct ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Int128VectorTests::ADDReduceLongMasked, Int128VectorTests::ADDReduceAllLongMasked); } @@ -4952,7 +4952,7 @@ static void BroadcastLongInt128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -4970,7 +4970,7 @@ static void blendInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Int128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::blend); } @@ -4987,7 +4987,7 @@ static void SelectFromInt128VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -5006,7 +5006,7 @@ static void SelectFromInt128VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5083,7 +5083,7 @@ static void maskEqInt128VectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Int128VectorTests::beq); + assertArraysEquals(r, a, b, Int128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java index 66005366309..6f43ed2f0f2 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Int256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Int256VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Int256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(int[] a, int[] r, boolean[] mask) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0, "at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(int[] a, int[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "intProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new int[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index df682b3540b..37e44fa3f3d 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Int256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { int apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { int[] apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { int apply(int[] a); } - static void assertReductionArraysEquals(int[] a, int[] b, int c, + static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { int apply(int[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(int[] a, int[] b, int c, boolean[] mask, + static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(int[] a); } - static void assertReductionLongArraysEquals(int[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(int[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(int[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(int[] a, int[] b, int element, int index) { + static void assertInsertArraysEquals(int[] r, int[] a, int element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vecto } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vect } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[ } } - static void assertBroadcastArraysEquals(int[]a, int[]r) { + static void assertBroadcastArraysEquals(int[] r, int[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMa } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mas } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTer } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, F } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, bool } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, b } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { int apply(int[] a, int b); } - static void assertArraysEquals(int[] a, int[] r, FBinArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, FGatherScatterOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatt } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { int[] apply(int[] a, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { + static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { int[] apply(int[] a, int[] b, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { int[] apply(int[] a, int[] b, int origin, int part, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } - static void assertArraysEquals(int[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(int[] a, int[] r, int offs) { - static void assertArraysEquals(int[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(int[] a, long[] r, int offs) { } } - static void assertArraysEquals(int[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1254,7 +1254,7 @@ static void ADDInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::ADD); + assertArraysEquals(r, a, b, Int256VectorTests::ADD); } static int add(int a, int b) { return (int)(a + b); @@ -1272,7 +1272,7 @@ static void addInt256VectorTests(IntFunction fa, IntFunction fb) { av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::add); + assertArraysEquals(r, a, b, Int256VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1292,7 +1292,7 @@ static void ADDInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Int256VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1310,7 +1310,7 @@ static void addInt256VectorTestsMasked(IntFunction fa, IntFunction av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int256VectorTests::add); + assertArraysEquals(r, a, b, mask, Int256VectorTests::add); } static int SUB(int a, int b) { return (int)(a - b); @@ -1330,7 +1330,7 @@ static void SUBInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::SUB); + assertArraysEquals(r, a, b, Int256VectorTests::SUB); } static int sub(int a, int b) { return (int)(a - b); @@ -1348,7 +1348,7 @@ static void subInt256VectorTests(IntFunction fa, IntFunction fb) { av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::sub); + assertArraysEquals(r, a, b, Int256VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1368,7 +1368,7 @@ static void SUBInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Int256VectorTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1386,7 +1386,7 @@ static void subInt256VectorTestsMasked(IntFunction fa, IntFunction av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int256VectorTests::sub); + assertArraysEquals(r, a, b, mask, Int256VectorTests::sub); } static int MUL(int a, int b) { return (int)(a * b); @@ -1406,7 +1406,7 @@ static void MULInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::MUL); + assertArraysEquals(r, a, b, Int256VectorTests::MUL); } static int mul(int a, int b) { return (int)(a * b); @@ -1424,7 +1424,7 @@ static void mulInt256VectorTests(IntFunction fa, IntFunction fb) { av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::mul); + assertArraysEquals(r, a, b, Int256VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void MULInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Int256VectorTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1462,7 +1462,7 @@ static void mulInt256VectorTestsMasked(IntFunction fa, IntFunction av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int256VectorTests::mul); + assertArraysEquals(r, a, b, mask, Int256VectorTests::mul); } @@ -1487,7 +1487,7 @@ static void DIVInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::DIV); + assertArraysEquals(r, a, b, Int256VectorTests::DIV); } static int div(int a, int b) { return (int)(a / b); @@ -1509,7 +1509,7 @@ static void divInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::div); + assertArraysEquals(r, a, b, Int256VectorTests::div); } @@ -1533,7 +1533,7 @@ static void DIVInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Int256VectorTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1555,7 +1555,7 @@ static void divInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::div); + assertArraysEquals(r, a, b, mask, Int256VectorTests::div); } static int FIRST_NONZERO(int a, int b) { @@ -1576,7 +1576,7 @@ static void FIRST_NONZEROInt256VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Int256VectorTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -1617,7 +1617,7 @@ static void ANDInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::AND); + assertArraysEquals(r, a, b, Int256VectorTests::AND); } static int and(int a, int b) { return (int)(a & b); @@ -1635,7 +1635,7 @@ static void andInt256VectorTests(IntFunction fa, IntFunction fb) { av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::and); + assertArraysEquals(r, a, b, Int256VectorTests::and); } @@ -1657,7 +1657,7 @@ static void ANDInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::AND); + assertArraysEquals(r, a, b, mask, Int256VectorTests::AND); } @@ -1679,7 +1679,7 @@ static void AND_NOTInt256VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Int256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Int256VectorTests::AND_NOT); } @@ -1701,7 +1701,7 @@ static void AND_NOTInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::OR); + assertArraysEquals(r, a, b, Int256VectorTests::OR); } static int or(int a, int b) { return (int)(a | b); @@ -1741,7 +1741,7 @@ static void orInt256VectorTests(IntFunction fa, IntFunction fb) { av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::or); + assertArraysEquals(r, a, b, Int256VectorTests::or); } @@ -1763,7 +1763,7 @@ static void ORInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::OR); + assertArraysEquals(r, a, b, mask, Int256VectorTests::OR); } @@ -1785,7 +1785,7 @@ static void XORInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::XOR); + assertArraysEquals(r, a, b, Int256VectorTests::XOR); } @@ -1807,7 +1807,7 @@ static void XORInt256VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::XOR); + assertArraysEquals(r, a, b, mask, Int256VectorTests::XOR); } @@ -1822,7 +1822,7 @@ static void addInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1839,7 +1839,7 @@ static void addInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::add); } @Test(dataProvider = "intBinaryOpProvider") @@ -1853,7 +1853,7 @@ static void subInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1870,7 +1870,7 @@ static void subInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::sub); } @Test(dataProvider = "intBinaryOpProvider") @@ -1884,7 +1884,7 @@ static void mulInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void mulInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::mul); } @@ -1920,7 +1920,7 @@ static void divInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::div); } @@ -1941,7 +1941,7 @@ static void divInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::div); } @@ -1957,7 +1957,7 @@ static void ORInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::OR); } @Test(dataProvider = "intBinaryOpProvider") @@ -1971,7 +1971,7 @@ static void orInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::or); } @@ -1990,7 +1990,7 @@ static void ORInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::OR); } @@ -2006,7 +2006,7 @@ static void ANDInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::AND); } @Test(dataProvider = "intBinaryOpProvider") @@ -2020,7 +2020,7 @@ static void andInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::and); } @@ -2039,7 +2039,7 @@ static void ANDInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::AND); } @@ -2055,7 +2055,7 @@ static void ORInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Int256VectorTests::OR); } @@ -2074,7 +2074,7 @@ static void ORInt256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::OR); } @@ -2089,7 +2089,7 @@ static void ADDInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Int256VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -2106,7 +2106,7 @@ static void ADDInt256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::ADD); } static int LSHL(int a, int b) { @@ -2127,7 +2127,7 @@ static void LSHLInt256VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int256VectorTests::LSHL); + assertArraysEquals(r, a, b, Int256VectorTests::LSHL); } @@ -2149,7 +2149,7 @@ static void LSHLInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int256VectorTests::ASHR); + assertArraysEquals(r, a, b, Int256VectorTests::ASHR); } @@ -2197,7 +2197,7 @@ static void ASHRInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int256VectorTests::LSHR); + assertArraysEquals(r, a, b, Int256VectorTests::LSHR); } @@ -2245,7 +2245,7 @@ static void LSHRInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, Int256VectorTests::LSHL_unary); } @@ -2291,7 +2291,7 @@ static void LSHLInt256VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::LSHL_unary); } @@ -2316,7 +2316,7 @@ static void LSHRInt256VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, Int256VectorTests::LSHR_unary); } @@ -2337,7 +2337,7 @@ static void LSHRInt256VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::LSHR_unary); } @@ -2362,7 +2362,7 @@ static void ASHRInt256VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, Int256VectorTests::ASHR_unary); } @@ -2383,7 +2383,7 @@ static void ASHRInt256VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::ASHR_unary); } @@ -2408,7 +2408,7 @@ static void MINInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::MIN); + assertArraysEquals(r, a, b, Int256VectorTests::MIN); } static int min(int a, int b) { return (int)(Math.min(a, b)); @@ -2426,7 +2426,7 @@ static void minInt256VectorTests(IntFunction fa, IntFunction fb) { av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::min); + assertArraysEquals(r, a, b, Int256VectorTests::min); } static int MAX(int a, int b) { return (int)(Math.max(a, b)); @@ -2446,7 +2446,7 @@ static void MAXInt256VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int256VectorTests::MAX); + assertArraysEquals(r, a, b, Int256VectorTests::MAX); } static int max(int a, int b) { return (int)(Math.max(a, b)); @@ -2464,7 +2464,7 @@ static void maxInt256VectorTests(IntFunction fa, IntFunction fb) { av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::max); + assertArraysEquals(r, a, b, Int256VectorTests::max); } @Test(dataProvider = "intBinaryOpProvider") @@ -2478,7 +2478,7 @@ static void MINInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") @@ -2492,7 +2492,7 @@ static void minInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::min); } @Test(dataProvider = "intBinaryOpProvider") @@ -2506,7 +2506,7 @@ static void MAXInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") @@ -2520,7 +2520,7 @@ static void maxInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Int256VectorTests::max); } static int ANDReduce(int[] a, int idx) { @@ -2563,7 +2563,7 @@ static void ANDReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::ANDReduce, Int256VectorTests::ANDReduceAll); } @@ -2611,7 +2611,7 @@ static void ANDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::ANDReduceMasked, Int256VectorTests::ANDReduceAllMasked); } @@ -2656,7 +2656,7 @@ static void ORReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::ORReduce, Int256VectorTests::ORReduceAll); } @@ -2704,7 +2704,7 @@ static void ORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::XORReduce, Int256VectorTests::XORReduceAll); } @@ -2797,7 +2797,7 @@ static void XORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::XORReduceMasked, Int256VectorTests::XORReduceAllMasked); } @@ -2839,7 +2839,7 @@ static void ADDReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::ADDReduce, Int256VectorTests::ADDReduceAll); } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2883,7 +2883,7 @@ static void ADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::ADDReduceMasked, Int256VectorTests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { @@ -2924,7 +2924,7 @@ static void MULReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::MULReduce, Int256VectorTests::MULReduceAll); } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2968,7 +2968,7 @@ static void MULReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::MULReduceMasked, Int256VectorTests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { @@ -3009,7 +3009,7 @@ static void MINReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::MINReduce, Int256VectorTests::MINReduceAll); } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3054,7 +3054,7 @@ static void MINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::MINReduceMasked, Int256VectorTests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { @@ -3095,7 +3095,7 @@ static void MAXReduceInt256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int256VectorTests::MAXReduce, Int256VectorTests::MAXReduceAll); } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3140,7 +3140,7 @@ static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::MAXReduceMasked, Int256VectorTests::MAXReduceAllMasked); } @@ -3166,7 +3166,7 @@ static void anyTrueInt256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Int256VectorTests::anyTrue); } @@ -3192,7 +3192,7 @@ static void allTrueInt256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Int256VectorTests::allTrue); } @@ -3208,7 +3208,7 @@ static void withInt256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (int)4, 0); + assertInsertArraysEquals(r, a, (int)4, 0); } static boolean testIS_DEFAULT(int a) { return bits(a)==0; @@ -3757,7 +3757,7 @@ static void blendInt256VectorTests(IntFunction fa, IntFunction fb, } } - assertArraysEquals(a, b, r, mask, Int256VectorTests::blend); + assertArraysEquals(r, a, b, mask, Int256VectorTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") @@ -3774,7 +3774,7 @@ static void RearrangeInt256VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -3792,7 +3792,7 @@ static void RearrangeInt256VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "intUnaryOpProvider") static void getInt256VectorTests(IntFunction fa) { @@ -3947,7 +3947,7 @@ static void getInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::get); + assertArraysEquals(r, a, Int256VectorTests::get); } @Test(dataProvider = "intUnaryOpProvider") @@ -3961,7 +3961,7 @@ static void BroadcastInt256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4008,7 +4008,7 @@ static void sliceUnaryInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Int256VectorTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { int[] res = new int[SPECIES.length()]; @@ -4037,7 +4037,7 @@ static void sliceBinaryInt256VectorTestsBinary(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, Int256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Int256VectorTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4070,7 +4070,7 @@ static void sliceInt256VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Int256VectorTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { int[] res = new int[SPECIES.length()]; @@ -4136,7 +4136,7 @@ static void unsliceBinaryInt256VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, Int256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Int256VectorTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4192,7 +4192,7 @@ static void unsliceInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4257,7 +4257,7 @@ static void bitwiseBlendInt256VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, c, r, mask, Int256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Int256VectorTests::BITWISE_BLEND); } @@ -4298,7 +4298,7 @@ static void BITWISE_BLENDInt256VectorTestsBroadcastSmokeTest(IntFunction IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Int256VectorTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") @@ -4313,7 +4313,7 @@ static void BITWISE_BLENDInt256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4327,7 +4327,7 @@ static void bitwiseBlendInt256VectorTestsBroadcastSmokeTest(IntFunction f IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Int256VectorTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") @@ -4342,7 +4342,7 @@ static void bitwiseBlendInt256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4413,7 +4413,7 @@ static void bitwiseBlendInt256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::NEG); + assertArraysEquals(r, a, Int256VectorTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") @@ -4471,7 +4471,7 @@ static void negInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::neg); + assertArraysEquals(r, a, Int256VectorTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4489,7 +4489,7 @@ static void NEGMaskedInt256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int256VectorTests::NEG); + assertArraysEquals(r, a, mask, Int256VectorTests::NEG); } static int ABS(int a) { @@ -4512,7 +4512,7 @@ static void ABSInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::ABS); + assertArraysEquals(r, a, Int256VectorTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") @@ -4527,7 +4527,7 @@ static void absInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::abs); + assertArraysEquals(r, a, Int256VectorTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4545,7 +4545,7 @@ static void ABSMaskedInt256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int256VectorTests::ABS); + assertArraysEquals(r, a, mask, Int256VectorTests::ABS); } @@ -4571,7 +4571,7 @@ static void NOTInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::NOT); + assertArraysEquals(r, a, Int256VectorTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") @@ -4586,7 +4586,7 @@ static void notInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::not); + assertArraysEquals(r, a, Int256VectorTests::not); } @@ -4606,7 +4606,7 @@ static void NOTMaskedInt256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int256VectorTests::NOT); + assertArraysEquals(r, a, mask, Int256VectorTests::NOT); } @@ -4629,7 +4629,7 @@ static void ZOMOInt256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int256VectorTests::ZOMO); + assertArraysEquals(r, a, Int256VectorTests::ZOMO); } @@ -4649,7 +4649,7 @@ static void ZOMOMaskedInt256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Int256VectorTests::ZOMO); } @@ -4677,7 +4677,7 @@ static void gatherInt256VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4821,8 +4821,8 @@ static void toLongArrayInt256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4832,8 +4832,8 @@ static void toDoubleArrayInt256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4899,7 +4899,7 @@ static void ADDReduceLongInt256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Int256VectorTests::ADDReduceLong, Int256VectorTests::ADDReduceAllLong); } @@ -4940,7 +4940,7 @@ static void ADDReduceLongInt256VectorTestsMasked(IntFunction fa, IntFunct ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Int256VectorTests::ADDReduceLongMasked, Int256VectorTests::ADDReduceAllLongMasked); } @@ -4952,7 +4952,7 @@ static void BroadcastLongInt256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -4970,7 +4970,7 @@ static void blendInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Int256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::blend); } @@ -4987,7 +4987,7 @@ static void SelectFromInt256VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -5006,7 +5006,7 @@ static void SelectFromInt256VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5083,7 +5083,7 @@ static void maskEqInt256VectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Int256VectorTests::beq); + assertArraysEquals(r, a, b, Int256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java index b7712421aaa..d0ed4682c1d 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Int512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Int512VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Int512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(int[] a, int[] r, boolean[] mask) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0, "at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(int[] a, int[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "intProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new int[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index b4395ba1691..943cb444ec5 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Int512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { int apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { int[] apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { int apply(int[] a); } - static void assertReductionArraysEquals(int[] a, int[] b, int c, + static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { int apply(int[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(int[] a, int[] b, int c, boolean[] mask, + static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(int[] a); } - static void assertReductionLongArraysEquals(int[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(int[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(int[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(int[] a, int[] b, int element, int index) { + static void assertInsertArraysEquals(int[] r, int[] a, int element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vecto } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vect } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[ } } - static void assertBroadcastArraysEquals(int[]a, int[]r) { + static void assertBroadcastArraysEquals(int[] r, int[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMa } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mas } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTer } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, F } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, bool } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, b } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { int apply(int[] a, int b); } - static void assertArraysEquals(int[] a, int[] r, FBinArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, FGatherScatterOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatt } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { int[] apply(int[] a, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { + static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { int[] apply(int[] a, int[] b, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { int[] apply(int[] a, int[] b, int origin, int part, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } - static void assertArraysEquals(int[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(int[] a, int[] r, int offs) { - static void assertArraysEquals(int[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(int[] a, long[] r, int offs) { } } - static void assertArraysEquals(int[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1254,7 +1254,7 @@ static void ADDInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::ADD); + assertArraysEquals(r, a, b, Int512VectorTests::ADD); } static int add(int a, int b) { return (int)(a + b); @@ -1272,7 +1272,7 @@ static void addInt512VectorTests(IntFunction fa, IntFunction fb) { av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::add); + assertArraysEquals(r, a, b, Int512VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1292,7 +1292,7 @@ static void ADDInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Int512VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1310,7 +1310,7 @@ static void addInt512VectorTestsMasked(IntFunction fa, IntFunction av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int512VectorTests::add); + assertArraysEquals(r, a, b, mask, Int512VectorTests::add); } static int SUB(int a, int b) { return (int)(a - b); @@ -1330,7 +1330,7 @@ static void SUBInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::SUB); + assertArraysEquals(r, a, b, Int512VectorTests::SUB); } static int sub(int a, int b) { return (int)(a - b); @@ -1348,7 +1348,7 @@ static void subInt512VectorTests(IntFunction fa, IntFunction fb) { av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::sub); + assertArraysEquals(r, a, b, Int512VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1368,7 +1368,7 @@ static void SUBInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Int512VectorTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1386,7 +1386,7 @@ static void subInt512VectorTestsMasked(IntFunction fa, IntFunction av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int512VectorTests::sub); + assertArraysEquals(r, a, b, mask, Int512VectorTests::sub); } static int MUL(int a, int b) { return (int)(a * b); @@ -1406,7 +1406,7 @@ static void MULInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::MUL); + assertArraysEquals(r, a, b, Int512VectorTests::MUL); } static int mul(int a, int b) { return (int)(a * b); @@ -1424,7 +1424,7 @@ static void mulInt512VectorTests(IntFunction fa, IntFunction fb) { av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::mul); + assertArraysEquals(r, a, b, Int512VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void MULInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Int512VectorTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1462,7 +1462,7 @@ static void mulInt512VectorTestsMasked(IntFunction fa, IntFunction av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int512VectorTests::mul); + assertArraysEquals(r, a, b, mask, Int512VectorTests::mul); } @@ -1487,7 +1487,7 @@ static void DIVInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::DIV); + assertArraysEquals(r, a, b, Int512VectorTests::DIV); } static int div(int a, int b) { return (int)(a / b); @@ -1509,7 +1509,7 @@ static void divInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::div); + assertArraysEquals(r, a, b, Int512VectorTests::div); } @@ -1533,7 +1533,7 @@ static void DIVInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Int512VectorTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1555,7 +1555,7 @@ static void divInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::div); + assertArraysEquals(r, a, b, mask, Int512VectorTests::div); } static int FIRST_NONZERO(int a, int b) { @@ -1576,7 +1576,7 @@ static void FIRST_NONZEROInt512VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Int512VectorTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -1617,7 +1617,7 @@ static void ANDInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::AND); + assertArraysEquals(r, a, b, Int512VectorTests::AND); } static int and(int a, int b) { return (int)(a & b); @@ -1635,7 +1635,7 @@ static void andInt512VectorTests(IntFunction fa, IntFunction fb) { av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::and); + assertArraysEquals(r, a, b, Int512VectorTests::and); } @@ -1657,7 +1657,7 @@ static void ANDInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::AND); + assertArraysEquals(r, a, b, mask, Int512VectorTests::AND); } @@ -1679,7 +1679,7 @@ static void AND_NOTInt512VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Int512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Int512VectorTests::AND_NOT); } @@ -1701,7 +1701,7 @@ static void AND_NOTInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::OR); + assertArraysEquals(r, a, b, Int512VectorTests::OR); } static int or(int a, int b) { return (int)(a | b); @@ -1741,7 +1741,7 @@ static void orInt512VectorTests(IntFunction fa, IntFunction fb) { av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::or); + assertArraysEquals(r, a, b, Int512VectorTests::or); } @@ -1763,7 +1763,7 @@ static void ORInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::OR); + assertArraysEquals(r, a, b, mask, Int512VectorTests::OR); } @@ -1785,7 +1785,7 @@ static void XORInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::XOR); + assertArraysEquals(r, a, b, Int512VectorTests::XOR); } @@ -1807,7 +1807,7 @@ static void XORInt512VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::XOR); + assertArraysEquals(r, a, b, mask, Int512VectorTests::XOR); } @@ -1822,7 +1822,7 @@ static void addInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1839,7 +1839,7 @@ static void addInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::add); } @Test(dataProvider = "intBinaryOpProvider") @@ -1853,7 +1853,7 @@ static void subInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1870,7 +1870,7 @@ static void subInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::sub); } @Test(dataProvider = "intBinaryOpProvider") @@ -1884,7 +1884,7 @@ static void mulInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void mulInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::mul); } @@ -1920,7 +1920,7 @@ static void divInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::div); } @@ -1941,7 +1941,7 @@ static void divInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::div); } @@ -1957,7 +1957,7 @@ static void ORInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::OR); } @Test(dataProvider = "intBinaryOpProvider") @@ -1971,7 +1971,7 @@ static void orInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::or); } @@ -1990,7 +1990,7 @@ static void ORInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::OR); } @@ -2006,7 +2006,7 @@ static void ANDInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::AND); } @Test(dataProvider = "intBinaryOpProvider") @@ -2020,7 +2020,7 @@ static void andInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::and); } @@ -2039,7 +2039,7 @@ static void ANDInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::AND); } @@ -2055,7 +2055,7 @@ static void ORInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Int512VectorTests::OR); } @@ -2074,7 +2074,7 @@ static void ORInt512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::OR); } @@ -2089,7 +2089,7 @@ static void ADDInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Int512VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -2106,7 +2106,7 @@ static void ADDInt512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::ADD); } static int LSHL(int a, int b) { @@ -2127,7 +2127,7 @@ static void LSHLInt512VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int512VectorTests::LSHL); + assertArraysEquals(r, a, b, Int512VectorTests::LSHL); } @@ -2149,7 +2149,7 @@ static void LSHLInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int512VectorTests::ASHR); + assertArraysEquals(r, a, b, Int512VectorTests::ASHR); } @@ -2197,7 +2197,7 @@ static void ASHRInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Int512VectorTests::LSHR); + assertArraysEquals(r, a, b, Int512VectorTests::LSHR); } @@ -2245,7 +2245,7 @@ static void LSHRInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, Int512VectorTests::LSHL_unary); } @@ -2291,7 +2291,7 @@ static void LSHLInt512VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::LSHL_unary); } @@ -2316,7 +2316,7 @@ static void LSHRInt512VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, Int512VectorTests::LSHR_unary); } @@ -2337,7 +2337,7 @@ static void LSHRInt512VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::LSHR_unary); } @@ -2362,7 +2362,7 @@ static void ASHRInt512VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, Int512VectorTests::ASHR_unary); } @@ -2383,7 +2383,7 @@ static void ASHRInt512VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::ASHR_unary); } @@ -2408,7 +2408,7 @@ static void MINInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::MIN); + assertArraysEquals(r, a, b, Int512VectorTests::MIN); } static int min(int a, int b) { return (int)(Math.min(a, b)); @@ -2426,7 +2426,7 @@ static void minInt512VectorTests(IntFunction fa, IntFunction fb) { av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::min); + assertArraysEquals(r, a, b, Int512VectorTests::min); } static int MAX(int a, int b) { return (int)(Math.max(a, b)); @@ -2446,7 +2446,7 @@ static void MAXInt512VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int512VectorTests::MAX); + assertArraysEquals(r, a, b, Int512VectorTests::MAX); } static int max(int a, int b) { return (int)(Math.max(a, b)); @@ -2464,7 +2464,7 @@ static void maxInt512VectorTests(IntFunction fa, IntFunction fb) { av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::max); + assertArraysEquals(r, a, b, Int512VectorTests::max); } @Test(dataProvider = "intBinaryOpProvider") @@ -2478,7 +2478,7 @@ static void MINInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") @@ -2492,7 +2492,7 @@ static void minInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::min); } @Test(dataProvider = "intBinaryOpProvider") @@ -2506,7 +2506,7 @@ static void MAXInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") @@ -2520,7 +2520,7 @@ static void maxInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Int512VectorTests::max); } static int ANDReduce(int[] a, int idx) { @@ -2563,7 +2563,7 @@ static void ANDReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::ANDReduce, Int512VectorTests::ANDReduceAll); } @@ -2611,7 +2611,7 @@ static void ANDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::ANDReduceMasked, Int512VectorTests::ANDReduceAllMasked); } @@ -2656,7 +2656,7 @@ static void ORReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::ORReduce, Int512VectorTests::ORReduceAll); } @@ -2704,7 +2704,7 @@ static void ORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::XORReduce, Int512VectorTests::XORReduceAll); } @@ -2797,7 +2797,7 @@ static void XORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::XORReduceMasked, Int512VectorTests::XORReduceAllMasked); } @@ -2839,7 +2839,7 @@ static void ADDReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::ADDReduce, Int512VectorTests::ADDReduceAll); } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2883,7 +2883,7 @@ static void ADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::ADDReduceMasked, Int512VectorTests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { @@ -2924,7 +2924,7 @@ static void MULReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::MULReduce, Int512VectorTests::MULReduceAll); } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2968,7 +2968,7 @@ static void MULReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::MULReduceMasked, Int512VectorTests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { @@ -3009,7 +3009,7 @@ static void MINReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::MINReduce, Int512VectorTests::MINReduceAll); } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3054,7 +3054,7 @@ static void MINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::MINReduceMasked, Int512VectorTests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { @@ -3095,7 +3095,7 @@ static void MAXReduceInt512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int512VectorTests::MAXReduce, Int512VectorTests::MAXReduceAll); } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3140,7 +3140,7 @@ static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::MAXReduceMasked, Int512VectorTests::MAXReduceAllMasked); } @@ -3166,7 +3166,7 @@ static void anyTrueInt512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Int512VectorTests::anyTrue); } @@ -3192,7 +3192,7 @@ static void allTrueInt512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Int512VectorTests::allTrue); } @@ -3208,7 +3208,7 @@ static void withInt512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (int)4, 0); + assertInsertArraysEquals(r, a, (int)4, 0); } static boolean testIS_DEFAULT(int a) { return bits(a)==0; @@ -3757,7 +3757,7 @@ static void blendInt512VectorTests(IntFunction fa, IntFunction fb, } } - assertArraysEquals(a, b, r, mask, Int512VectorTests::blend); + assertArraysEquals(r, a, b, mask, Int512VectorTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") @@ -3774,7 +3774,7 @@ static void RearrangeInt512VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -3792,7 +3792,7 @@ static void RearrangeInt512VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "intUnaryOpProvider") static void getInt512VectorTests(IntFunction fa) { @@ -3947,7 +3947,7 @@ static void getInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::get); + assertArraysEquals(r, a, Int512VectorTests::get); } @Test(dataProvider = "intUnaryOpProvider") @@ -3961,7 +3961,7 @@ static void BroadcastInt512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4008,7 +4008,7 @@ static void sliceUnaryInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Int512VectorTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { int[] res = new int[SPECIES.length()]; @@ -4037,7 +4037,7 @@ static void sliceBinaryInt512VectorTestsBinary(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, Int512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Int512VectorTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4070,7 +4070,7 @@ static void sliceInt512VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Int512VectorTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { int[] res = new int[SPECIES.length()]; @@ -4136,7 +4136,7 @@ static void unsliceBinaryInt512VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, Int512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Int512VectorTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4192,7 +4192,7 @@ static void unsliceInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4257,7 +4257,7 @@ static void bitwiseBlendInt512VectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, c, r, mask, Int512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Int512VectorTests::BITWISE_BLEND); } @@ -4298,7 +4298,7 @@ static void BITWISE_BLENDInt512VectorTestsBroadcastSmokeTest(IntFunction IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Int512VectorTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") @@ -4313,7 +4313,7 @@ static void BITWISE_BLENDInt512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4327,7 +4327,7 @@ static void bitwiseBlendInt512VectorTestsBroadcastSmokeTest(IntFunction f IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Int512VectorTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") @@ -4342,7 +4342,7 @@ static void bitwiseBlendInt512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4413,7 +4413,7 @@ static void bitwiseBlendInt512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::NEG); + assertArraysEquals(r, a, Int512VectorTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") @@ -4471,7 +4471,7 @@ static void negInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::neg); + assertArraysEquals(r, a, Int512VectorTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4489,7 +4489,7 @@ static void NEGMaskedInt512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int512VectorTests::NEG); + assertArraysEquals(r, a, mask, Int512VectorTests::NEG); } static int ABS(int a) { @@ -4512,7 +4512,7 @@ static void ABSInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::ABS); + assertArraysEquals(r, a, Int512VectorTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") @@ -4527,7 +4527,7 @@ static void absInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::abs); + assertArraysEquals(r, a, Int512VectorTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4545,7 +4545,7 @@ static void ABSMaskedInt512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int512VectorTests::ABS); + assertArraysEquals(r, a, mask, Int512VectorTests::ABS); } @@ -4571,7 +4571,7 @@ static void NOTInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::NOT); + assertArraysEquals(r, a, Int512VectorTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") @@ -4586,7 +4586,7 @@ static void notInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::not); + assertArraysEquals(r, a, Int512VectorTests::not); } @@ -4606,7 +4606,7 @@ static void NOTMaskedInt512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int512VectorTests::NOT); + assertArraysEquals(r, a, mask, Int512VectorTests::NOT); } @@ -4629,7 +4629,7 @@ static void ZOMOInt512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int512VectorTests::ZOMO); + assertArraysEquals(r, a, Int512VectorTests::ZOMO); } @@ -4649,7 +4649,7 @@ static void ZOMOMaskedInt512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Int512VectorTests::ZOMO); } @@ -4677,7 +4677,7 @@ static void gatherInt512VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4821,8 +4821,8 @@ static void toLongArrayInt512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4832,8 +4832,8 @@ static void toDoubleArrayInt512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4899,7 +4899,7 @@ static void ADDReduceLongInt512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Int512VectorTests::ADDReduceLong, Int512VectorTests::ADDReduceAllLong); } @@ -4940,7 +4940,7 @@ static void ADDReduceLongInt512VectorTestsMasked(IntFunction fa, IntFunct ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Int512VectorTests::ADDReduceLongMasked, Int512VectorTests::ADDReduceAllLongMasked); } @@ -4952,7 +4952,7 @@ static void BroadcastLongInt512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -4970,7 +4970,7 @@ static void blendInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Int512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::blend); } @@ -4987,7 +4987,7 @@ static void SelectFromInt512VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -5006,7 +5006,7 @@ static void SelectFromInt512VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5083,7 +5083,7 @@ static void maskEqInt512VectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Int512VectorTests::beq); + assertArraysEquals(r, a, b, Int512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java index 0d4b2abde73..c17b8591dd3 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Int64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Int64VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Int64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(int[] a, int[] r, boolean[] mask) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0, "at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(int[] a, int[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "intProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new int[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index 660f362d736..9a3a9541423 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Int64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { int apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { int[] apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { int apply(int[] a); } - static void assertReductionArraysEquals(int[] a, int[] b, int c, + static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { int apply(int[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(int[] a, int[] b, int c, boolean[] mask, + static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(int[] a); } - static void assertReductionLongArraysEquals(int[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(int[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(int[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(int[] a, int[] b, int element, int index) { + static void assertInsertArraysEquals(int[] r, int[] a, int element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vecto } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vect } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[ } } - static void assertBroadcastArraysEquals(int[]a, int[]r) { + static void assertBroadcastArraysEquals(int[] r, int[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMa } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mas } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTer } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, F } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, bool } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, b } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { int apply(int[] a, int b); } - static void assertArraysEquals(int[] a, int[] r, FBinArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, FGatherScatterOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatt } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { int[] apply(int[] a, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { + static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { int[] apply(int[] a, int[] b, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { int[] apply(int[] a, int[] b, int origin, int part, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } - static void assertArraysEquals(int[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(int[] a, int[] r, int offs) { - static void assertArraysEquals(int[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(int[] a, long[] r, int offs) { } } - static void assertArraysEquals(int[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1254,7 +1254,7 @@ static void ADDInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::ADD); + assertArraysEquals(r, a, b, Int64VectorTests::ADD); } static int add(int a, int b) { return (int)(a + b); @@ -1272,7 +1272,7 @@ static void addInt64VectorTests(IntFunction fa, IntFunction fb) { av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::add); + assertArraysEquals(r, a, b, Int64VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1292,7 +1292,7 @@ static void ADDInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, Int64VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1310,7 +1310,7 @@ static void addInt64VectorTestsMasked(IntFunction fa, IntFunction av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int64VectorTests::add); + assertArraysEquals(r, a, b, mask, Int64VectorTests::add); } static int SUB(int a, int b) { return (int)(a - b); @@ -1330,7 +1330,7 @@ static void SUBInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::SUB); + assertArraysEquals(r, a, b, Int64VectorTests::SUB); } static int sub(int a, int b) { return (int)(a - b); @@ -1348,7 +1348,7 @@ static void subInt64VectorTests(IntFunction fa, IntFunction fb) { av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::sub); + assertArraysEquals(r, a, b, Int64VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1368,7 +1368,7 @@ static void SUBInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, Int64VectorTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1386,7 +1386,7 @@ static void subInt64VectorTestsMasked(IntFunction fa, IntFunction av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int64VectorTests::sub); + assertArraysEquals(r, a, b, mask, Int64VectorTests::sub); } static int MUL(int a, int b) { return (int)(a * b); @@ -1406,7 +1406,7 @@ static void MULInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::MUL); + assertArraysEquals(r, a, b, Int64VectorTests::MUL); } static int mul(int a, int b) { return (int)(a * b); @@ -1424,7 +1424,7 @@ static void mulInt64VectorTests(IntFunction fa, IntFunction fb) { av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::mul); + assertArraysEquals(r, a, b, Int64VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1444,7 +1444,7 @@ static void MULInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, Int64VectorTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1462,7 +1462,7 @@ static void mulInt64VectorTestsMasked(IntFunction fa, IntFunction av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, Int64VectorTests::mul); + assertArraysEquals(r, a, b, mask, Int64VectorTests::mul); } @@ -1487,7 +1487,7 @@ static void DIVInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::DIV); + assertArraysEquals(r, a, b, Int64VectorTests::DIV); } static int div(int a, int b) { return (int)(a / b); @@ -1509,7 +1509,7 @@ static void divInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::div); + assertArraysEquals(r, a, b, Int64VectorTests::div); } @@ -1533,7 +1533,7 @@ static void DIVInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, Int64VectorTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1555,7 +1555,7 @@ static void divInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::div); + assertArraysEquals(r, a, b, mask, Int64VectorTests::div); } static int FIRST_NONZERO(int a, int b) { @@ -1576,7 +1576,7 @@ static void FIRST_NONZEROInt64VectorTests(IntFunction fa, IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Int64VectorTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -1617,7 +1617,7 @@ static void ANDInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::AND); + assertArraysEquals(r, a, b, Int64VectorTests::AND); } static int and(int a, int b) { return (int)(a & b); @@ -1635,7 +1635,7 @@ static void andInt64VectorTests(IntFunction fa, IntFunction fb) { av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::and); + assertArraysEquals(r, a, b, Int64VectorTests::and); } @@ -1657,7 +1657,7 @@ static void ANDInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::AND); + assertArraysEquals(r, a, b, mask, Int64VectorTests::AND); } @@ -1679,7 +1679,7 @@ static void AND_NOTInt64VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Int64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Int64VectorTests::AND_NOT); } @@ -1701,7 +1701,7 @@ static void AND_NOTInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::OR); + assertArraysEquals(r, a, b, Int64VectorTests::OR); } static int or(int a, int b) { return (int)(a | b); @@ -1741,7 +1741,7 @@ static void orInt64VectorTests(IntFunction fa, IntFunction fb) { av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::or); + assertArraysEquals(r, a, b, Int64VectorTests::or); } @@ -1763,7 +1763,7 @@ static void ORInt64VectorTestsMasked(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::OR); + assertArraysEquals(r, a, b, mask, Int64VectorTests::OR); } @@ -1785,7 +1785,7 @@ static void XORInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::XOR); + assertArraysEquals(r, a, b, Int64VectorTests::XOR); } @@ -1807,7 +1807,7 @@ static void XORInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::XOR); + assertArraysEquals(r, a, b, mask, Int64VectorTests::XOR); } @@ -1822,7 +1822,7 @@ static void addInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1839,7 +1839,7 @@ static void addInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::add); } @Test(dataProvider = "intBinaryOpProvider") @@ -1853,7 +1853,7 @@ static void subInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1870,7 +1870,7 @@ static void subInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::sub); } @Test(dataProvider = "intBinaryOpProvider") @@ -1884,7 +1884,7 @@ static void mulInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1901,7 +1901,7 @@ static void mulInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::mul); } @@ -1920,7 +1920,7 @@ static void divInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::div); } @@ -1941,7 +1941,7 @@ static void divInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::div); } @@ -1957,7 +1957,7 @@ static void ORInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunct av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::OR); } @Test(dataProvider = "intBinaryOpProvider") @@ -1971,7 +1971,7 @@ static void orInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunct av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::or); } @@ -1990,7 +1990,7 @@ static void ORInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::OR); } @@ -2006,7 +2006,7 @@ static void ANDInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::AND); } @Test(dataProvider = "intBinaryOpProvider") @@ -2020,7 +2020,7 @@ static void andInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::and); } @@ -2039,7 +2039,7 @@ static void ANDInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::AND); } @@ -2055,7 +2055,7 @@ static void ORInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Int64VectorTests::OR); } @@ -2074,7 +2074,7 @@ static void ORInt64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::OR); } @@ -2089,7 +2089,7 @@ static void ADDInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Int64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Int64VectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -2106,7 +2106,7 @@ static void ADDInt64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction f av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Int64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::ADD); } static int LSHL(int a, int b) { @@ -2127,7 +2127,7 @@ static void LSHLInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::LSHL); + assertArraysEquals(r, a, b, Int64VectorTests::LSHL); } @@ -2149,7 +2149,7 @@ static void LSHLInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, Int64VectorTests::LSHL); } @@ -2175,7 +2175,7 @@ static void ASHRInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::ASHR); + assertArraysEquals(r, a, b, Int64VectorTests::ASHR); } @@ -2197,7 +2197,7 @@ static void ASHRInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, Int64VectorTests::ASHR); } @@ -2223,7 +2223,7 @@ static void LSHRInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::LSHR); + assertArraysEquals(r, a, b, Int64VectorTests::LSHR); } @@ -2245,7 +2245,7 @@ static void LSHRInt64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, Int64VectorTests::LSHR); } @@ -2270,7 +2270,7 @@ static void LSHLInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, Int64VectorTests::LSHL_unary); } @@ -2291,7 +2291,7 @@ static void LSHLInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::LSHL_unary); } @@ -2316,7 +2316,7 @@ static void LSHRInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, Int64VectorTests::LSHR_unary); } @@ -2337,7 +2337,7 @@ static void LSHRInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::LSHR_unary); } @@ -2362,7 +2362,7 @@ static void ASHRInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, Int64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, Int64VectorTests::ASHR_unary); } @@ -2383,7 +2383,7 @@ static void ASHRInt64VectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, Int64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::ASHR_unary); } @@ -2408,7 +2408,7 @@ static void MINInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::MIN); + assertArraysEquals(r, a, b, Int64VectorTests::MIN); } static int min(int a, int b) { return (int)(Math.min(a, b)); @@ -2426,7 +2426,7 @@ static void minInt64VectorTests(IntFunction fa, IntFunction fb) { av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::min); + assertArraysEquals(r, a, b, Int64VectorTests::min); } static int MAX(int a, int b) { return (int)(Math.max(a, b)); @@ -2446,7 +2446,7 @@ static void MAXInt64VectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, Int64VectorTests::MAX); + assertArraysEquals(r, a, b, Int64VectorTests::MAX); } static int max(int a, int b) { return (int)(Math.max(a, b)); @@ -2464,7 +2464,7 @@ static void maxInt64VectorTests(IntFunction fa, IntFunction fb) { av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::max); + assertArraysEquals(r, a, b, Int64VectorTests::max); } @Test(dataProvider = "intBinaryOpProvider") @@ -2478,7 +2478,7 @@ static void MINInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") @@ -2492,7 +2492,7 @@ static void minInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::min); } @Test(dataProvider = "intBinaryOpProvider") @@ -2506,7 +2506,7 @@ static void MAXInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") @@ -2520,7 +2520,7 @@ static void maxInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Int64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Int64VectorTests::max); } static int ANDReduce(int[] a, int idx) { @@ -2563,7 +2563,7 @@ static void ANDReduceInt64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::ANDReduce, Int64VectorTests::ANDReduceAll); } @@ -2611,7 +2611,7 @@ static void ANDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::ORReduce, Int64VectorTests::ORReduceAll); } @@ -2704,7 +2704,7 @@ static void ORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::XORReduce, Int64VectorTests::XORReduceAll); } @@ -2797,7 +2797,7 @@ static void XORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::ADDReduce, Int64VectorTests::ADDReduceAll); } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2883,7 +2883,7 @@ static void ADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::MULReduce, Int64VectorTests::MULReduceAll); } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2968,7 +2968,7 @@ static void MULReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::MINReduce, Int64VectorTests::MINReduceAll); } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3054,7 +3054,7 @@ static void MINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Int64VectorTests::MAXReduce, Int64VectorTests::MAXReduceAll); } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3140,7 +3140,7 @@ static void MAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Int64VectorTests::anyTrue); } @@ -3192,7 +3192,7 @@ static void allTrueInt64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Int64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Int64VectorTests::allTrue); } @@ -3208,7 +3208,7 @@ static void withInt64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (int)4, 0); + assertInsertArraysEquals(r, a, (int)4, 0); } static boolean testIS_DEFAULT(int a) { return bits(a)==0; @@ -3757,7 +3757,7 @@ static void blendInt64VectorTests(IntFunction fa, IntFunction fb, } } - assertArraysEquals(a, b, r, mask, Int64VectorTests::blend); + assertArraysEquals(r, a, b, mask, Int64VectorTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") @@ -3774,7 +3774,7 @@ static void RearrangeInt64VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -3792,7 +3792,7 @@ static void RearrangeInt64VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "intUnaryOpProvider") static void getInt64VectorTests(IntFunction fa) { @@ -3947,7 +3947,7 @@ static void getInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::get); + assertArraysEquals(r, a, Int64VectorTests::get); } @Test(dataProvider = "intUnaryOpProvider") @@ -3961,7 +3961,7 @@ static void BroadcastInt64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4008,7 +4008,7 @@ static void sliceUnaryInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Int64VectorTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { int[] res = new int[SPECIES.length()]; @@ -4037,7 +4037,7 @@ static void sliceBinaryInt64VectorTestsBinary(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, origin, Int64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Int64VectorTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4070,7 +4070,7 @@ static void sliceInt64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Int64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Int64VectorTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { int[] res = new int[SPECIES.length()]; @@ -4136,7 +4136,7 @@ static void unsliceBinaryInt64VectorTestsBinary(IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, origin, part, Int64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Int64VectorTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4192,7 +4192,7 @@ static void unsliceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4257,7 +4257,7 @@ static void bitwiseBlendInt64VectorTests(IntFunction fa, IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, c, r, mask, Int64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Int64VectorTests::BITWISE_BLEND); } @@ -4298,7 +4298,7 @@ static void BITWISE_BLENDInt64VectorTestsBroadcastSmokeTest(IntFunction f IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Int64VectorTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") @@ -4313,7 +4313,7 @@ static void BITWISE_BLENDInt64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4327,7 +4327,7 @@ static void bitwiseBlendInt64VectorTestsBroadcastSmokeTest(IntFunction fa IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Int64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") @@ -4342,7 +4342,7 @@ static void bitwiseBlendInt64VectorTestsAltBroadcastSmokeTest(IntFunction IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, Int64VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); } @@ -4362,7 +4362,7 @@ static void BITWISE_BLENDInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4413,7 +4413,7 @@ static void bitwiseBlendInt64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::NEG); + assertArraysEquals(r, a, Int64VectorTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") @@ -4471,7 +4471,7 @@ static void negInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::neg); + assertArraysEquals(r, a, Int64VectorTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4489,7 +4489,7 @@ static void NEGMaskedInt64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int64VectorTests::NEG); + assertArraysEquals(r, a, mask, Int64VectorTests::NEG); } static int ABS(int a) { @@ -4512,7 +4512,7 @@ static void ABSInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::ABS); + assertArraysEquals(r, a, Int64VectorTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") @@ -4527,7 +4527,7 @@ static void absInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::abs); + assertArraysEquals(r, a, Int64VectorTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4545,7 +4545,7 @@ static void ABSMaskedInt64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int64VectorTests::ABS); + assertArraysEquals(r, a, mask, Int64VectorTests::ABS); } @@ -4571,7 +4571,7 @@ static void NOTInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::NOT); + assertArraysEquals(r, a, Int64VectorTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") @@ -4586,7 +4586,7 @@ static void notInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::not); + assertArraysEquals(r, a, Int64VectorTests::not); } @@ -4606,7 +4606,7 @@ static void NOTMaskedInt64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int64VectorTests::NOT); + assertArraysEquals(r, a, mask, Int64VectorTests::NOT); } @@ -4629,7 +4629,7 @@ static void ZOMOInt64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Int64VectorTests::ZOMO); + assertArraysEquals(r, a, Int64VectorTests::ZOMO); } @@ -4649,7 +4649,7 @@ static void ZOMOMaskedInt64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Int64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Int64VectorTests::ZOMO); } @@ -4677,7 +4677,7 @@ static void gatherInt64VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4821,8 +4821,8 @@ static void toLongArrayInt64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4832,8 +4832,8 @@ static void toDoubleArrayInt64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4899,7 +4899,7 @@ static void ADDReduceLongInt64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Int64VectorTests::ADDReduceLong, Int64VectorTests::ADDReduceAllLong); } @@ -4940,7 +4940,7 @@ static void ADDReduceLongInt64VectorTestsMasked(IntFunction fa, IntFuncti ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Int64VectorTests::ADDReduceLongMasked, Int64VectorTests::ADDReduceAllLongMasked); } @@ -4952,7 +4952,7 @@ static void BroadcastLongInt64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -4970,7 +4970,7 @@ static void blendInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Int64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::blend); } @@ -4987,7 +4987,7 @@ static void SelectFromInt64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -5006,7 +5006,7 @@ static void SelectFromInt64VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5083,7 +5083,7 @@ static void maskEqInt64VectorTestsSmokeTest(IntFunction fa, IntFuncti var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Int64VectorTests::beq); + assertArraysEquals(r, a, b, Int64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java index 00ddaedc1e5..7d89b2c2ae0 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * IntMaxVectorLoadStoreTests + * -XX:-TieredCompilation IntMaxVectorLoadStoreTests * */ @@ -67,47 +67,25 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(int[] a, int[] r, boolean[] mask) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (int) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (int) 0, "at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(int[] a, int[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (int) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -410,7 +388,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "intProviderForIOOBE") @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new int[a.length]; @@ -492,7 +470,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intMaskProviderForIOOBE") @@ -565,7 +543,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -589,7 +567,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -676,7 +654,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -691,7 +669,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -807,7 +785,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "intByteProviderForIOOBE") @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -899,7 +877,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "intByteMaskProviderForIOOBE") @@ -976,7 +954,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -987,7 +965,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index 92829c048e3..1db67b4b2de 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch IntMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation IntMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { int apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { int[] apply(int a); } - static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(int[] a, int[] r, FUnArrayOp f) { } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(int[] a, int[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { int apply(int[] a); } - static void assertReductionArraysEquals(int[] a, int[] b, int c, + static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { int apply(int[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(int[] a, int[] b, int c, boolean[] mask, + static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -167,17 +167,17 @@ interface FReductionAllOpLong { long apply(int[] a); } - static void assertReductionLongArraysEquals(int[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -189,17 +189,17 @@ interface FReductionAllMaskedOpLong { long apply(int[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(int[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -207,37 +207,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(int[] a, int[] b, int element, int index) { + static void assertInsertArraysEquals(int[] r, int[] a, int element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -251,7 +251,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, int vecto } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -265,7 +265,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, int vect } } - static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -285,7 +285,7 @@ static void assertRearrangeArraysEquals(int[] a, int[] r, int[] order, boolean[] } } - static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -305,7 +305,7 @@ static void assertSelectFromArraysEquals(int[] a, int[] r, int[] order, boolean[ } } - static void assertBroadcastArraysEquals(int[]a, int[]r) { + static void assertBroadcastArraysEquals(int[] r, int[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -334,7 +334,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -345,7 +345,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -357,7 +357,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -369,11 +369,11 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, FBinOp f) } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -384,11 +384,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMa } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -402,11 +402,11 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mas } } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -420,7 +420,7 @@ static void assertBroadcastLongArraysEquals(int[] a, int[] b, int[] r, boolean[] } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -434,11 +434,11 @@ static void assertShiftArraysEquals(int[] a, int[] b, int[] r, FBinOp f) { } } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -464,7 +464,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -475,11 +475,11 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { } } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -491,7 +491,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mas } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -504,7 +504,7 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTer } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,12 +517,12 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, F } } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -538,12 +538,12 @@ static void assertBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, bool } } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ static void assertAltBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, b } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,12 +574,12 @@ static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r } } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(int[] a, int[] b, int[] c, int[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -602,7 +602,7 @@ interface FBinArrayOp { int apply(int[] a, int b); } - static void assertArraysEquals(int[] a, int[] r, FBinArrayOp f) { + static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -617,7 +617,7 @@ interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, FGatherScatterOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -644,7 +644,7 @@ interface FScatterMaskedOp { int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -665,7 +665,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FGathe } } - static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -675,7 +675,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FScatt } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -692,7 +692,7 @@ interface FLaneOp { int[] apply(int[] a, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { + static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -702,7 +702,7 @@ static void assertArraysEquals(int[] a, int[] r, int origin, FLaneOp f) { } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -712,7 +712,7 @@ interface FLaneBop { int[] apply(int[] a, int[] b, int origin, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -722,7 +722,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, FLaneBop f } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -733,7 +733,7 @@ interface FLaneMaskedBop { int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -743,7 +743,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, boolean[] } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -754,7 +754,7 @@ interface FLanePartBop { int[] apply(int[] a, int[] b, int origin, int part, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -764,7 +764,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -776,7 +776,7 @@ interface FLanePartMaskedBop { int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -786,7 +786,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -795,7 +795,7 @@ static void assertArraysEquals(int[] a, int[] b, int[] r, int origin, int part, } - static void assertArraysEquals(int[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -808,7 +808,7 @@ static void assertArraysEquals(int[] a, int[] r, int offs) { - static void assertArraysEquals(int[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -819,7 +819,7 @@ static void assertArraysEquals(int[] a, long[] r, int offs) { } } - static void assertArraysEquals(int[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1259,7 +1259,7 @@ static void ADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::ADD); + assertArraysEquals(r, a, b, IntMaxVectorTests::ADD); } static int add(int a, int b) { return (int)(a + b); @@ -1277,7 +1277,7 @@ static void addIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::add); + assertArraysEquals(r, a, b, IntMaxVectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1297,7 +1297,7 @@ static void ADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1315,7 +1315,7 @@ static void addIntMaxVectorTestsMasked(IntFunction fa, IntFunction av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::add); } static int SUB(int a, int b) { return (int)(a - b); @@ -1335,7 +1335,7 @@ static void SUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::SUB); + assertArraysEquals(r, a, b, IntMaxVectorTests::SUB); } static int sub(int a, int b) { return (int)(a - b); @@ -1353,7 +1353,7 @@ static void subIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::sub); + assertArraysEquals(r, a, b, IntMaxVectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1373,7 +1373,7 @@ static void SUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1391,7 +1391,7 @@ static void subIntMaxVectorTestsMasked(IntFunction fa, IntFunction av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::sub); } static int MUL(int a, int b) { return (int)(a * b); @@ -1411,7 +1411,7 @@ static void MULIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::MUL); + assertArraysEquals(r, a, b, IntMaxVectorTests::MUL); } static int mul(int a, int b) { return (int)(a * b); @@ -1429,7 +1429,7 @@ static void mulIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::mul); + assertArraysEquals(r, a, b, IntMaxVectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1449,7 +1449,7 @@ static void MULIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1467,7 +1467,7 @@ static void mulIntMaxVectorTestsMasked(IntFunction fa, IntFunction av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::mul); } @@ -1492,7 +1492,7 @@ static void DIVIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::DIV); + assertArraysEquals(r, a, b, IntMaxVectorTests::DIV); } static int div(int a, int b) { return (int)(a / b); @@ -1514,7 +1514,7 @@ static void divIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::div); + assertArraysEquals(r, a, b, IntMaxVectorTests::div); } @@ -1538,7 +1538,7 @@ static void DIVIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1560,7 +1560,7 @@ static void divIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::div); } static int FIRST_NONZERO(int a, int b) { @@ -1581,7 +1581,7 @@ static void FIRST_NONZEROIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -1622,7 +1622,7 @@ static void ANDIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::AND); + assertArraysEquals(r, a, b, IntMaxVectorTests::AND); } static int and(int a, int b) { return (int)(a & b); @@ -1640,7 +1640,7 @@ static void andIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::and); + assertArraysEquals(r, a, b, IntMaxVectorTests::and); } @@ -1662,7 +1662,7 @@ static void ANDIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::AND); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND); } @@ -1684,7 +1684,7 @@ static void AND_NOTIntMaxVectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, IntMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntMaxVectorTests::AND_NOT); } @@ -1706,7 +1706,7 @@ static void AND_NOTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::OR); + assertArraysEquals(r, a, b, IntMaxVectorTests::OR); } static int or(int a, int b) { return (int)(a | b); @@ -1746,7 +1746,7 @@ static void orIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::or); + assertArraysEquals(r, a, b, IntMaxVectorTests::or); } @@ -1768,7 +1768,7 @@ static void ORIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::OR); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); } @@ -1790,7 +1790,7 @@ static void XORIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::XOR); + assertArraysEquals(r, a, b, IntMaxVectorTests::XOR); } @@ -1812,7 +1812,7 @@ static void XORIntMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::XOR); } @@ -1827,7 +1827,7 @@ static void addIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1844,7 +1844,7 @@ static void addIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::add); } @Test(dataProvider = "intBinaryOpProvider") @@ -1858,7 +1858,7 @@ static void subIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1875,7 +1875,7 @@ static void subIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::sub); } @Test(dataProvider = "intBinaryOpProvider") @@ -1889,7 +1889,7 @@ static void mulIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -1906,7 +1906,7 @@ static void mulIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::mul); } @@ -1925,7 +1925,7 @@ static void divIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::div); } @@ -1946,7 +1946,7 @@ static void divIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::div); } @@ -1962,7 +1962,7 @@ static void ORIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::OR); } @Test(dataProvider = "intBinaryOpProvider") @@ -1976,7 +1976,7 @@ static void orIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::or); } @@ -1995,7 +1995,7 @@ static void ORIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); } @@ -2011,7 +2011,7 @@ static void ANDIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::AND); } @Test(dataProvider = "intBinaryOpProvider") @@ -2025,7 +2025,7 @@ static void andIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::and); } @@ -2044,7 +2044,7 @@ static void ANDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::AND); } @@ -2060,7 +2060,7 @@ static void ORIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, IntMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::OR); } @@ -2079,7 +2079,7 @@ static void ORIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, IntMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); } @@ -2094,7 +2094,7 @@ static void ADDIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, IntMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -2111,7 +2111,7 @@ static void ADDIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, IntMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD); } static int LSHL(int a, int b) { @@ -2132,7 +2132,7 @@ static void LSHLIntMaxVectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, IntMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, IntMaxVectorTests::LSHL); } @@ -2154,7 +2154,7 @@ static void LSHLIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, IntMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, IntMaxVectorTests::ASHR); } @@ -2202,7 +2202,7 @@ static void ASHRIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, IntMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, IntMaxVectorTests::LSHR); } @@ -2250,7 +2250,7 @@ static void LSHRIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, IntMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHL_unary); } @@ -2296,7 +2296,7 @@ static void LSHLIntMaxVectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, IntMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL_unary); } @@ -2321,7 +2321,7 @@ static void LSHRIntMaxVectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, IntMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHR_unary); } @@ -2342,7 +2342,7 @@ static void LSHRIntMaxVectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, IntMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR_unary); } @@ -2367,7 +2367,7 @@ static void ASHRIntMaxVectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, IntMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ASHR_unary); } @@ -2388,7 +2388,7 @@ static void ASHRIntMaxVectorTestsShift(IntFunction fa, IntFunction } } - assertShiftArraysEquals(a, b, r, mask, IntMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR_unary); } @@ -2413,7 +2413,7 @@ static void MINIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::MIN); + assertArraysEquals(r, a, b, IntMaxVectorTests::MIN); } static int min(int a, int b) { return (int)(Math.min(a, b)); @@ -2431,7 +2431,7 @@ static void minIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::min); + assertArraysEquals(r, a, b, IntMaxVectorTests::min); } static int MAX(int a, int b) { return (int)(Math.max(a, b)); @@ -2451,7 +2451,7 @@ static void MAXIntMaxVectorTests(IntFunction fa, IntFunction fb) { } } - assertArraysEquals(a, b, r, IntMaxVectorTests::MAX); + assertArraysEquals(r, a, b, IntMaxVectorTests::MAX); } static int max(int a, int b) { return (int)(Math.max(a, b)); @@ -2469,7 +2469,7 @@ static void maxIntMaxVectorTests(IntFunction fa, IntFunction fb) { av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::max); + assertArraysEquals(r, a, b, IntMaxVectorTests::max); } @Test(dataProvider = "intBinaryOpProvider") @@ -2483,7 +2483,7 @@ static void MINIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") @@ -2497,7 +2497,7 @@ static void minIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::min); } @Test(dataProvider = "intBinaryOpProvider") @@ -2511,7 +2511,7 @@ static void MAXIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") @@ -2525,7 +2525,7 @@ static void maxIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::max); } static int ANDReduce(int[] a, int idx) { @@ -2568,7 +2568,7 @@ static void ANDReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::ANDReduce, IntMaxVectorTests::ANDReduceAll); } @@ -2616,7 +2616,7 @@ static void ANDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::ANDReduceMasked, IntMaxVectorTests::ANDReduceAllMasked); } @@ -2661,7 +2661,7 @@ static void ORReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::ORReduce, IntMaxVectorTests::ORReduceAll); } @@ -2709,7 +2709,7 @@ static void ORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::XORReduce, IntMaxVectorTests::XORReduceAll); } @@ -2802,7 +2802,7 @@ static void XORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::XORReduceMasked, IntMaxVectorTests::XORReduceAllMasked); } @@ -2844,7 +2844,7 @@ static void ADDReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::ADDReduce, IntMaxVectorTests::ADDReduceAll); } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2888,7 +2888,7 @@ static void ADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::ADDReduceMasked, IntMaxVectorTests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { @@ -2929,7 +2929,7 @@ static void MULReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::MULReduce, IntMaxVectorTests::MULReduceAll); } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { @@ -2973,7 +2973,7 @@ static void MULReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::MULReduceMasked, IntMaxVectorTests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { @@ -3014,7 +3014,7 @@ static void MINReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::MINReduce, IntMaxVectorTests::MINReduceAll); } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3059,7 +3059,7 @@ static void MINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::MINReduceMasked, IntMaxVectorTests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { @@ -3100,7 +3100,7 @@ static void MAXReduceIntMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, IntMaxVectorTests::MAXReduce, IntMaxVectorTests::MAXReduceAll); } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { @@ -3145,7 +3145,7 @@ static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked); } @@ -3171,7 +3171,7 @@ static void anyTrueIntMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, IntMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::anyTrue); } @@ -3197,7 +3197,7 @@ static void allTrueIntMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, IntMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue); } @@ -3213,7 +3213,7 @@ static void withIntMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (int)4, 0); + assertInsertArraysEquals(r, a, (int)4, 0); } static boolean testIS_DEFAULT(int a) { return bits(a)==0; @@ -3762,7 +3762,7 @@ static void blendIntMaxVectorTests(IntFunction fa, IntFunction fb, } } - assertArraysEquals(a, b, r, mask, IntMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") @@ -3779,7 +3779,7 @@ static void RearrangeIntMaxVectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -3797,7 +3797,7 @@ static void RearrangeIntMaxVectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "intUnaryOpProvider") static void getIntMaxVectorTests(IntFunction fa) { @@ -3952,7 +3952,7 @@ static void getIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::get); + assertArraysEquals(r, a, IntMaxVectorTests::get); } @Test(dataProvider = "intUnaryOpProvider") @@ -3966,7 +3966,7 @@ static void BroadcastIntMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4013,7 +4013,7 @@ static void sliceUnaryIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, IntMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntMaxVectorTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { int[] res = new int[SPECIES.length()]; @@ -4042,7 +4042,7 @@ static void sliceBinaryIntMaxVectorTestsBinary(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, IntMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntMaxVectorTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4075,7 +4075,7 @@ static void sliceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, IntMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntMaxVectorTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { int[] res = new int[SPECIES.length()]; @@ -4141,7 +4141,7 @@ static void unsliceBinaryIntMaxVectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, part, IntMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntMaxVectorTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { int[] res = new int[SPECIES.length()]; @@ -4197,7 +4197,7 @@ static void unsliceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4262,7 +4262,7 @@ static void bitwiseBlendIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunct } } - assertArraysEquals(a, b, c, r, mask, IntMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND); } @@ -4303,7 +4303,7 @@ static void BITWISE_BLENDIntMaxVectorTestsBroadcastSmokeTest(IntFunction IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, IntMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") @@ -4318,7 +4318,7 @@ static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4332,7 +4332,7 @@ static void bitwiseBlendIntMaxVectorTestsBroadcastSmokeTest(IntFunction f IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, IntMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") @@ -4347,7 +4347,7 @@ static void bitwiseBlendIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4418,7 +4418,7 @@ static void bitwiseBlendIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::NEG); + assertArraysEquals(r, a, IntMaxVectorTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") @@ -4476,7 +4476,7 @@ static void negIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::neg); + assertArraysEquals(r, a, IntMaxVectorTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4494,7 +4494,7 @@ static void NEGMaskedIntMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, IntMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, IntMaxVectorTests::NEG); } static int ABS(int a) { @@ -4517,7 +4517,7 @@ static void ABSIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::ABS); + assertArraysEquals(r, a, IntMaxVectorTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") @@ -4532,7 +4532,7 @@ static void absIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::abs); + assertArraysEquals(r, a, IntMaxVectorTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") @@ -4550,7 +4550,7 @@ static void ABSMaskedIntMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, IntMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, IntMaxVectorTests::ABS); } @@ -4576,7 +4576,7 @@ static void NOTIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::NOT); + assertArraysEquals(r, a, IntMaxVectorTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") @@ -4591,7 +4591,7 @@ static void notIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::not); + assertArraysEquals(r, a, IntMaxVectorTests::not); } @@ -4611,7 +4611,7 @@ static void NOTMaskedIntMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, IntMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, IntMaxVectorTests::NOT); } @@ -4634,7 +4634,7 @@ static void ZOMOIntMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, IntMaxVectorTests::ZOMO); + assertArraysEquals(r, a, IntMaxVectorTests::ZOMO); } @@ -4654,7 +4654,7 @@ static void ZOMOMaskedIntMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, IntMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntMaxVectorTests::ZOMO); } @@ -4682,7 +4682,7 @@ static void gatherIntMaxVectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4826,8 +4826,8 @@ static void toLongArrayIntMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4837,8 +4837,8 @@ static void toDoubleArrayIntMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4904,7 +4904,7 @@ static void ADDReduceLongIntMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, IntMaxVectorTests::ADDReduceLong, IntMaxVectorTests::ADDReduceAllLong); } @@ -4945,7 +4945,7 @@ static void ADDReduceLongIntMaxVectorTestsMasked(IntFunction fa, IntFunct ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, IntMaxVectorTests::ADDReduceLongMasked, IntMaxVectorTests::ADDReduceAllLongMasked); } @@ -4957,7 +4957,7 @@ static void BroadcastLongIntMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "intBinaryOpMaskProvider") @@ -4975,7 +4975,7 @@ static void blendIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, IntMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::blend); } @@ -4992,7 +4992,7 @@ static void SelectFromIntMaxVectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") @@ -5011,7 +5011,7 @@ static void SelectFromIntMaxVectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5088,7 +5088,7 @@ static void maskEqIntMaxVectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, IntMaxVectorTests::beq); + assertArraysEquals(r, a, b, IntMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java index 03773381f09..54c337cee33 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Long128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Long128VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Long128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(long[] a, long[] r, boolean[] mask) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0, "at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(long[] a, long[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "longProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new long[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index f1fb7c1d95a..19ce3554e88 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Long128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { long apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { long[] apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { long apply(long[] a); } - static void assertReductionArraysEquals(long[] a, long[] b, long c, + static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(long[] a, long[] b, long c, boolean[] mask, + static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -159,37 +159,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) { + static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -203,7 +203,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -217,7 +217,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int v } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -237,7 +237,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -257,7 +257,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boole } } - static void assertBroadcastArraysEquals(long[]a, long[]r) { + static void assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -286,7 +286,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -297,7 +297,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -309,7 +309,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -321,11 +321,11 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp } } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -336,11 +336,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -354,11 +354,11 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -372,7 +372,7 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolea } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -386,11 +386,11 @@ static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -416,7 +416,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -427,11 +427,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -443,7 +443,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -456,7 +456,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -469,12 +469,12 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -490,12 +490,12 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -511,7 +511,7 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -526,12 +526,12 @@ static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ interface FBinArrayOp { long apply(long[] a, int b); } - static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,7 +569,7 @@ interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -596,7 +596,7 @@ interface FScatterMaskedOp { long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -606,7 +606,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -617,7 +617,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -627,7 +627,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FSca } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -644,7 +644,7 @@ interface FLaneOp { long[] apply(long[] a, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { + static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -664,7 +664,7 @@ interface FLaneBop { long[] apply(long[] a, long[] b, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -674,7 +674,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBo } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -685,7 +685,7 @@ interface FLaneMaskedBop { long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -695,7 +695,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -706,7 +706,7 @@ interface FLanePartBop { long[] apply(long[] a, long[] b, int origin, int part, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -716,7 +716,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -728,7 +728,7 @@ interface FLanePartMaskedBop { long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -780,7 +780,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(long[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -793,7 +793,7 @@ static void assertArraysEquals(long[] a, int[] r, int offs) { - static void assertArraysEquals(long[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -804,7 +804,7 @@ static void assertArraysEquals(long[] a, long[] r, int offs) { } } - static void assertArraysEquals(long[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1275,7 +1275,7 @@ static void ADDLong128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::ADD); + assertArraysEquals(r, a, b, Long128VectorTests::ADD); } static long add(long a, long b) { return (long)(a + b); @@ -1293,7 +1293,7 @@ static void addLong128VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::add); + assertArraysEquals(r, a, b, Long128VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1313,7 +1313,7 @@ static void ADDLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::SUB); + assertArraysEquals(r, a, b, Long128VectorTests::SUB); } static long sub(long a, long b) { return (long)(a - b); @@ -1369,7 +1369,7 @@ static void subLong128VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::sub); + assertArraysEquals(r, a, b, Long128VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1389,7 +1389,7 @@ static void SUBLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::MUL); + assertArraysEquals(r, a, b, Long128VectorTests::MUL); } static long mul(long a, long b) { return (long)(a * b); @@ -1445,7 +1445,7 @@ static void mulLong128VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::mul); + assertArraysEquals(r, a, b, Long128VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1465,7 +1465,7 @@ static void MULLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::DIV); + assertArraysEquals(r, a, b, Long128VectorTests::DIV); } static long div(long a, long b) { return (long)(a / b); @@ -1530,7 +1530,7 @@ static void divLong128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::div); + assertArraysEquals(r, a, b, Long128VectorTests::div); } @@ -1554,7 +1554,7 @@ static void DIVLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Long128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Long128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1617,7 +1617,7 @@ static void FIRST_NONZEROLong128VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Long128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Long128VectorTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -1638,7 +1638,7 @@ static void ANDLong128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::AND); + assertArraysEquals(r, a, b, Long128VectorTests::AND); } static long and(long a, long b) { return (long)(a & b); @@ -1656,7 +1656,7 @@ static void andLong128VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::and); + assertArraysEquals(r, a, b, Long128VectorTests::and); } @@ -1678,7 +1678,7 @@ static void ANDLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Long128VectorTests::AND_NOT); } @@ -1744,7 +1744,7 @@ static void ORLong128VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long128VectorTests::OR); + assertArraysEquals(r, a, b, Long128VectorTests::OR); } static long or(long a, long b) { return (long)(a | b); @@ -1762,7 +1762,7 @@ static void orLong128VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::or); + assertArraysEquals(r, a, b, Long128VectorTests::or); } @@ -1784,7 +1784,7 @@ static void ORLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::XOR); + assertArraysEquals(r, a, b, Long128VectorTests::XOR); } @@ -1828,7 +1828,7 @@ static void XORLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1860,7 +1860,7 @@ static void addLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::add); } @Test(dataProvider = "longBinaryOpProvider") @@ -1874,7 +1874,7 @@ static void subLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1891,7 +1891,7 @@ static void subLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::sub); } @Test(dataProvider = "longBinaryOpProvider") @@ -1905,7 +1905,7 @@ static void mulLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1922,7 +1922,7 @@ static void mulLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::mul); } @@ -1941,7 +1941,7 @@ static void divLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::div); } @@ -1962,7 +1962,7 @@ static void divLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::div); } @@ -1978,7 +1978,7 @@ static void ORLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::OR); } @Test(dataProvider = "longBinaryOpProvider") @@ -1992,7 +1992,7 @@ static void orLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::or); } @@ -2011,7 +2011,7 @@ static void ORLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::OR); } @@ -2027,7 +2027,7 @@ static void ANDLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::AND); } @Test(dataProvider = "longBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void andLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::and); } @@ -2060,7 +2060,7 @@ static void ANDLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::AND); } @@ -2076,7 +2076,7 @@ static void ORLong128VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Long128VectorTests::OR); } @@ -2095,7 +2095,7 @@ static void ORLong128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Long128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Long128VectorTests::OR); } @@ -2110,7 +2110,7 @@ static void ADDLong128VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Long128VectorTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -2127,7 +2127,7 @@ static void ADDLong128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long128VectorTests::LSHL); + assertArraysEquals(r, a, b, Long128VectorTests::LSHL); } @@ -2170,7 +2170,7 @@ static void LSHLLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long128VectorTests::ASHR); + assertArraysEquals(r, a, b, Long128VectorTests::ASHR); } @@ -2218,7 +2218,7 @@ static void ASHRLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long128VectorTests::LSHR); + assertArraysEquals(r, a, b, Long128VectorTests::LSHR); } @@ -2266,7 +2266,7 @@ static void LSHRLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::MIN); + assertArraysEquals(r, a, b, Long128VectorTests::MIN); } static long min(long a, long b) { return (long)(Math.min(a, b)); @@ -2447,7 +2447,7 @@ static void minLong128VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::min); + assertArraysEquals(r, a, b, Long128VectorTests::min); } static long MAX(long a, long b) { return (long)(Math.max(a, b)); @@ -2467,7 +2467,7 @@ static void MAXLong128VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long128VectorTests::MAX); + assertArraysEquals(r, a, b, Long128VectorTests::MAX); } static long max(long a, long b) { return (long)(Math.max(a, b)); @@ -2485,7 +2485,7 @@ static void maxLong128VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::max); + assertArraysEquals(r, a, b, Long128VectorTests::max); } @Test(dataProvider = "longBinaryOpProvider") @@ -2499,7 +2499,7 @@ static void MINLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") @@ -2513,7 +2513,7 @@ static void minLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::min); } @Test(dataProvider = "longBinaryOpProvider") @@ -2527,7 +2527,7 @@ static void MAXLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") @@ -2541,7 +2541,7 @@ static void maxLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Long128VectorTests::max); } static long ANDReduce(long[] a, int idx) { @@ -2584,7 +2584,7 @@ static void ANDReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::ANDReduce, Long128VectorTests::ANDReduceAll); } @@ -2632,7 +2632,7 @@ static void ANDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::ANDReduceMasked, Long128VectorTests::ANDReduceAllMasked); } @@ -2677,7 +2677,7 @@ static void ORReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::ORReduce, Long128VectorTests::ORReduceAll); } @@ -2725,7 +2725,7 @@ static void ORReduceLong128VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::ORReduceMasked, Long128VectorTests::ORReduceAllMasked); } @@ -2770,7 +2770,7 @@ static void XORReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::XORReduce, Long128VectorTests::XORReduceAll); } @@ -2818,7 +2818,7 @@ static void XORReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::XORReduceMasked, Long128VectorTests::XORReduceAllMasked); } @@ -2860,7 +2860,7 @@ static void ADDReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::ADDReduce, Long128VectorTests::ADDReduceAll); } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2904,7 +2904,7 @@ static void ADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::ADDReduceMasked, Long128VectorTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { @@ -2945,7 +2945,7 @@ static void MULReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::MULReduce, Long128VectorTests::MULReduceAll); } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2989,7 +2989,7 @@ static void MULReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::MULReduceMasked, Long128VectorTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { @@ -3030,7 +3030,7 @@ static void MINReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::MINReduce, Long128VectorTests::MINReduceAll); } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3075,7 +3075,7 @@ static void MINReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::MINReduceMasked, Long128VectorTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { @@ -3116,7 +3116,7 @@ static void MAXReduceLong128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::MAXReduce, Long128VectorTests::MAXReduceAll); } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3161,7 +3161,7 @@ static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::MAXReduceMasked, Long128VectorTests::MAXReduceAllMasked); } @@ -3187,7 +3187,7 @@ static void anyTrueLong128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Long128VectorTests::anyTrue); } @@ -3213,7 +3213,7 @@ static void allTrueLong128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Long128VectorTests::allTrue); } @@ -3229,7 +3229,7 @@ static void withLong128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (long)4, 0); + assertInsertArraysEquals(r, a, (long)4, 0); } static boolean testIS_DEFAULT(long a) { return bits(a)==0; @@ -3706,7 +3706,7 @@ static void blendLong128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Long128VectorTests::blend); + assertArraysEquals(r, a, b, mask, Long128VectorTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") @@ -3723,7 +3723,7 @@ static void RearrangeLong128VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") @@ -3741,7 +3741,7 @@ static void RearrangeLong128VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "longUnaryOpProvider") static void getLong128VectorTests(IntFunction fa) { @@ -3896,7 +3896,7 @@ static void getLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::get); + assertArraysEquals(r, a, Long128VectorTests::get); } @Test(dataProvider = "longUnaryOpProvider") @@ -3910,7 +3910,7 @@ static void BroadcastLong128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3957,7 +3957,7 @@ static void sliceUnaryLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Long128VectorTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = new long[SPECIES.length()]; @@ -3986,7 +3986,7 @@ static void sliceBinaryLong128VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Long128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Long128VectorTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4019,7 +4019,7 @@ static void sliceLong128VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Long128VectorTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = new long[SPECIES.length()]; @@ -4085,7 +4085,7 @@ static void unsliceBinaryLong128VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Long128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Long128VectorTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4141,7 +4141,7 @@ static void unsliceLong128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Long128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Long128VectorTests::unslice); } @@ -4190,7 +4190,7 @@ static void BITWISE_BLENDLong128VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Long128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Long128VectorTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") static void bitwiseBlendLong128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4206,7 +4206,7 @@ static void bitwiseBlendLong128VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Long128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Long128VectorTests::BITWISE_BLEND); } @@ -4247,7 +4247,7 @@ static void BITWISE_BLENDLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4276,7 +4276,7 @@ static void bitwiseBlendLong128VectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Long128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Long128VectorTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") @@ -4291,7 +4291,7 @@ static void bitwiseBlendLong128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4362,7 +4362,7 @@ static void bitwiseBlendLong128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::NEG); + assertArraysEquals(r, a, Long128VectorTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") @@ -4420,7 +4420,7 @@ static void negLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::neg); + assertArraysEquals(r, a, Long128VectorTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4438,7 +4438,7 @@ static void NEGMaskedLong128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long128VectorTests::NEG); + assertArraysEquals(r, a, mask, Long128VectorTests::NEG); } static long ABS(long a) { @@ -4461,7 +4461,7 @@ static void ABSLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::ABS); + assertArraysEquals(r, a, Long128VectorTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") @@ -4476,7 +4476,7 @@ static void absLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::abs); + assertArraysEquals(r, a, Long128VectorTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4494,7 +4494,7 @@ static void ABSMaskedLong128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long128VectorTests::ABS); + assertArraysEquals(r, a, mask, Long128VectorTests::ABS); } @@ -4520,7 +4520,7 @@ static void NOTLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::NOT); + assertArraysEquals(r, a, Long128VectorTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") @@ -4535,7 +4535,7 @@ static void notLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::not); + assertArraysEquals(r, a, Long128VectorTests::not); } @@ -4555,7 +4555,7 @@ static void NOTMaskedLong128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long128VectorTests::NOT); + assertArraysEquals(r, a, mask, Long128VectorTests::NOT); } @@ -4578,7 +4578,7 @@ static void ZOMOLong128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long128VectorTests::ZOMO); + assertArraysEquals(r, a, Long128VectorTests::ZOMO); } @@ -4598,7 +4598,7 @@ static void ZOMOMaskedLong128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Long128VectorTests::ZOMO); } @@ -4626,7 +4626,7 @@ static void gatherLong128VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long128VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Long128VectorTests::scatterMasked); } @@ -4759,8 +4759,8 @@ static void toIntArrayLong128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4770,8 +4770,8 @@ static void toLongArrayLong128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4781,8 +4781,8 @@ static void toDoubleArrayLong128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4831,7 +4831,7 @@ static void ADDReduceLongLong128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long128VectorTests::ADDReduce, Long128VectorTests::ADDReduceAll); } @@ -4853,7 +4853,7 @@ static void ADDReduceLongLong128VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long128VectorTests::ADDReduceMasked, Long128VectorTests::ADDReduceAllMasked); } @@ -4870,7 +4870,7 @@ static void SelectFromLong128VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") @@ -4889,7 +4889,7 @@ static void SelectFromLong128VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4966,7 +4966,7 @@ static void maskEqLong128VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Long128VectorTests::beq); + assertArraysEquals(r, a, b, Long128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java index 9b9101fdb50..3433fd0239b 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Long256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Long256VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Long256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(long[] a, long[] r, boolean[] mask) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0, "at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(long[] a, long[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "longProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new long[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index ff0983da916..6bd614f5a7c 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Long256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { long apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { long[] apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { long apply(long[] a); } - static void assertReductionArraysEquals(long[] a, long[] b, long c, + static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(long[] a, long[] b, long c, boolean[] mask, + static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -159,37 +159,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) { + static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -203,7 +203,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -217,7 +217,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int v } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -237,7 +237,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -257,7 +257,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boole } } - static void assertBroadcastArraysEquals(long[]a, long[]r) { + static void assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -286,7 +286,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -297,7 +297,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -309,7 +309,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -321,11 +321,11 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp } } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -336,11 +336,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -354,11 +354,11 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -372,7 +372,7 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolea } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -386,11 +386,11 @@ static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -416,7 +416,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -427,11 +427,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -443,7 +443,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -456,7 +456,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -469,12 +469,12 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -490,12 +490,12 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -511,7 +511,7 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -526,12 +526,12 @@ static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ interface FBinArrayOp { long apply(long[] a, int b); } - static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,7 +569,7 @@ interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -596,7 +596,7 @@ interface FScatterMaskedOp { long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -606,7 +606,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -617,7 +617,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -627,7 +627,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FSca } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -644,7 +644,7 @@ interface FLaneOp { long[] apply(long[] a, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { + static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -664,7 +664,7 @@ interface FLaneBop { long[] apply(long[] a, long[] b, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -674,7 +674,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBo } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -685,7 +685,7 @@ interface FLaneMaskedBop { long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -695,7 +695,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -706,7 +706,7 @@ interface FLanePartBop { long[] apply(long[] a, long[] b, int origin, int part, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -716,7 +716,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -728,7 +728,7 @@ interface FLanePartMaskedBop { long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -780,7 +780,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(long[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -793,7 +793,7 @@ static void assertArraysEquals(long[] a, int[] r, int offs) { - static void assertArraysEquals(long[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -804,7 +804,7 @@ static void assertArraysEquals(long[] a, long[] r, int offs) { } } - static void assertArraysEquals(long[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1275,7 +1275,7 @@ static void ADDLong256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::ADD); + assertArraysEquals(r, a, b, Long256VectorTests::ADD); } static long add(long a, long b) { return (long)(a + b); @@ -1293,7 +1293,7 @@ static void addLong256VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::add); + assertArraysEquals(r, a, b, Long256VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1313,7 +1313,7 @@ static void ADDLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::SUB); + assertArraysEquals(r, a, b, Long256VectorTests::SUB); } static long sub(long a, long b) { return (long)(a - b); @@ -1369,7 +1369,7 @@ static void subLong256VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::sub); + assertArraysEquals(r, a, b, Long256VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1389,7 +1389,7 @@ static void SUBLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::MUL); + assertArraysEquals(r, a, b, Long256VectorTests::MUL); } static long mul(long a, long b) { return (long)(a * b); @@ -1445,7 +1445,7 @@ static void mulLong256VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::mul); + assertArraysEquals(r, a, b, Long256VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1465,7 +1465,7 @@ static void MULLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::DIV); + assertArraysEquals(r, a, b, Long256VectorTests::DIV); } static long div(long a, long b) { return (long)(a / b); @@ -1530,7 +1530,7 @@ static void divLong256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::div); + assertArraysEquals(r, a, b, Long256VectorTests::div); } @@ -1554,7 +1554,7 @@ static void DIVLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Long256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Long256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1617,7 +1617,7 @@ static void FIRST_NONZEROLong256VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Long256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Long256VectorTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -1638,7 +1638,7 @@ static void ANDLong256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::AND); + assertArraysEquals(r, a, b, Long256VectorTests::AND); } static long and(long a, long b) { return (long)(a & b); @@ -1656,7 +1656,7 @@ static void andLong256VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::and); + assertArraysEquals(r, a, b, Long256VectorTests::and); } @@ -1678,7 +1678,7 @@ static void ANDLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Long256VectorTests::AND_NOT); } @@ -1744,7 +1744,7 @@ static void ORLong256VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long256VectorTests::OR); + assertArraysEquals(r, a, b, Long256VectorTests::OR); } static long or(long a, long b) { return (long)(a | b); @@ -1762,7 +1762,7 @@ static void orLong256VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::or); + assertArraysEquals(r, a, b, Long256VectorTests::or); } @@ -1784,7 +1784,7 @@ static void ORLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::XOR); + assertArraysEquals(r, a, b, Long256VectorTests::XOR); } @@ -1828,7 +1828,7 @@ static void XORLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1860,7 +1860,7 @@ static void addLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::add); } @Test(dataProvider = "longBinaryOpProvider") @@ -1874,7 +1874,7 @@ static void subLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1891,7 +1891,7 @@ static void subLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::sub); } @Test(dataProvider = "longBinaryOpProvider") @@ -1905,7 +1905,7 @@ static void mulLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1922,7 +1922,7 @@ static void mulLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::mul); } @@ -1941,7 +1941,7 @@ static void divLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::div); } @@ -1962,7 +1962,7 @@ static void divLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::div); } @@ -1978,7 +1978,7 @@ static void ORLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::OR); } @Test(dataProvider = "longBinaryOpProvider") @@ -1992,7 +1992,7 @@ static void orLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::or); } @@ -2011,7 +2011,7 @@ static void ORLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::OR); } @@ -2027,7 +2027,7 @@ static void ANDLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::AND); } @Test(dataProvider = "longBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void andLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::and); } @@ -2060,7 +2060,7 @@ static void ANDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::AND); } @@ -2076,7 +2076,7 @@ static void ORLong256VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::OR); } @@ -2095,7 +2095,7 @@ static void ORLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Long256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::OR); } @@ -2110,7 +2110,7 @@ static void ADDLong256VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -2127,7 +2127,7 @@ static void ADDLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long256VectorTests::LSHL); + assertArraysEquals(r, a, b, Long256VectorTests::LSHL); } @@ -2170,7 +2170,7 @@ static void LSHLLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long256VectorTests::ASHR); + assertArraysEquals(r, a, b, Long256VectorTests::ASHR); } @@ -2218,7 +2218,7 @@ static void ASHRLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long256VectorTests::LSHR); + assertArraysEquals(r, a, b, Long256VectorTests::LSHR); } @@ -2266,7 +2266,7 @@ static void LSHRLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::MIN); + assertArraysEquals(r, a, b, Long256VectorTests::MIN); } static long min(long a, long b) { return (long)(Math.min(a, b)); @@ -2447,7 +2447,7 @@ static void minLong256VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::min); + assertArraysEquals(r, a, b, Long256VectorTests::min); } static long MAX(long a, long b) { return (long)(Math.max(a, b)); @@ -2467,7 +2467,7 @@ static void MAXLong256VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long256VectorTests::MAX); + assertArraysEquals(r, a, b, Long256VectorTests::MAX); } static long max(long a, long b) { return (long)(Math.max(a, b)); @@ -2485,7 +2485,7 @@ static void maxLong256VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::max); + assertArraysEquals(r, a, b, Long256VectorTests::max); } @Test(dataProvider = "longBinaryOpProvider") @@ -2499,7 +2499,7 @@ static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") @@ -2513,7 +2513,7 @@ static void minLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::min); } @Test(dataProvider = "longBinaryOpProvider") @@ -2527,7 +2527,7 @@ static void MAXLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") @@ -2541,7 +2541,7 @@ static void maxLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Long256VectorTests::max); } static long ANDReduce(long[] a, int idx) { @@ -2584,7 +2584,7 @@ static void ANDReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::ANDReduce, Long256VectorTests::ANDReduceAll); } @@ -2632,7 +2632,7 @@ static void ANDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::ANDReduceMasked, Long256VectorTests::ANDReduceAllMasked); } @@ -2677,7 +2677,7 @@ static void ORReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::ORReduce, Long256VectorTests::ORReduceAll); } @@ -2725,7 +2725,7 @@ static void ORReduceLong256VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::ORReduceMasked, Long256VectorTests::ORReduceAllMasked); } @@ -2770,7 +2770,7 @@ static void XORReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::XORReduce, Long256VectorTests::XORReduceAll); } @@ -2818,7 +2818,7 @@ static void XORReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::XORReduceMasked, Long256VectorTests::XORReduceAllMasked); } @@ -2860,7 +2860,7 @@ static void ADDReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll); } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2904,7 +2904,7 @@ static void ADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { @@ -2945,7 +2945,7 @@ static void MULReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::MULReduce, Long256VectorTests::MULReduceAll); } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2989,7 +2989,7 @@ static void MULReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::MULReduceMasked, Long256VectorTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { @@ -3030,7 +3030,7 @@ static void MINReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::MINReduce, Long256VectorTests::MINReduceAll); } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3075,7 +3075,7 @@ static void MINReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::MINReduceMasked, Long256VectorTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { @@ -3116,7 +3116,7 @@ static void MAXReduceLong256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::MAXReduce, Long256VectorTests::MAXReduceAll); } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3161,7 +3161,7 @@ static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked); } @@ -3187,7 +3187,7 @@ static void anyTrueLong256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Long256VectorTests::anyTrue); } @@ -3213,7 +3213,7 @@ static void allTrueLong256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue); } @@ -3229,7 +3229,7 @@ static void withLong256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (long)4, 0); + assertInsertArraysEquals(r, a, (long)4, 0); } static boolean testIS_DEFAULT(long a) { return bits(a)==0; @@ -3706,7 +3706,7 @@ static void blendLong256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Long256VectorTests::blend); + assertArraysEquals(r, a, b, mask, Long256VectorTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") @@ -3723,7 +3723,7 @@ static void RearrangeLong256VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") @@ -3741,7 +3741,7 @@ static void RearrangeLong256VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "longUnaryOpProvider") static void getLong256VectorTests(IntFunction fa) { @@ -3896,7 +3896,7 @@ static void getLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::get); + assertArraysEquals(r, a, Long256VectorTests::get); } @Test(dataProvider = "longUnaryOpProvider") @@ -3910,7 +3910,7 @@ static void BroadcastLong256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3957,7 +3957,7 @@ static void sliceUnaryLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Long256VectorTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = new long[SPECIES.length()]; @@ -3986,7 +3986,7 @@ static void sliceBinaryLong256VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Long256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Long256VectorTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4019,7 +4019,7 @@ static void sliceLong256VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Long256VectorTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = new long[SPECIES.length()]; @@ -4085,7 +4085,7 @@ static void unsliceBinaryLong256VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Long256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Long256VectorTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4141,7 +4141,7 @@ static void unsliceLong256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Long256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Long256VectorTests::unslice); } @@ -4190,7 +4190,7 @@ static void BITWISE_BLENDLong256VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Long256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") static void bitwiseBlendLong256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4206,7 +4206,7 @@ static void bitwiseBlendLong256VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Long256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND); } @@ -4247,7 +4247,7 @@ static void BITWISE_BLENDLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4276,7 +4276,7 @@ static void bitwiseBlendLong256VectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Long256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") @@ -4291,7 +4291,7 @@ static void bitwiseBlendLong256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4362,7 +4362,7 @@ static void bitwiseBlendLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::NEG); + assertArraysEquals(r, a, Long256VectorTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") @@ -4420,7 +4420,7 @@ static void negLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::neg); + assertArraysEquals(r, a, Long256VectorTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4438,7 +4438,7 @@ static void NEGMaskedLong256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long256VectorTests::NEG); + assertArraysEquals(r, a, mask, Long256VectorTests::NEG); } static long ABS(long a) { @@ -4461,7 +4461,7 @@ static void ABSLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::ABS); + assertArraysEquals(r, a, Long256VectorTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") @@ -4476,7 +4476,7 @@ static void absLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::abs); + assertArraysEquals(r, a, Long256VectorTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4494,7 +4494,7 @@ static void ABSMaskedLong256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long256VectorTests::ABS); + assertArraysEquals(r, a, mask, Long256VectorTests::ABS); } @@ -4520,7 +4520,7 @@ static void NOTLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::NOT); + assertArraysEquals(r, a, Long256VectorTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") @@ -4535,7 +4535,7 @@ static void notLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::not); + assertArraysEquals(r, a, Long256VectorTests::not); } @@ -4555,7 +4555,7 @@ static void NOTMaskedLong256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long256VectorTests::NOT); + assertArraysEquals(r, a, mask, Long256VectorTests::NOT); } @@ -4578,7 +4578,7 @@ static void ZOMOLong256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long256VectorTests::ZOMO); + assertArraysEquals(r, a, Long256VectorTests::ZOMO); } @@ -4598,7 +4598,7 @@ static void ZOMOMaskedLong256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Long256VectorTests::ZOMO); } @@ -4626,7 +4626,7 @@ static void gatherLong256VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long256VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Long256VectorTests::scatterMasked); } @@ -4759,8 +4759,8 @@ static void toIntArrayLong256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4770,8 +4770,8 @@ static void toLongArrayLong256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4781,8 +4781,8 @@ static void toDoubleArrayLong256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4831,7 +4831,7 @@ static void ADDReduceLongLong256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll); } @@ -4853,7 +4853,7 @@ static void ADDReduceLongLong256VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked); } @@ -4870,7 +4870,7 @@ static void SelectFromLong256VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") @@ -4889,7 +4889,7 @@ static void SelectFromLong256VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4966,7 +4966,7 @@ static void maskEqLong256VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Long256VectorTests::beq); + assertArraysEquals(r, a, b, Long256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java index c56a0982ea9..c5724f854e4 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Long512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Long512VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Long512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(long[] a, long[] r, boolean[] mask) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0, "at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(long[] a, long[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "longProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new long[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index 8c79bb97b55..ca02ac5b726 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Long512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { long apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { long[] apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { long apply(long[] a); } - static void assertReductionArraysEquals(long[] a, long[] b, long c, + static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(long[] a, long[] b, long c, boolean[] mask, + static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -159,37 +159,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) { + static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -203,7 +203,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -217,7 +217,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int v } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -237,7 +237,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -257,7 +257,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boole } } - static void assertBroadcastArraysEquals(long[]a, long[]r) { + static void assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -286,7 +286,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -297,7 +297,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -309,7 +309,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -321,11 +321,11 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp } } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -336,11 +336,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -354,11 +354,11 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -372,7 +372,7 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolea } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -386,11 +386,11 @@ static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -416,7 +416,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -427,11 +427,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -443,7 +443,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -456,7 +456,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -469,12 +469,12 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -490,12 +490,12 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -511,7 +511,7 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -526,12 +526,12 @@ static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ interface FBinArrayOp { long apply(long[] a, int b); } - static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,7 +569,7 @@ interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -596,7 +596,7 @@ interface FScatterMaskedOp { long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -606,7 +606,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -617,7 +617,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -627,7 +627,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FSca } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -644,7 +644,7 @@ interface FLaneOp { long[] apply(long[] a, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { + static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -664,7 +664,7 @@ interface FLaneBop { long[] apply(long[] a, long[] b, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -674,7 +674,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBo } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -685,7 +685,7 @@ interface FLaneMaskedBop { long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -695,7 +695,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -706,7 +706,7 @@ interface FLanePartBop { long[] apply(long[] a, long[] b, int origin, int part, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -716,7 +716,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -728,7 +728,7 @@ interface FLanePartMaskedBop { long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -780,7 +780,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(long[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -793,7 +793,7 @@ static void assertArraysEquals(long[] a, int[] r, int offs) { - static void assertArraysEquals(long[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -804,7 +804,7 @@ static void assertArraysEquals(long[] a, long[] r, int offs) { } } - static void assertArraysEquals(long[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1275,7 +1275,7 @@ static void ADDLong512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::ADD); + assertArraysEquals(r, a, b, Long512VectorTests::ADD); } static long add(long a, long b) { return (long)(a + b); @@ -1293,7 +1293,7 @@ static void addLong512VectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::add); + assertArraysEquals(r, a, b, Long512VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1313,7 +1313,7 @@ static void ADDLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::SUB); + assertArraysEquals(r, a, b, Long512VectorTests::SUB); } static long sub(long a, long b) { return (long)(a - b); @@ -1369,7 +1369,7 @@ static void subLong512VectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::sub); + assertArraysEquals(r, a, b, Long512VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1389,7 +1389,7 @@ static void SUBLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::MUL); + assertArraysEquals(r, a, b, Long512VectorTests::MUL); } static long mul(long a, long b) { return (long)(a * b); @@ -1445,7 +1445,7 @@ static void mulLong512VectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::mul); + assertArraysEquals(r, a, b, Long512VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1465,7 +1465,7 @@ static void MULLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::DIV); + assertArraysEquals(r, a, b, Long512VectorTests::DIV); } static long div(long a, long b) { return (long)(a / b); @@ -1530,7 +1530,7 @@ static void divLong512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::div); + assertArraysEquals(r, a, b, Long512VectorTests::div); } @@ -1554,7 +1554,7 @@ static void DIVLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, Long512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Long512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1617,7 +1617,7 @@ static void FIRST_NONZEROLong512VectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, Long512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Long512VectorTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -1638,7 +1638,7 @@ static void ANDLong512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::AND); + assertArraysEquals(r, a, b, Long512VectorTests::AND); } static long and(long a, long b) { return (long)(a & b); @@ -1656,7 +1656,7 @@ static void andLong512VectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::and); + assertArraysEquals(r, a, b, Long512VectorTests::and); } @@ -1678,7 +1678,7 @@ static void ANDLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Long512VectorTests::AND_NOT); } @@ -1744,7 +1744,7 @@ static void ORLong512VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long512VectorTests::OR); + assertArraysEquals(r, a, b, Long512VectorTests::OR); } static long or(long a, long b) { return (long)(a | b); @@ -1762,7 +1762,7 @@ static void orLong512VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::or); + assertArraysEquals(r, a, b, Long512VectorTests::or); } @@ -1784,7 +1784,7 @@ static void ORLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::XOR); + assertArraysEquals(r, a, b, Long512VectorTests::XOR); } @@ -1828,7 +1828,7 @@ static void XORLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1860,7 +1860,7 @@ static void addLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::add); } @Test(dataProvider = "longBinaryOpProvider") @@ -1874,7 +1874,7 @@ static void subLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1891,7 +1891,7 @@ static void subLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::sub); } @Test(dataProvider = "longBinaryOpProvider") @@ -1905,7 +1905,7 @@ static void mulLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1922,7 +1922,7 @@ static void mulLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::mul); } @@ -1941,7 +1941,7 @@ static void divLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::div); } @@ -1962,7 +1962,7 @@ static void divLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::div); } @@ -1978,7 +1978,7 @@ static void ORLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::OR); } @Test(dataProvider = "longBinaryOpProvider") @@ -1992,7 +1992,7 @@ static void orLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::or); } @@ -2011,7 +2011,7 @@ static void ORLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::OR); } @@ -2027,7 +2027,7 @@ static void ANDLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::AND); } @Test(dataProvider = "longBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void andLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::and); } @@ -2060,7 +2060,7 @@ static void ANDLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::AND); } @@ -2076,7 +2076,7 @@ static void ORLong512VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Long512VectorTests::OR); } @@ -2095,7 +2095,7 @@ static void ORLong512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Long512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Long512VectorTests::OR); } @@ -2110,7 +2110,7 @@ static void ADDLong512VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Long512VectorTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -2127,7 +2127,7 @@ static void ADDLong512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long512VectorTests::LSHL); + assertArraysEquals(r, a, b, Long512VectorTests::LSHL); } @@ -2170,7 +2170,7 @@ static void LSHLLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long512VectorTests::ASHR); + assertArraysEquals(r, a, b, Long512VectorTests::ASHR); } @@ -2218,7 +2218,7 @@ static void ASHRLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Long512VectorTests::LSHR); + assertArraysEquals(r, a, b, Long512VectorTests::LSHR); } @@ -2266,7 +2266,7 @@ static void LSHRLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::MIN); + assertArraysEquals(r, a, b, Long512VectorTests::MIN); } static long min(long a, long b) { return (long)(Math.min(a, b)); @@ -2447,7 +2447,7 @@ static void minLong512VectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::min); + assertArraysEquals(r, a, b, Long512VectorTests::min); } static long MAX(long a, long b) { return (long)(Math.max(a, b)); @@ -2467,7 +2467,7 @@ static void MAXLong512VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long512VectorTests::MAX); + assertArraysEquals(r, a, b, Long512VectorTests::MAX); } static long max(long a, long b) { return (long)(Math.max(a, b)); @@ -2485,7 +2485,7 @@ static void maxLong512VectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::max); + assertArraysEquals(r, a, b, Long512VectorTests::max); } @Test(dataProvider = "longBinaryOpProvider") @@ -2499,7 +2499,7 @@ static void MINLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") @@ -2513,7 +2513,7 @@ static void minLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::min); } @Test(dataProvider = "longBinaryOpProvider") @@ -2527,7 +2527,7 @@ static void MAXLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") @@ -2541,7 +2541,7 @@ static void maxLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Long512VectorTests::max); } static long ANDReduce(long[] a, int idx) { @@ -2584,7 +2584,7 @@ static void ANDReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::ANDReduce, Long512VectorTests::ANDReduceAll); } @@ -2632,7 +2632,7 @@ static void ANDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::ANDReduceMasked, Long512VectorTests::ANDReduceAllMasked); } @@ -2677,7 +2677,7 @@ static void ORReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::ORReduce, Long512VectorTests::ORReduceAll); } @@ -2725,7 +2725,7 @@ static void ORReduceLong512VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::ORReduceMasked, Long512VectorTests::ORReduceAllMasked); } @@ -2770,7 +2770,7 @@ static void XORReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::XORReduce, Long512VectorTests::XORReduceAll); } @@ -2818,7 +2818,7 @@ static void XORReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::XORReduceMasked, Long512VectorTests::XORReduceAllMasked); } @@ -2860,7 +2860,7 @@ static void ADDReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::ADDReduce, Long512VectorTests::ADDReduceAll); } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2904,7 +2904,7 @@ static void ADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::ADDReduceMasked, Long512VectorTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { @@ -2945,7 +2945,7 @@ static void MULReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::MULReduce, Long512VectorTests::MULReduceAll); } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2989,7 +2989,7 @@ static void MULReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::MULReduceMasked, Long512VectorTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { @@ -3030,7 +3030,7 @@ static void MINReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::MINReduce, Long512VectorTests::MINReduceAll); } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3075,7 +3075,7 @@ static void MINReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::MINReduceMasked, Long512VectorTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { @@ -3116,7 +3116,7 @@ static void MAXReduceLong512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::MAXReduce, Long512VectorTests::MAXReduceAll); } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3161,7 +3161,7 @@ static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::MAXReduceMasked, Long512VectorTests::MAXReduceAllMasked); } @@ -3187,7 +3187,7 @@ static void anyTrueLong512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Long512VectorTests::anyTrue); } @@ -3213,7 +3213,7 @@ static void allTrueLong512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Long512VectorTests::allTrue); } @@ -3229,7 +3229,7 @@ static void withLong512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (long)4, 0); + assertInsertArraysEquals(r, a, (long)4, 0); } static boolean testIS_DEFAULT(long a) { return bits(a)==0; @@ -3706,7 +3706,7 @@ static void blendLong512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Long512VectorTests::blend); + assertArraysEquals(r, a, b, mask, Long512VectorTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") @@ -3723,7 +3723,7 @@ static void RearrangeLong512VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") @@ -3741,7 +3741,7 @@ static void RearrangeLong512VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "longUnaryOpProvider") static void getLong512VectorTests(IntFunction fa) { @@ -3896,7 +3896,7 @@ static void getLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::get); + assertArraysEquals(r, a, Long512VectorTests::get); } @Test(dataProvider = "longUnaryOpProvider") @@ -3910,7 +3910,7 @@ static void BroadcastLong512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3957,7 +3957,7 @@ static void sliceUnaryLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Long512VectorTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = new long[SPECIES.length()]; @@ -3986,7 +3986,7 @@ static void sliceBinaryLong512VectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, Long512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Long512VectorTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4019,7 +4019,7 @@ static void sliceLong512VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Long512VectorTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = new long[SPECIES.length()]; @@ -4085,7 +4085,7 @@ static void unsliceBinaryLong512VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, Long512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Long512VectorTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4141,7 +4141,7 @@ static void unsliceLong512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, Long512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Long512VectorTests::unslice); } @@ -4190,7 +4190,7 @@ static void BITWISE_BLENDLong512VectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, Long512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Long512VectorTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") static void bitwiseBlendLong512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4206,7 +4206,7 @@ static void bitwiseBlendLong512VectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, Long512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Long512VectorTests::BITWISE_BLEND); } @@ -4247,7 +4247,7 @@ static void BITWISE_BLENDLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4276,7 +4276,7 @@ static void bitwiseBlendLong512VectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Long512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Long512VectorTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") @@ -4291,7 +4291,7 @@ static void bitwiseBlendLong512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4362,7 +4362,7 @@ static void bitwiseBlendLong512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::NEG); + assertArraysEquals(r, a, Long512VectorTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") @@ -4420,7 +4420,7 @@ static void negLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::neg); + assertArraysEquals(r, a, Long512VectorTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4438,7 +4438,7 @@ static void NEGMaskedLong512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long512VectorTests::NEG); + assertArraysEquals(r, a, mask, Long512VectorTests::NEG); } static long ABS(long a) { @@ -4461,7 +4461,7 @@ static void ABSLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::ABS); + assertArraysEquals(r, a, Long512VectorTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") @@ -4476,7 +4476,7 @@ static void absLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::abs); + assertArraysEquals(r, a, Long512VectorTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4494,7 +4494,7 @@ static void ABSMaskedLong512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long512VectorTests::ABS); + assertArraysEquals(r, a, mask, Long512VectorTests::ABS); } @@ -4520,7 +4520,7 @@ static void NOTLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::NOT); + assertArraysEquals(r, a, Long512VectorTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") @@ -4535,7 +4535,7 @@ static void notLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::not); + assertArraysEquals(r, a, Long512VectorTests::not); } @@ -4555,7 +4555,7 @@ static void NOTMaskedLong512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long512VectorTests::NOT); + assertArraysEquals(r, a, mask, Long512VectorTests::NOT); } @@ -4578,7 +4578,7 @@ static void ZOMOLong512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long512VectorTests::ZOMO); + assertArraysEquals(r, a, Long512VectorTests::ZOMO); } @@ -4598,7 +4598,7 @@ static void ZOMOMaskedLong512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Long512VectorTests::ZOMO); } @@ -4626,7 +4626,7 @@ static void gatherLong512VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, Long512VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Long512VectorTests::scatterMasked); } @@ -4759,8 +4759,8 @@ static void toIntArrayLong512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4770,8 +4770,8 @@ static void toLongArrayLong512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4781,8 +4781,8 @@ static void toDoubleArrayLong512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4831,7 +4831,7 @@ static void ADDReduceLongLong512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long512VectorTests::ADDReduce, Long512VectorTests::ADDReduceAll); } @@ -4853,7 +4853,7 @@ static void ADDReduceLongLong512VectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long512VectorTests::ADDReduceMasked, Long512VectorTests::ADDReduceAllMasked); } @@ -4870,7 +4870,7 @@ static void SelectFromLong512VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") @@ -4889,7 +4889,7 @@ static void SelectFromLong512VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4966,7 +4966,7 @@ static void maskEqLong512VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Long512VectorTests::beq); + assertArraysEquals(r, a, b, Long512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java index b43cf51ec3a..c0764c57196 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Long64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Long64VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Long64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(long[] a, long[] r, boolean[] mask) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0, "at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(long[] a, long[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "longProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new long[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index a7cb17e71bf..2ba810968c0 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Long64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { long apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { long[] apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { long apply(long[] a); } - static void assertReductionArraysEquals(long[] a, long[] b, long c, + static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(long[] a, long[] b, long c, boolean[] mask, + static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -159,37 +159,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) { + static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -203,7 +203,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -217,7 +217,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int v } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -237,7 +237,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -257,7 +257,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boole } } - static void assertBroadcastArraysEquals(long[]a, long[]r) { + static void assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -286,7 +286,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -297,7 +297,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -309,7 +309,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -321,11 +321,11 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp } } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -336,11 +336,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -354,11 +354,11 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -372,7 +372,7 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolea } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -386,11 +386,11 @@ static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -416,7 +416,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -427,11 +427,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -443,7 +443,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -456,7 +456,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -469,12 +469,12 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -490,12 +490,12 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -511,7 +511,7 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -526,12 +526,12 @@ static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ interface FBinArrayOp { long apply(long[] a, int b); } - static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,7 +569,7 @@ interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -596,7 +596,7 @@ interface FScatterMaskedOp { long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -606,7 +606,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -617,7 +617,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -627,7 +627,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FSca } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -644,7 +644,7 @@ interface FLaneOp { long[] apply(long[] a, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { + static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -664,7 +664,7 @@ interface FLaneBop { long[] apply(long[] a, long[] b, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -674,7 +674,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBo } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -685,7 +685,7 @@ interface FLaneMaskedBop { long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -695,7 +695,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -706,7 +706,7 @@ interface FLanePartBop { long[] apply(long[] a, long[] b, int origin, int part, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -716,7 +716,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -728,7 +728,7 @@ interface FLanePartMaskedBop { long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -780,7 +780,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(long[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -793,7 +793,7 @@ static void assertArraysEquals(long[] a, int[] r, int offs) { - static void assertArraysEquals(long[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -804,7 +804,7 @@ static void assertArraysEquals(long[] a, long[] r, int offs) { } } - static void assertArraysEquals(long[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1275,7 +1275,7 @@ static void ADDLong64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::ADD); + assertArraysEquals(r, a, b, Long64VectorTests::ADD); } static long add(long a, long b) { return (long)(a + b); @@ -1293,7 +1293,7 @@ static void addLong64VectorTests(IntFunction fa, IntFunction fb) av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::add); + assertArraysEquals(r, a, b, Long64VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1313,7 +1313,7 @@ static void ADDLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::SUB); + assertArraysEquals(r, a, b, Long64VectorTests::SUB); } static long sub(long a, long b) { return (long)(a - b); @@ -1369,7 +1369,7 @@ static void subLong64VectorTests(IntFunction fa, IntFunction fb) av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::sub); + assertArraysEquals(r, a, b, Long64VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1389,7 +1389,7 @@ static void SUBLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::MUL); + assertArraysEquals(r, a, b, Long64VectorTests::MUL); } static long mul(long a, long b) { return (long)(a * b); @@ -1445,7 +1445,7 @@ static void mulLong64VectorTests(IntFunction fa, IntFunction fb) av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::mul); + assertArraysEquals(r, a, b, Long64VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1465,7 +1465,7 @@ static void MULLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::DIV); + assertArraysEquals(r, a, b, Long64VectorTests::DIV); } static long div(long a, long b) { return (long)(a / b); @@ -1530,7 +1530,7 @@ static void divLong64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::div); + assertArraysEquals(r, a, b, Long64VectorTests::div); } @@ -1554,7 +1554,7 @@ static void DIVLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, mask, Long64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Long64VectorTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -1638,7 +1638,7 @@ static void ANDLong64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::AND); + assertArraysEquals(r, a, b, Long64VectorTests::AND); } static long and(long a, long b) { return (long)(a & b); @@ -1656,7 +1656,7 @@ static void andLong64VectorTests(IntFunction fa, IntFunction fb) av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::and); + assertArraysEquals(r, a, b, Long64VectorTests::and); } @@ -1678,7 +1678,7 @@ static void ANDLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Long64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, Long64VectorTests::AND_NOT); } @@ -1722,7 +1722,7 @@ static void AND_NOTLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::OR); + assertArraysEquals(r, a, b, Long64VectorTests::OR); } static long or(long a, long b) { return (long)(a | b); @@ -1762,7 +1762,7 @@ static void orLong64VectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::or); + assertArraysEquals(r, a, b, Long64VectorTests::or); } @@ -1784,7 +1784,7 @@ static void ORLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::XOR); + assertArraysEquals(r, a, b, Long64VectorTests::XOR); } @@ -1828,7 +1828,7 @@ static void XORLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1860,7 +1860,7 @@ static void addLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::add); } @Test(dataProvider = "longBinaryOpProvider") @@ -1874,7 +1874,7 @@ static void subLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1891,7 +1891,7 @@ static void subLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::sub); } @Test(dataProvider = "longBinaryOpProvider") @@ -1905,7 +1905,7 @@ static void mulLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1922,7 +1922,7 @@ static void mulLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::mul); } @@ -1941,7 +1941,7 @@ static void divLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::div); } @@ -1962,7 +1962,7 @@ static void divLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::div); } @@ -1978,7 +1978,7 @@ static void ORLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::OR); } @Test(dataProvider = "longBinaryOpProvider") @@ -1992,7 +1992,7 @@ static void orLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::or); } @@ -2011,7 +2011,7 @@ static void ORLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::OR); } @@ -2027,7 +2027,7 @@ static void ANDLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::AND); } @Test(dataProvider = "longBinaryOpProvider") @@ -2041,7 +2041,7 @@ static void andLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::and); } @@ -2060,7 +2060,7 @@ static void ANDLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::AND); } @@ -2076,7 +2076,7 @@ static void ORLong64VectorTestsBroadcastLongSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::OR); } @@ -2095,7 +2095,7 @@ static void ORLong64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Long64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::OR); } @@ -2110,7 +2110,7 @@ static void ADDLong64VectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Long64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -2127,7 +2127,7 @@ static void ADDLong64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, Long64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::ADD); } static long LSHL(long a, long b) { @@ -2148,7 +2148,7 @@ static void LSHLLong64VectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long64VectorTests::LSHL); + assertArraysEquals(r, a, b, Long64VectorTests::LSHL); } @@ -2170,7 +2170,7 @@ static void LSHLLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long64VectorTests::ASHR); + assertArraysEquals(r, a, b, Long64VectorTests::ASHR); } @@ -2218,7 +2218,7 @@ static void ASHRLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, Long64VectorTests::LSHR); + assertArraysEquals(r, a, b, Long64VectorTests::LSHR); } @@ -2266,7 +2266,7 @@ static void LSHRLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::MIN); + assertArraysEquals(r, a, b, Long64VectorTests::MIN); } static long min(long a, long b) { return (long)(Math.min(a, b)); @@ -2447,7 +2447,7 @@ static void minLong64VectorTests(IntFunction fa, IntFunction fb) av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::min); + assertArraysEquals(r, a, b, Long64VectorTests::min); } static long MAX(long a, long b) { return (long)(Math.max(a, b)); @@ -2467,7 +2467,7 @@ static void MAXLong64VectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, Long64VectorTests::MAX); + assertArraysEquals(r, a, b, Long64VectorTests::MAX); } static long max(long a, long b) { return (long)(Math.max(a, b)); @@ -2485,7 +2485,7 @@ static void maxLong64VectorTests(IntFunction fa, IntFunction fb) av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::max); + assertArraysEquals(r, a, b, Long64VectorTests::max); } @Test(dataProvider = "longBinaryOpProvider") @@ -2499,7 +2499,7 @@ static void MINLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") @@ -2513,7 +2513,7 @@ static void minLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::min); } @Test(dataProvider = "longBinaryOpProvider") @@ -2527,7 +2527,7 @@ static void MAXLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") @@ -2541,7 +2541,7 @@ static void maxLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Long64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Long64VectorTests::max); } static long ANDReduce(long[] a, int idx) { @@ -2584,7 +2584,7 @@ static void ANDReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::ANDReduce, Long64VectorTests::ANDReduceAll); } @@ -2632,7 +2632,7 @@ static void ANDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::ANDReduceMasked, Long64VectorTests::ANDReduceAllMasked); } @@ -2677,7 +2677,7 @@ static void ORReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::ORReduce, Long64VectorTests::ORReduceAll); } @@ -2725,7 +2725,7 @@ static void ORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction< } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::ORReduceMasked, Long64VectorTests::ORReduceAllMasked); } @@ -2770,7 +2770,7 @@ static void XORReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::XORReduce, Long64VectorTests::XORReduceAll); } @@ -2818,7 +2818,7 @@ static void XORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::XORReduceMasked, Long64VectorTests::XORReduceAllMasked); } @@ -2860,7 +2860,7 @@ static void ADDReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll); } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2904,7 +2904,7 @@ static void ADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { @@ -2945,7 +2945,7 @@ static void MULReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::MULReduce, Long64VectorTests::MULReduceAll); } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2989,7 +2989,7 @@ static void MULReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::MULReduceMasked, Long64VectorTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { @@ -3030,7 +3030,7 @@ static void MINReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::MINReduce, Long64VectorTests::MINReduceAll); } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3075,7 +3075,7 @@ static void MINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::MINReduceMasked, Long64VectorTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { @@ -3116,7 +3116,7 @@ static void MAXReduceLong64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::MAXReduce, Long64VectorTests::MAXReduceAll); } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3161,7 +3161,7 @@ static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::MAXReduceMasked, Long64VectorTests::MAXReduceAllMasked); } @@ -3187,7 +3187,7 @@ static void anyTrueLong64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Long64VectorTests::anyTrue); } @@ -3213,7 +3213,7 @@ static void allTrueLong64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Long64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Long64VectorTests::allTrue); } @@ -3229,7 +3229,7 @@ static void withLong64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (long)4, 0); + assertInsertArraysEquals(r, a, (long)4, 0); } static boolean testIS_DEFAULT(long a) { return bits(a)==0; @@ -3706,7 +3706,7 @@ static void blendLong64VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, mask, Long64VectorTests::blend); + assertArraysEquals(r, a, b, mask, Long64VectorTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") @@ -3723,7 +3723,7 @@ static void RearrangeLong64VectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") @@ -3741,7 +3741,7 @@ static void RearrangeLong64VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "longUnaryOpProvider") static void getLong64VectorTests(IntFunction fa) { @@ -3896,7 +3896,7 @@ static void getLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::get); + assertArraysEquals(r, a, Long64VectorTests::get); } @Test(dataProvider = "longUnaryOpProvider") @@ -3910,7 +3910,7 @@ static void BroadcastLong64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3957,7 +3957,7 @@ static void sliceUnaryLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Long64VectorTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = new long[SPECIES.length()]; @@ -3986,7 +3986,7 @@ static void sliceBinaryLong64VectorTestsBinary(IntFunction fa, IntFuncti } } - assertArraysEquals(a, b, r, origin, Long64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Long64VectorTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4019,7 +4019,7 @@ static void sliceLong64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Long64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Long64VectorTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = new long[SPECIES.length()]; @@ -4085,7 +4085,7 @@ static void unsliceBinaryLong64VectorTestsBinary(IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, origin, part, Long64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Long64VectorTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4141,7 +4141,7 @@ static void unsliceLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4206,7 +4206,7 @@ static void bitwiseBlendLong64VectorTests(IntFunction fa, IntFunction fa, IntFunc } } - assertArraysEquals(a, b, c, r, mask, Long64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND); } @@ -4247,7 +4247,7 @@ static void BITWISE_BLENDLong64VectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Long64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") @@ -4262,7 +4262,7 @@ static void BITWISE_BLENDLong64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4276,7 +4276,7 @@ static void bitwiseBlendLong64VectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, Long64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") @@ -4291,7 +4291,7 @@ static void bitwiseBlendLong64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4362,7 +4362,7 @@ static void bitwiseBlendLong64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::NEG); + assertArraysEquals(r, a, Long64VectorTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") @@ -4420,7 +4420,7 @@ static void negLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::neg); + assertArraysEquals(r, a, Long64VectorTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4438,7 +4438,7 @@ static void NEGMaskedLong64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long64VectorTests::NEG); + assertArraysEquals(r, a, mask, Long64VectorTests::NEG); } static long ABS(long a) { @@ -4461,7 +4461,7 @@ static void ABSLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::ABS); + assertArraysEquals(r, a, Long64VectorTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") @@ -4476,7 +4476,7 @@ static void absLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::abs); + assertArraysEquals(r, a, Long64VectorTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4494,7 +4494,7 @@ static void ABSMaskedLong64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long64VectorTests::ABS); + assertArraysEquals(r, a, mask, Long64VectorTests::ABS); } @@ -4520,7 +4520,7 @@ static void NOTLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::NOT); + assertArraysEquals(r, a, Long64VectorTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") @@ -4535,7 +4535,7 @@ static void notLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::not); + assertArraysEquals(r, a, Long64VectorTests::not); } @@ -4555,7 +4555,7 @@ static void NOTMaskedLong64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long64VectorTests::NOT); + assertArraysEquals(r, a, mask, Long64VectorTests::NOT); } @@ -4578,7 +4578,7 @@ static void ZOMOLong64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Long64VectorTests::ZOMO); + assertArraysEquals(r, a, Long64VectorTests::ZOMO); } @@ -4598,7 +4598,7 @@ static void ZOMOMaskedLong64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Long64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Long64VectorTests::ZOMO); } @@ -4626,7 +4626,7 @@ static void gatherLong64VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4770,8 +4770,8 @@ static void toLongArrayLong64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4781,8 +4781,8 @@ static void toDoubleArrayLong64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4831,7 +4831,7 @@ static void ADDReduceLongLong64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll); } @@ -4853,7 +4853,7 @@ static void ADDReduceLongLong64VectorTestsMasked(IntFunction fa, IntFunc ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked); } @@ -4870,7 +4870,7 @@ static void SelectFromLong64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") @@ -4889,7 +4889,7 @@ static void SelectFromLong64VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4966,7 +4966,7 @@ static void maskEqLong64VectorTestsSmokeTest(IntFunction fa, IntFunct var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Long64VectorTests::beq); + assertArraysEquals(r, a, b, Long64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java index 596066cc0c0..4f092652734 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * LongMaxVectorLoadStoreTests + * -XX:-TieredCompilation LongMaxVectorLoadStoreTests * */ @@ -67,47 +67,25 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(long[] a, long[] r, boolean[] mask) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (long) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (long) 0, "at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(long[] a, long[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (long) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -410,7 +388,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "longProviderForIOOBE") @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new long[a.length]; @@ -492,7 +470,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longMaskProviderForIOOBE") @@ -565,7 +543,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -589,7 +567,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -676,7 +654,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -691,7 +669,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -807,7 +785,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "longByteProviderForIOOBE") @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -899,7 +877,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "longByteMaskProviderForIOOBE") @@ -976,7 +954,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -987,7 +965,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index a8415ee1858..364ae80ddc5 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch LongMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { long apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { long[] apply(long a); } - static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(long[] a, long[] r, FUnArrayOp f) { } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { long apply(long[] a); } - static void assertReductionArraysEquals(long[] a, long[] b, long c, + static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(long[] a, long[] b, long c, boolean[] mask, + static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -164,37 +164,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) { + static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -208,7 +208,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vec } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -222,7 +222,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, int v } } - static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -242,7 +242,7 @@ static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, boolean } } - static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -262,7 +262,7 @@ static void assertSelectFromArraysEquals(long[] a, long[] r, long[] order, boole } } - static void assertBroadcastArraysEquals(long[]a, long[]r) { + static void assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -291,7 +291,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -302,7 +302,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -314,7 +314,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, FBinOp f) } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -326,11 +326,11 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, FBinOp } } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -341,11 +341,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBi } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -359,11 +359,11 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] } } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -377,7 +377,7 @@ static void assertBroadcastLongArraysEquals(long[] a, long[] b, long[] r, boolea } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -391,11 +391,11 @@ static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) { } } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -421,7 +421,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -432,11 +432,11 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f } } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -448,7 +448,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -461,7 +461,7 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -474,12 +474,12 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -495,12 +495,12 @@ static void assertBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, } } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -516,7 +516,7 @@ static void assertAltBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -531,12 +531,12 @@ static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long } } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(long[] a, long[] b, long[] c, long[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ interface FBinArrayOp { long apply(long[] a, int b); } - static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) { + static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,7 +574,7 @@ interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -601,7 +601,7 @@ interface FScatterMaskedOp { long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -611,7 +611,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -622,7 +622,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FGat } } - static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -632,7 +632,7 @@ static void assertArraysEquals(long[] a, int[] b, long[] r, boolean[] mask, FSca } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -649,7 +649,7 @@ interface FLaneOp { long[] apply(long[] a, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { + static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -659,7 +659,7 @@ static void assertArraysEquals(long[] a, long[] r, int origin, FLaneOp f) { } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -669,7 +669,7 @@ interface FLaneBop { long[] apply(long[] a, long[] b, int origin, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -679,7 +679,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, FLaneBo } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -690,7 +690,7 @@ interface FLaneMaskedBop { long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -700,7 +700,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, boolean } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -711,7 +711,7 @@ interface FLanePartBop { long[] apply(long[] a, long[] b, int origin, int part, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -721,7 +721,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -733,7 +733,7 @@ interface FLanePartMaskedBop { long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -743,7 +743,7 @@ static void assertArraysEquals(long[] a, long[] b, long[] r, int origin, int par } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -785,7 +785,7 @@ static int intCornerCaseValue(int i) { }) ); - static void assertArraysEquals(long[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -798,7 +798,7 @@ static void assertArraysEquals(long[] a, int[] r, int offs) { - static void assertArraysEquals(long[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -809,7 +809,7 @@ static void assertArraysEquals(long[] a, long[] r, int offs) { } } - static void assertArraysEquals(long[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1280,7 +1280,7 @@ static void ADDLongMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::ADD); + assertArraysEquals(r, a, b, LongMaxVectorTests::ADD); } static long add(long a, long b) { return (long)(a + b); @@ -1298,7 +1298,7 @@ static void addLongMaxVectorTests(IntFunction fa, IntFunction fb av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::add); + assertArraysEquals(r, a, b, LongMaxVectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1318,7 +1318,7 @@ static void ADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::SUB); + assertArraysEquals(r, a, b, LongMaxVectorTests::SUB); } static long sub(long a, long b) { return (long)(a - b); @@ -1374,7 +1374,7 @@ static void subLongMaxVectorTests(IntFunction fa, IntFunction fb av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::sub); + assertArraysEquals(r, a, b, LongMaxVectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1394,7 +1394,7 @@ static void SUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::MUL); + assertArraysEquals(r, a, b, LongMaxVectorTests::MUL); } static long mul(long a, long b) { return (long)(a * b); @@ -1450,7 +1450,7 @@ static void mulLongMaxVectorTests(IntFunction fa, IntFunction fb av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::mul); + assertArraysEquals(r, a, b, LongMaxVectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1470,7 +1470,7 @@ static void MULLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::DIV); + assertArraysEquals(r, a, b, LongMaxVectorTests::DIV); } static long div(long a, long b) { return (long)(a / b); @@ -1535,7 +1535,7 @@ static void divLongMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::div); + assertArraysEquals(r, a, b, LongMaxVectorTests::div); } @@ -1559,7 +1559,7 @@ static void DIVLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, LongMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1622,7 +1622,7 @@ static void FIRST_NONZEROLongMaxVectorTestsMasked(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, mask, LongMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -1643,7 +1643,7 @@ static void ANDLongMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::AND); + assertArraysEquals(r, a, b, LongMaxVectorTests::AND); } static long and(long a, long b) { return (long)(a & b); @@ -1661,7 +1661,7 @@ static void andLongMaxVectorTests(IntFunction fa, IntFunction fb av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::and); + assertArraysEquals(r, a, b, LongMaxVectorTests::and); } @@ -1683,7 +1683,7 @@ static void ANDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, LongMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND_NOT); } @@ -1749,7 +1749,7 @@ static void ORLongMaxVectorTests(IntFunction fa, IntFunction fb) } } - assertArraysEquals(a, b, r, LongMaxVectorTests::OR); + assertArraysEquals(r, a, b, LongMaxVectorTests::OR); } static long or(long a, long b) { return (long)(a | b); @@ -1767,7 +1767,7 @@ static void orLongMaxVectorTests(IntFunction fa, IntFunction fb) av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::or); + assertArraysEquals(r, a, b, LongMaxVectorTests::or); } @@ -1789,7 +1789,7 @@ static void ORLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::XOR); + assertArraysEquals(r, a, b, LongMaxVectorTests::XOR); } @@ -1833,7 +1833,7 @@ static void XORLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntF av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1865,7 +1865,7 @@ static void addLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::add); } @Test(dataProvider = "longBinaryOpProvider") @@ -1879,7 +1879,7 @@ static void subLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1896,7 +1896,7 @@ static void subLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::sub); } @Test(dataProvider = "longBinaryOpProvider") @@ -1910,7 +1910,7 @@ static void mulLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -1927,7 +1927,7 @@ static void mulLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::mul); } @@ -1946,7 +1946,7 @@ static void divLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::div); } @@ -1967,7 +1967,7 @@ static void divLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::div); } @@ -1983,7 +1983,7 @@ static void ORLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::OR); } @Test(dataProvider = "longBinaryOpProvider") @@ -1997,7 +1997,7 @@ static void orLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::or); } @@ -2016,7 +2016,7 @@ static void ORLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); } @@ -2032,7 +2032,7 @@ static void ANDLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::AND); } @Test(dataProvider = "longBinaryOpProvider") @@ -2046,7 +2046,7 @@ static void andLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::and); } @@ -2065,7 +2065,7 @@ static void ANDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::AND); } @@ -2081,7 +2081,7 @@ static void ORLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, I av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, LongMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::OR); } @@ -2100,7 +2100,7 @@ static void ORLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, mask, LongMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); } @@ -2115,7 +2115,7 @@ static void ADDLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, LongMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") @@ -2132,7 +2132,7 @@ static void ADDLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, LongMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, LongMaxVectorTests::LSHL); } @@ -2175,7 +2175,7 @@ static void LSHLLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, LongMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, LongMaxVectorTests::ASHR); } @@ -2223,7 +2223,7 @@ static void ASHRLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, LongMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, LongMaxVectorTests::LSHR); } @@ -2271,7 +2271,7 @@ static void LSHRLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::MIN); + assertArraysEquals(r, a, b, LongMaxVectorTests::MIN); } static long min(long a, long b) { return (long)(Math.min(a, b)); @@ -2452,7 +2452,7 @@ static void minLongMaxVectorTests(IntFunction fa, IntFunction fb av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::min); + assertArraysEquals(r, a, b, LongMaxVectorTests::min); } static long MAX(long a, long b) { return (long)(Math.max(a, b)); @@ -2472,7 +2472,7 @@ static void MAXLongMaxVectorTests(IntFunction fa, IntFunction fb } } - assertArraysEquals(a, b, r, LongMaxVectorTests::MAX); + assertArraysEquals(r, a, b, LongMaxVectorTests::MAX); } static long max(long a, long b) { return (long)(Math.max(a, b)); @@ -2490,7 +2490,7 @@ static void maxLongMaxVectorTests(IntFunction fa, IntFunction fb av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::max); + assertArraysEquals(r, a, b, LongMaxVectorTests::max); } @Test(dataProvider = "longBinaryOpProvider") @@ -2504,7 +2504,7 @@ static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") @@ -2518,7 +2518,7 @@ static void minLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::min); } @Test(dataProvider = "longBinaryOpProvider") @@ -2532,7 +2532,7 @@ static void MAXLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") @@ -2546,7 +2546,7 @@ static void maxLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::max); } static long ANDReduce(long[] a, int idx) { @@ -2589,7 +2589,7 @@ static void ANDReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::ANDReduce, LongMaxVectorTests::ANDReduceAll); } @@ -2637,7 +2637,7 @@ static void ANDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::ANDReduceMasked, LongMaxVectorTests::ANDReduceAllMasked); } @@ -2682,7 +2682,7 @@ static void ORReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::ORReduce, LongMaxVectorTests::ORReduceAll); } @@ -2730,7 +2730,7 @@ static void ORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::ORReduceMasked, LongMaxVectorTests::ORReduceAllMasked); } @@ -2775,7 +2775,7 @@ static void XORReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::XORReduce, LongMaxVectorTests::XORReduceAll); } @@ -2823,7 +2823,7 @@ static void XORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::XORReduceMasked, LongMaxVectorTests::XORReduceAllMasked); } @@ -2865,7 +2865,7 @@ static void ADDReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2909,7 +2909,7 @@ static void ADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { @@ -2950,7 +2950,7 @@ static void MULReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::MULReduce, LongMaxVectorTests::MULReduceAll); } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { @@ -2994,7 +2994,7 @@ static void MULReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::MULReduceMasked, LongMaxVectorTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { @@ -3035,7 +3035,7 @@ static void MINReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::MINReduce, LongMaxVectorTests::MINReduceAll); } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3080,7 +3080,7 @@ static void MINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::MINReduceMasked, LongMaxVectorTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { @@ -3121,7 +3121,7 @@ static void MAXReduceLongMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::MAXReduce, LongMaxVectorTests::MAXReduceAll); } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { @@ -3166,7 +3166,7 @@ static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked); } @@ -3192,7 +3192,7 @@ static void anyTrueLongMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, LongMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::anyTrue); } @@ -3218,7 +3218,7 @@ static void allTrueLongMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, LongMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue); } @@ -3234,7 +3234,7 @@ static void withLongMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (long)4, 0); + assertInsertArraysEquals(r, a, (long)4, 0); } static boolean testIS_DEFAULT(long a) { return bits(a)==0; @@ -3711,7 +3711,7 @@ static void blendLongMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, LongMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") @@ -3728,7 +3728,7 @@ static void RearrangeLongMaxVectorTests(IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") @@ -3746,7 +3746,7 @@ static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "longUnaryOpProvider") static void getLongMaxVectorTests(IntFunction fa) { @@ -3901,7 +3901,7 @@ static void getLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::get); + assertArraysEquals(r, a, LongMaxVectorTests::get); } @Test(dataProvider = "longUnaryOpProvider") @@ -3915,7 +3915,7 @@ static void BroadcastLongMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -3962,7 +3962,7 @@ static void sliceUnaryLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, LongMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = new long[SPECIES.length()]; @@ -3991,7 +3991,7 @@ static void sliceBinaryLongMaxVectorTestsBinary(IntFunction fa, IntFunct } } - assertArraysEquals(a, b, r, origin, LongMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4024,7 +4024,7 @@ static void sliceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, LongMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = new long[SPECIES.length()]; @@ -4090,7 +4090,7 @@ static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, part, LongMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = new long[SPECIES.length()]; @@ -4146,7 +4146,7 @@ static void unsliceLongMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, part, mask, LongMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice); } @@ -4195,7 +4195,7 @@ static void BITWISE_BLENDLongMaxVectorTests(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, c, r, LongMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") static void bitwiseBlendLongMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4211,7 +4211,7 @@ static void bitwiseBlendLongMaxVectorTests(IntFunction fa, IntFunction fa, IntFun } } - assertArraysEquals(a, b, c, r, mask, LongMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); } @@ -4252,7 +4252,7 @@ static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4281,7 +4281,7 @@ static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, LongMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") @@ -4296,7 +4296,7 @@ static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4367,7 +4367,7 @@ static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::NEG); + assertArraysEquals(r, a, LongMaxVectorTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") @@ -4425,7 +4425,7 @@ static void negLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::neg); + assertArraysEquals(r, a, LongMaxVectorTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4443,7 +4443,7 @@ static void NEGMaskedLongMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, LongMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG); } static long ABS(long a) { @@ -4466,7 +4466,7 @@ static void ABSLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::ABS); + assertArraysEquals(r, a, LongMaxVectorTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") @@ -4481,7 +4481,7 @@ static void absLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::abs); + assertArraysEquals(r, a, LongMaxVectorTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") @@ -4499,7 +4499,7 @@ static void ABSMaskedLongMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, LongMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS); } @@ -4525,7 +4525,7 @@ static void NOTLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::NOT); + assertArraysEquals(r, a, LongMaxVectorTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") @@ -4540,7 +4540,7 @@ static void notLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::not); + assertArraysEquals(r, a, LongMaxVectorTests::not); } @@ -4560,7 +4560,7 @@ static void NOTMaskedLongMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, LongMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT); } @@ -4583,7 +4583,7 @@ static void ZOMOLongMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, LongMaxVectorTests::ZOMO); + assertArraysEquals(r, a, LongMaxVectorTests::ZOMO); } @@ -4603,7 +4603,7 @@ static void ZOMOMaskedLongMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, LongMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO); } @@ -4631,7 +4631,7 @@ static void gatherLongMaxVectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, mask, LongMaxVectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::scatterMasked); } @@ -4764,8 +4764,8 @@ static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4775,8 +4775,8 @@ static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4786,8 +4786,8 @@ static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4836,7 +4836,7 @@ static void ADDReduceLongLongMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); } @@ -4858,7 +4858,7 @@ static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction fa, IntFun ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); } @@ -4875,7 +4875,7 @@ static void SelectFromLongMaxVectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") @@ -4894,7 +4894,7 @@ static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -4971,7 +4971,7 @@ static void maskEqLongMaxVectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, LongMaxVectorTests::beq); + assertArraysEquals(r, a, b, LongMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java index 8603e37d5f1..0b723fd3827 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Short128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Short128VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Short128VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8)); - static void assertArraysEquals(short[] a, short[] r, boolean[] mask) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(short[] a, short[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "shortProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new short[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 27fb3a844d4..91f3e215759 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Short128VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { short apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { short[] apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { short apply(short[] a); } - static void assertReductionArraysEquals(short[] a, short[] b, short c, + static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { short apply(short[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(short[] a, short[] b, short c, boolean[] mask, + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(short[] a); } - static void assertReductionLongArraysEquals(short[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(short[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(short[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(short[] a, short[] b, short element, int index) { + static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, in } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, bo } } - static void assertBroadcastArraysEquals(short[]a, short[]r) { + static void assertBroadcastArraysEquals(short[] r, short[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBi } } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boo } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTern } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boole } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, s } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { short apply(short[] a, int b); } - static void assertArraysEquals(short[] a, short[] r, FBinArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, FGatherScatterOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FS } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { short[] apply(short[] a, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { short[] apply(short[] a, short[] b, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLaneBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLan } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, bool } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { short[] apply(short[] a, short[] b, int origin, int part, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } - static void assertArraysEquals(short[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(short[] a, int[] r, int offs) { - static void assertArraysEquals(short[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(short[] a, long[] r, int offs) { } } - static void assertArraysEquals(short[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1278,7 +1278,7 @@ static void ADDShort128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::ADD); + assertArraysEquals(r, a, b, Short128VectorTests::ADD); } static short add(short a, short b) { return (short)(a + b); @@ -1296,7 +1296,7 @@ static void addShort128VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::add); + assertArraysEquals(r, a, b, Short128VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1316,7 +1316,7 @@ static void ADDShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::SUB); + assertArraysEquals(r, a, b, Short128VectorTests::SUB); } static short sub(short a, short b) { return (short)(a - b); @@ -1372,7 +1372,7 @@ static void subShort128VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::sub); + assertArraysEquals(r, a, b, Short128VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1392,7 +1392,7 @@ static void SUBShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::MUL); + assertArraysEquals(r, a, b, Short128VectorTests::MUL); } static short mul(short a, short b) { return (short)(a * b); @@ -1448,7 +1448,7 @@ static void mulShort128VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::mul); + assertArraysEquals(r, a, b, Short128VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1468,7 +1468,7 @@ static void MULShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::DIV); + assertArraysEquals(r, a, b, Short128VectorTests::DIV); } static short div(short a, short b) { return (short)(a / b); @@ -1533,7 +1533,7 @@ static void divShort128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::div); + assertArraysEquals(r, a, b, Short128VectorTests::div); } @@ -1557,7 +1557,7 @@ static void DIVShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Short128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Short128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1620,7 +1620,7 @@ static void FIRST_NONZEROShort128VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Short128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Short128VectorTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -1641,7 +1641,7 @@ static void ANDShort128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::AND); + assertArraysEquals(r, a, b, Short128VectorTests::AND); } static short and(short a, short b) { return (short)(a & b); @@ -1659,7 +1659,7 @@ static void andShort128VectorTests(IntFunction fa, IntFunction av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::and); + assertArraysEquals(r, a, b, Short128VectorTests::and); } @@ -1681,7 +1681,7 @@ static void ANDShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Short128VectorTests::AND_NOT); } @@ -1747,7 +1747,7 @@ static void ORShort128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::OR); + assertArraysEquals(r, a, b, Short128VectorTests::OR); } static short or(short a, short b) { return (short)(a | b); @@ -1765,7 +1765,7 @@ static void orShort128VectorTests(IntFunction fa, IntFunction av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::or); + assertArraysEquals(r, a, b, Short128VectorTests::or); } @@ -1787,7 +1787,7 @@ static void ORShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::XOR); + assertArraysEquals(r, a, b, Short128VectorTests::XOR); } @@ -1831,7 +1831,7 @@ static void XORShort128VectorTestsMasked(IntFunction fa, IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1863,7 +1863,7 @@ static void addShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::add); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1877,7 +1877,7 @@ static void subShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1894,7 +1894,7 @@ static void subShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1908,7 +1908,7 @@ static void mulShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1925,7 +1925,7 @@ static void mulShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::mul); } @@ -1944,7 +1944,7 @@ static void divShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::div); } @@ -1965,7 +1965,7 @@ static void divShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::div); } @@ -1981,7 +1981,7 @@ static void ORShort128VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1995,7 +1995,7 @@ static void orShort128VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::or); } @@ -2014,7 +2014,7 @@ static void ORShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::OR); } @@ -2030,7 +2030,7 @@ static void ANDShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2044,7 +2044,7 @@ static void andShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::and); } @@ -2063,7 +2063,7 @@ static void ANDShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::AND); } @@ -2079,7 +2079,7 @@ static void ORShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Short128VectorTests::OR); } @@ -2098,7 +2098,7 @@ static void ORShort128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Short128VectorTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -2130,7 +2130,7 @@ static void ADDShort128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::MIN); + assertArraysEquals(r, a, b, Short128VectorTests::MIN); } static short min(short a, short b) { return (short)(Math.min(a, b)); @@ -2450,7 +2450,7 @@ static void minShort128VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::min); + assertArraysEquals(r, a, b, Short128VectorTests::min); } static short MAX(short a, short b) { return (short)(Math.max(a, b)); @@ -2470,7 +2470,7 @@ static void MAXShort128VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short128VectorTests::MAX); + assertArraysEquals(r, a, b, Short128VectorTests::MAX); } static short max(short a, short b) { return (short)(Math.max(a, b)); @@ -2488,7 +2488,7 @@ static void maxShort128VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::max); + assertArraysEquals(r, a, b, Short128VectorTests::max); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2502,7 +2502,7 @@ static void MINShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2516,7 +2516,7 @@ static void minShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::min); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2530,7 +2530,7 @@ static void MAXShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2544,7 +2544,7 @@ static void maxShort128VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Short128VectorTests::max); } static short ANDReduce(short[] a, int idx) { @@ -2587,7 +2587,7 @@ static void ANDReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::ANDReduce, Short128VectorTests::ANDReduceAll); } @@ -2635,7 +2635,7 @@ static void ANDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::ANDReduceMasked, Short128VectorTests::ANDReduceAllMasked); } @@ -2680,7 +2680,7 @@ static void ORReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::ORReduce, Short128VectorTests::ORReduceAll); } @@ -2728,7 +2728,7 @@ static void ORReduceShort128VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::ORReduceMasked, Short128VectorTests::ORReduceAllMasked); } @@ -2773,7 +2773,7 @@ static void XORReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::XORReduce, Short128VectorTests::XORReduceAll); } @@ -2821,7 +2821,7 @@ static void XORReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::XORReduceMasked, Short128VectorTests::XORReduceAllMasked); } @@ -2863,7 +2863,7 @@ static void ADDReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::ADDReduce, Short128VectorTests::ADDReduceAll); } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2907,7 +2907,7 @@ static void ADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::ADDReduceMasked, Short128VectorTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { @@ -2948,7 +2948,7 @@ static void MULReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::MULReduce, Short128VectorTests::MULReduceAll); } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2992,7 +2992,7 @@ static void MULReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::MULReduceMasked, Short128VectorTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { @@ -3033,7 +3033,7 @@ static void MINReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::MINReduce, Short128VectorTests::MINReduceAll); } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3078,7 +3078,7 @@ static void MINReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::MINReduceMasked, Short128VectorTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { @@ -3119,7 +3119,7 @@ static void MAXReduceShort128VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short128VectorTests::MAXReduce, Short128VectorTests::MAXReduceAll); } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3164,7 +3164,7 @@ static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::MAXReduceMasked, Short128VectorTests::MAXReduceAllMasked); } @@ -3190,7 +3190,7 @@ static void anyTrueShort128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Short128VectorTests::anyTrue); } @@ -3216,7 +3216,7 @@ static void allTrueShort128VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Short128VectorTests::allTrue); } @@ -3232,7 +3232,7 @@ static void withShort128VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (short)4, 0); + assertInsertArraysEquals(r, a, (short)4, 0); } static boolean testIS_DEFAULT(short a) { return bits(a)==0; @@ -3781,7 +3781,7 @@ static void blendShort128VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") @@ -3816,7 +3816,7 @@ static void RearrangeShort128VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpProvider") static void getShort128VectorTests(IntFunction fa) { @@ -3971,7 +3971,7 @@ static void getShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::get); + assertArraysEquals(r, a, Short128VectorTests::get); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3985,7 +3985,7 @@ static void BroadcastShort128VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4032,7 +4032,7 @@ static void sliceUnaryShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Short128VectorTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4061,7 +4061,7 @@ static void sliceBinaryShort128VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Short128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Short128VectorTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4094,7 +4094,7 @@ static void sliceShort128VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Short128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Short128VectorTests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4121,7 +4121,7 @@ static void unsliceUnaryShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Short128VectorTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { short[] res = new short[SPECIES.length()]; @@ -4160,7 +4160,7 @@ static void unsliceBinaryShort128VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Short128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Short128VectorTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4216,7 +4216,7 @@ static void unsliceShort128VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Short128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Short128VectorTests::unslice); } @@ -4265,7 +4265,7 @@ static void BITWISE_BLENDShort128VectorTests(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, c, r, Short128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") static void bitwiseBlendShort128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4281,7 +4281,7 @@ static void bitwiseBlendShort128VectorTests(IntFunction fa, IntFunction av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Short128VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); } @@ -4304,7 +4304,7 @@ static void BITWISE_BLENDShort128VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, c, r, mask, Short128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); } @@ -4322,7 +4322,7 @@ static void BITWISE_BLENDShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4351,7 +4351,7 @@ static void bitwiseBlendShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4437,7 +4437,7 @@ static void bitwiseBlendShort128VectorTestsDoubleBroadcastSmokeTest(IntFunction< av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Short128VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); } @@ -4456,7 +4456,7 @@ static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, Short128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); } @@ -4480,7 +4480,7 @@ static void NEGShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::NEG); + assertArraysEquals(r, a, Short128VectorTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4495,7 +4495,7 @@ static void negShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::neg); + assertArraysEquals(r, a, Short128VectorTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4513,7 +4513,7 @@ static void NEGMaskedShort128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short128VectorTests::NEG); + assertArraysEquals(r, a, mask, Short128VectorTests::NEG); } static short ABS(short a) { @@ -4536,7 +4536,7 @@ static void ABSShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::ABS); + assertArraysEquals(r, a, Short128VectorTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4551,7 +4551,7 @@ static void absShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::abs); + assertArraysEquals(r, a, Short128VectorTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4569,7 +4569,7 @@ static void ABSMaskedShort128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short128VectorTests::ABS); + assertArraysEquals(r, a, mask, Short128VectorTests::ABS); } @@ -4595,7 +4595,7 @@ static void NOTShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::NOT); + assertArraysEquals(r, a, Short128VectorTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4610,7 +4610,7 @@ static void notShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::not); + assertArraysEquals(r, a, Short128VectorTests::not); } @@ -4630,7 +4630,7 @@ static void NOTMaskedShort128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short128VectorTests::NOT); + assertArraysEquals(r, a, mask, Short128VectorTests::NOT); } @@ -4653,7 +4653,7 @@ static void ZOMOShort128VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short128VectorTests::ZOMO); + assertArraysEquals(r, a, Short128VectorTests::ZOMO); } @@ -4673,7 +4673,7 @@ static void ZOMOMaskedShort128VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Short128VectorTests::ZOMO); } @@ -4701,7 +4701,7 @@ static void gatherShort128VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Short128VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Short128VectorTests::gatherMasked); } static short[] scatter(short a[], int ix, int[] b, int iy) { @@ -4754,7 +4754,7 @@ static void scatterShort128VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short128VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Short128VectorTests::scatterMasked); } @@ -4834,8 +4834,8 @@ static void toIntArrayShort128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4845,8 +4845,8 @@ static void toLongArrayShort128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4856,8 +4856,8 @@ static void toDoubleArrayShort128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4923,7 +4923,7 @@ static void ADDReduceLongShort128VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Short128VectorTests::ADDReduceLong, Short128VectorTests::ADDReduceAllLong); } @@ -4964,7 +4964,7 @@ static void ADDReduceLongShort128VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Short128VectorTests::ADDReduceLongMasked, Short128VectorTests::ADDReduceAllLongMasked); } @@ -4976,7 +4976,7 @@ static void BroadcastLongShort128VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -4994,7 +4994,7 @@ static void blendShort128VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Short128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::blend); } @@ -5011,7 +5011,7 @@ static void SelectFromShort128VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") @@ -5030,7 +5030,7 @@ static void SelectFromShort128VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5107,7 +5107,7 @@ static void maskEqShort128VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Short128VectorTests::beq); + assertArraysEquals(r, a, b, Short128VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java index 0193f6f72ce..567ae6c7486 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Short256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Short256VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Short256VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8)); - static void assertArraysEquals(short[] a, short[] r, boolean[] mask) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(short[] a, short[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "shortProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new short[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index 6a555957743..efbde094120 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Short256VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { short apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { short[] apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { short apply(short[] a); } - static void assertReductionArraysEquals(short[] a, short[] b, short c, + static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { short apply(short[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(short[] a, short[] b, short c, boolean[] mask, + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(short[] a); } - static void assertReductionLongArraysEquals(short[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(short[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(short[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(short[] a, short[] b, short element, int index) { + static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, in } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, bo } } - static void assertBroadcastArraysEquals(short[]a, short[]r) { + static void assertBroadcastArraysEquals(short[] r, short[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBi } } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boo } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTern } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boole } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, s } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { short apply(short[] a, int b); } - static void assertArraysEquals(short[] a, short[] r, FBinArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, FGatherScatterOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FS } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { short[] apply(short[] a, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { short[] apply(short[] a, short[] b, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLaneBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLan } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, bool } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { short[] apply(short[] a, short[] b, int origin, int part, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } - static void assertArraysEquals(short[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(short[] a, int[] r, int offs) { - static void assertArraysEquals(short[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(short[] a, long[] r, int offs) { } } - static void assertArraysEquals(short[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1278,7 +1278,7 @@ static void ADDShort256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::ADD); + assertArraysEquals(r, a, b, Short256VectorTests::ADD); } static short add(short a, short b) { return (short)(a + b); @@ -1296,7 +1296,7 @@ static void addShort256VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::add); + assertArraysEquals(r, a, b, Short256VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1316,7 +1316,7 @@ static void ADDShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::SUB); + assertArraysEquals(r, a, b, Short256VectorTests::SUB); } static short sub(short a, short b) { return (short)(a - b); @@ -1372,7 +1372,7 @@ static void subShort256VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::sub); + assertArraysEquals(r, a, b, Short256VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1392,7 +1392,7 @@ static void SUBShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::MUL); + assertArraysEquals(r, a, b, Short256VectorTests::MUL); } static short mul(short a, short b) { return (short)(a * b); @@ -1448,7 +1448,7 @@ static void mulShort256VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::mul); + assertArraysEquals(r, a, b, Short256VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1468,7 +1468,7 @@ static void MULShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::DIV); + assertArraysEquals(r, a, b, Short256VectorTests::DIV); } static short div(short a, short b) { return (short)(a / b); @@ -1533,7 +1533,7 @@ static void divShort256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::div); + assertArraysEquals(r, a, b, Short256VectorTests::div); } @@ -1557,7 +1557,7 @@ static void DIVShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Short256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Short256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1620,7 +1620,7 @@ static void FIRST_NONZEROShort256VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Short256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Short256VectorTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -1641,7 +1641,7 @@ static void ANDShort256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::AND); + assertArraysEquals(r, a, b, Short256VectorTests::AND); } static short and(short a, short b) { return (short)(a & b); @@ -1659,7 +1659,7 @@ static void andShort256VectorTests(IntFunction fa, IntFunction av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::and); + assertArraysEquals(r, a, b, Short256VectorTests::and); } @@ -1681,7 +1681,7 @@ static void ANDShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Short256VectorTests::AND_NOT); } @@ -1747,7 +1747,7 @@ static void ORShort256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::OR); + assertArraysEquals(r, a, b, Short256VectorTests::OR); } static short or(short a, short b) { return (short)(a | b); @@ -1765,7 +1765,7 @@ static void orShort256VectorTests(IntFunction fa, IntFunction av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::or); + assertArraysEquals(r, a, b, Short256VectorTests::or); } @@ -1787,7 +1787,7 @@ static void ORShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::XOR); + assertArraysEquals(r, a, b, Short256VectorTests::XOR); } @@ -1831,7 +1831,7 @@ static void XORShort256VectorTestsMasked(IntFunction fa, IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1863,7 +1863,7 @@ static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::add); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1877,7 +1877,7 @@ static void subShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1894,7 +1894,7 @@ static void subShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1908,7 +1908,7 @@ static void mulShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1925,7 +1925,7 @@ static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::mul); } @@ -1944,7 +1944,7 @@ static void divShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::div); } @@ -1965,7 +1965,7 @@ static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::div); } @@ -1981,7 +1981,7 @@ static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1995,7 +1995,7 @@ static void orShort256VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::or); } @@ -2014,7 +2014,7 @@ static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::OR); } @@ -2030,7 +2030,7 @@ static void ANDShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2044,7 +2044,7 @@ static void andShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::and); } @@ -2063,7 +2063,7 @@ static void ANDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::AND); } @@ -2079,7 +2079,7 @@ static void ORShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::OR); } @@ -2098,7 +2098,7 @@ static void ORShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -2130,7 +2130,7 @@ static void ADDShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::MIN); + assertArraysEquals(r, a, b, Short256VectorTests::MIN); } static short min(short a, short b) { return (short)(Math.min(a, b)); @@ -2450,7 +2450,7 @@ static void minShort256VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::min); + assertArraysEquals(r, a, b, Short256VectorTests::min); } static short MAX(short a, short b) { return (short)(Math.max(a, b)); @@ -2470,7 +2470,7 @@ static void MAXShort256VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short256VectorTests::MAX); + assertArraysEquals(r, a, b, Short256VectorTests::MAX); } static short max(short a, short b) { return (short)(Math.max(a, b)); @@ -2488,7 +2488,7 @@ static void maxShort256VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::max); + assertArraysEquals(r, a, b, Short256VectorTests::max); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2502,7 +2502,7 @@ static void MINShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2516,7 +2516,7 @@ static void minShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::min); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2530,7 +2530,7 @@ static void MAXShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2544,7 +2544,7 @@ static void maxShort256VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Short256VectorTests::max); } static short ANDReduce(short[] a, int idx) { @@ -2587,7 +2587,7 @@ static void ANDReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::ANDReduce, Short256VectorTests::ANDReduceAll); } @@ -2635,7 +2635,7 @@ static void ANDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::ANDReduceMasked, Short256VectorTests::ANDReduceAllMasked); } @@ -2680,7 +2680,7 @@ static void ORReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::ORReduce, Short256VectorTests::ORReduceAll); } @@ -2728,7 +2728,7 @@ static void ORReduceShort256VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::ORReduceMasked, Short256VectorTests::ORReduceAllMasked); } @@ -2773,7 +2773,7 @@ static void XORReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::XORReduce, Short256VectorTests::XORReduceAll); } @@ -2821,7 +2821,7 @@ static void XORReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::XORReduceMasked, Short256VectorTests::XORReduceAllMasked); } @@ -2863,7 +2863,7 @@ static void ADDReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::ADDReduce, Short256VectorTests::ADDReduceAll); } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2907,7 +2907,7 @@ static void ADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::ADDReduceMasked, Short256VectorTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { @@ -2948,7 +2948,7 @@ static void MULReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::MULReduce, Short256VectorTests::MULReduceAll); } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2992,7 +2992,7 @@ static void MULReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::MULReduceMasked, Short256VectorTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { @@ -3033,7 +3033,7 @@ static void MINReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::MINReduce, Short256VectorTests::MINReduceAll); } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3078,7 +3078,7 @@ static void MINReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::MINReduceMasked, Short256VectorTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { @@ -3119,7 +3119,7 @@ static void MAXReduceShort256VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short256VectorTests::MAXReduce, Short256VectorTests::MAXReduceAll); } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3164,7 +3164,7 @@ static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked); } @@ -3190,7 +3190,7 @@ static void anyTrueShort256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Short256VectorTests::anyTrue); } @@ -3216,7 +3216,7 @@ static void allTrueShort256VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue); } @@ -3232,7 +3232,7 @@ static void withShort256VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (short)4, 0); + assertInsertArraysEquals(r, a, (short)4, 0); } static boolean testIS_DEFAULT(short a) { return bits(a)==0; @@ -3781,7 +3781,7 @@ static void blendShort256VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") @@ -3816,7 +3816,7 @@ static void RearrangeShort256VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpProvider") static void getShort256VectorTests(IntFunction fa) { @@ -3971,7 +3971,7 @@ static void getShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::get); + assertArraysEquals(r, a, Short256VectorTests::get); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3985,7 +3985,7 @@ static void BroadcastShort256VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4032,7 +4032,7 @@ static void sliceUnaryShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Short256VectorTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4061,7 +4061,7 @@ static void sliceBinaryShort256VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Short256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Short256VectorTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4094,7 +4094,7 @@ static void sliceShort256VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Short256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Short256VectorTests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4121,7 +4121,7 @@ static void unsliceUnaryShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Short256VectorTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { short[] res = new short[SPECIES.length()]; @@ -4160,7 +4160,7 @@ static void unsliceBinaryShort256VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Short256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Short256VectorTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4216,7 +4216,7 @@ static void unsliceShort256VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Short256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Short256VectorTests::unslice); } @@ -4265,7 +4265,7 @@ static void BITWISE_BLENDShort256VectorTests(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, c, r, Short256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") static void bitwiseBlendShort256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4281,7 +4281,7 @@ static void bitwiseBlendShort256VectorTests(IntFunction fa, IntFunction av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Short256VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); } @@ -4304,7 +4304,7 @@ static void BITWISE_BLENDShort256VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, c, r, mask, Short256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); } @@ -4322,7 +4322,7 @@ static void BITWISE_BLENDShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4351,7 +4351,7 @@ static void bitwiseBlendShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4437,7 +4437,7 @@ static void bitwiseBlendShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction< av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Short256VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); } @@ -4456,7 +4456,7 @@ static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, Short256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); } @@ -4480,7 +4480,7 @@ static void NEGShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::NEG); + assertArraysEquals(r, a, Short256VectorTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4495,7 +4495,7 @@ static void negShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::neg); + assertArraysEquals(r, a, Short256VectorTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4513,7 +4513,7 @@ static void NEGMaskedShort256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short256VectorTests::NEG); + assertArraysEquals(r, a, mask, Short256VectorTests::NEG); } static short ABS(short a) { @@ -4536,7 +4536,7 @@ static void ABSShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::ABS); + assertArraysEquals(r, a, Short256VectorTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4551,7 +4551,7 @@ static void absShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::abs); + assertArraysEquals(r, a, Short256VectorTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4569,7 +4569,7 @@ static void ABSMaskedShort256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short256VectorTests::ABS); + assertArraysEquals(r, a, mask, Short256VectorTests::ABS); } @@ -4595,7 +4595,7 @@ static void NOTShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::NOT); + assertArraysEquals(r, a, Short256VectorTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4610,7 +4610,7 @@ static void notShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::not); + assertArraysEquals(r, a, Short256VectorTests::not); } @@ -4630,7 +4630,7 @@ static void NOTMaskedShort256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short256VectorTests::NOT); + assertArraysEquals(r, a, mask, Short256VectorTests::NOT); } @@ -4653,7 +4653,7 @@ static void ZOMOShort256VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short256VectorTests::ZOMO); + assertArraysEquals(r, a, Short256VectorTests::ZOMO); } @@ -4673,7 +4673,7 @@ static void ZOMOMaskedShort256VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Short256VectorTests::ZOMO); } @@ -4701,7 +4701,7 @@ static void gatherShort256VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Short256VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Short256VectorTests::gatherMasked); } static short[] scatter(short a[], int ix, int[] b, int iy) { @@ -4754,7 +4754,7 @@ static void scatterShort256VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short256VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Short256VectorTests::scatterMasked); } @@ -4834,8 +4834,8 @@ static void toIntArrayShort256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4845,8 +4845,8 @@ static void toLongArrayShort256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4856,8 +4856,8 @@ static void toDoubleArrayShort256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4923,7 +4923,7 @@ static void ADDReduceLongShort256VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Short256VectorTests::ADDReduceLong, Short256VectorTests::ADDReduceAllLong); } @@ -4964,7 +4964,7 @@ static void ADDReduceLongShort256VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Short256VectorTests::ADDReduceLongMasked, Short256VectorTests::ADDReduceAllLongMasked); } @@ -4976,7 +4976,7 @@ static void BroadcastLongShort256VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -4994,7 +4994,7 @@ static void blendShort256VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Short256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::blend); } @@ -5011,7 +5011,7 @@ static void SelectFromShort256VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") @@ -5030,7 +5030,7 @@ static void SelectFromShort256VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5107,7 +5107,7 @@ static void maskEqShort256VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Short256VectorTests::beq); + assertArraysEquals(r, a, b, Short256VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java index fc24134cf1c..ae9d392d75f 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Short512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Short512VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Short512VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8)); - static void assertArraysEquals(short[] a, short[] r, boolean[] mask) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(short[] a, short[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "shortProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new short[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index 03a54b5729e..16463ba45d8 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Short512VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { short apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { short[] apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { short apply(short[] a); } - static void assertReductionArraysEquals(short[] a, short[] b, short c, + static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { short apply(short[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(short[] a, short[] b, short c, boolean[] mask, + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(short[] a); } - static void assertReductionLongArraysEquals(short[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(short[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(short[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(short[] a, short[] b, short element, int index) { + static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, in } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, bo } } - static void assertBroadcastArraysEquals(short[]a, short[]r) { + static void assertBroadcastArraysEquals(short[] r, short[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBi } } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boo } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTern } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boole } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, s } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { short apply(short[] a, int b); } - static void assertArraysEquals(short[] a, short[] r, FBinArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, FGatherScatterOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FS } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { short[] apply(short[] a, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { short[] apply(short[] a, short[] b, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLaneBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLan } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, bool } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { short[] apply(short[] a, short[] b, int origin, int part, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } - static void assertArraysEquals(short[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(short[] a, int[] r, int offs) { - static void assertArraysEquals(short[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(short[] a, long[] r, int offs) { } } - static void assertArraysEquals(short[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1278,7 +1278,7 @@ static void ADDShort512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::ADD); + assertArraysEquals(r, a, b, Short512VectorTests::ADD); } static short add(short a, short b) { return (short)(a + b); @@ -1296,7 +1296,7 @@ static void addShort512VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::add); + assertArraysEquals(r, a, b, Short512VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1316,7 +1316,7 @@ static void ADDShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::SUB); + assertArraysEquals(r, a, b, Short512VectorTests::SUB); } static short sub(short a, short b) { return (short)(a - b); @@ -1372,7 +1372,7 @@ static void subShort512VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::sub); + assertArraysEquals(r, a, b, Short512VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1392,7 +1392,7 @@ static void SUBShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::MUL); + assertArraysEquals(r, a, b, Short512VectorTests::MUL); } static short mul(short a, short b) { return (short)(a * b); @@ -1448,7 +1448,7 @@ static void mulShort512VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::mul); + assertArraysEquals(r, a, b, Short512VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1468,7 +1468,7 @@ static void MULShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::DIV); + assertArraysEquals(r, a, b, Short512VectorTests::DIV); } static short div(short a, short b) { return (short)(a / b); @@ -1533,7 +1533,7 @@ static void divShort512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::div); + assertArraysEquals(r, a, b, Short512VectorTests::div); } @@ -1557,7 +1557,7 @@ static void DIVShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, Short512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Short512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1620,7 +1620,7 @@ static void FIRST_NONZEROShort512VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, Short512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Short512VectorTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -1641,7 +1641,7 @@ static void ANDShort512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::AND); + assertArraysEquals(r, a, b, Short512VectorTests::AND); } static short and(short a, short b) { return (short)(a & b); @@ -1659,7 +1659,7 @@ static void andShort512VectorTests(IntFunction fa, IntFunction av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::and); + assertArraysEquals(r, a, b, Short512VectorTests::and); } @@ -1681,7 +1681,7 @@ static void ANDShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Short512VectorTests::AND_NOT); } @@ -1747,7 +1747,7 @@ static void ORShort512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::OR); + assertArraysEquals(r, a, b, Short512VectorTests::OR); } static short or(short a, short b) { return (short)(a | b); @@ -1765,7 +1765,7 @@ static void orShort512VectorTests(IntFunction fa, IntFunction av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::or); + assertArraysEquals(r, a, b, Short512VectorTests::or); } @@ -1787,7 +1787,7 @@ static void ORShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::XOR); + assertArraysEquals(r, a, b, Short512VectorTests::XOR); } @@ -1831,7 +1831,7 @@ static void XORShort512VectorTestsMasked(IntFunction fa, IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1863,7 +1863,7 @@ static void addShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::add); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1877,7 +1877,7 @@ static void subShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1894,7 +1894,7 @@ static void subShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1908,7 +1908,7 @@ static void mulShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1925,7 +1925,7 @@ static void mulShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::mul); } @@ -1944,7 +1944,7 @@ static void divShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::div); } @@ -1965,7 +1965,7 @@ static void divShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::div); } @@ -1981,7 +1981,7 @@ static void ORShort512VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1995,7 +1995,7 @@ static void orShort512VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::or); } @@ -2014,7 +2014,7 @@ static void ORShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::OR); } @@ -2030,7 +2030,7 @@ static void ANDShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2044,7 +2044,7 @@ static void andShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::and); } @@ -2063,7 +2063,7 @@ static void ANDShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::AND); } @@ -2079,7 +2079,7 @@ static void ORShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Short512VectorTests::OR); } @@ -2098,7 +2098,7 @@ static void ORShort512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Short512VectorTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -2130,7 +2130,7 @@ static void ADDShort512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::MIN); + assertArraysEquals(r, a, b, Short512VectorTests::MIN); } static short min(short a, short b) { return (short)(Math.min(a, b)); @@ -2450,7 +2450,7 @@ static void minShort512VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::min); + assertArraysEquals(r, a, b, Short512VectorTests::min); } static short MAX(short a, short b) { return (short)(Math.max(a, b)); @@ -2470,7 +2470,7 @@ static void MAXShort512VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short512VectorTests::MAX); + assertArraysEquals(r, a, b, Short512VectorTests::MAX); } static short max(short a, short b) { return (short)(Math.max(a, b)); @@ -2488,7 +2488,7 @@ static void maxShort512VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::max); + assertArraysEquals(r, a, b, Short512VectorTests::max); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2502,7 +2502,7 @@ static void MINShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2516,7 +2516,7 @@ static void minShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::min); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2530,7 +2530,7 @@ static void MAXShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2544,7 +2544,7 @@ static void maxShort512VectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Short512VectorTests::max); } static short ANDReduce(short[] a, int idx) { @@ -2587,7 +2587,7 @@ static void ANDReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::ANDReduce, Short512VectorTests::ANDReduceAll); } @@ -2635,7 +2635,7 @@ static void ANDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::ANDReduceMasked, Short512VectorTests::ANDReduceAllMasked); } @@ -2680,7 +2680,7 @@ static void ORReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::ORReduce, Short512VectorTests::ORReduceAll); } @@ -2728,7 +2728,7 @@ static void ORReduceShort512VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::ORReduceMasked, Short512VectorTests::ORReduceAllMasked); } @@ -2773,7 +2773,7 @@ static void XORReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::XORReduce, Short512VectorTests::XORReduceAll); } @@ -2821,7 +2821,7 @@ static void XORReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::XORReduceMasked, Short512VectorTests::XORReduceAllMasked); } @@ -2863,7 +2863,7 @@ static void ADDReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::ADDReduce, Short512VectorTests::ADDReduceAll); } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2907,7 +2907,7 @@ static void ADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::ADDReduceMasked, Short512VectorTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { @@ -2948,7 +2948,7 @@ static void MULReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::MULReduce, Short512VectorTests::MULReduceAll); } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2992,7 +2992,7 @@ static void MULReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::MULReduceMasked, Short512VectorTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { @@ -3033,7 +3033,7 @@ static void MINReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::MINReduce, Short512VectorTests::MINReduceAll); } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3078,7 +3078,7 @@ static void MINReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::MINReduceMasked, Short512VectorTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { @@ -3119,7 +3119,7 @@ static void MAXReduceShort512VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short512VectorTests::MAXReduce, Short512VectorTests::MAXReduceAll); } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3164,7 +3164,7 @@ static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::MAXReduceMasked, Short512VectorTests::MAXReduceAllMasked); } @@ -3190,7 +3190,7 @@ static void anyTrueShort512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Short512VectorTests::anyTrue); } @@ -3216,7 +3216,7 @@ static void allTrueShort512VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Short512VectorTests::allTrue); } @@ -3232,7 +3232,7 @@ static void withShort512VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (short)4, 0); + assertInsertArraysEquals(r, a, (short)4, 0); } static boolean testIS_DEFAULT(short a) { return bits(a)==0; @@ -3781,7 +3781,7 @@ static void blendShort512VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") @@ -3816,7 +3816,7 @@ static void RearrangeShort512VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpProvider") static void getShort512VectorTests(IntFunction fa) { @@ -3971,7 +3971,7 @@ static void getShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::get); + assertArraysEquals(r, a, Short512VectorTests::get); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3985,7 +3985,7 @@ static void BroadcastShort512VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4032,7 +4032,7 @@ static void sliceUnaryShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Short512VectorTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4061,7 +4061,7 @@ static void sliceBinaryShort512VectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, Short512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Short512VectorTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4094,7 +4094,7 @@ static void sliceShort512VectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, Short512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, Short512VectorTests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4121,7 +4121,7 @@ static void unsliceUnaryShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Short512VectorTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { short[] res = new short[SPECIES.length()]; @@ -4160,7 +4160,7 @@ static void unsliceBinaryShort512VectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, Short512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Short512VectorTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4216,7 +4216,7 @@ static void unsliceShort512VectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, Short512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Short512VectorTests::unslice); } @@ -4265,7 +4265,7 @@ static void BITWISE_BLENDShort512VectorTests(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, c, r, Short512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Short512VectorTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") static void bitwiseBlendShort512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4281,7 +4281,7 @@ static void bitwiseBlendShort512VectorTests(IntFunction fa, IntFunction av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Short512VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); } @@ -4304,7 +4304,7 @@ static void BITWISE_BLENDShort512VectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, c, r, mask, Short512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); } @@ -4322,7 +4322,7 @@ static void BITWISE_BLENDShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4351,7 +4351,7 @@ static void bitwiseBlendShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4437,7 +4437,7 @@ static void bitwiseBlendShort512VectorTestsDoubleBroadcastSmokeTest(IntFunction< av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, Short512VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); } @@ -4456,7 +4456,7 @@ static void BITWISE_BLENDShort512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, Short512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); } @@ -4480,7 +4480,7 @@ static void NEGShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::NEG); + assertArraysEquals(r, a, Short512VectorTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4495,7 +4495,7 @@ static void negShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::neg); + assertArraysEquals(r, a, Short512VectorTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4513,7 +4513,7 @@ static void NEGMaskedShort512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short512VectorTests::NEG); + assertArraysEquals(r, a, mask, Short512VectorTests::NEG); } static short ABS(short a) { @@ -4536,7 +4536,7 @@ static void ABSShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::ABS); + assertArraysEquals(r, a, Short512VectorTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4551,7 +4551,7 @@ static void absShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::abs); + assertArraysEquals(r, a, Short512VectorTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4569,7 +4569,7 @@ static void ABSMaskedShort512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short512VectorTests::ABS); + assertArraysEquals(r, a, mask, Short512VectorTests::ABS); } @@ -4595,7 +4595,7 @@ static void NOTShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::NOT); + assertArraysEquals(r, a, Short512VectorTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4610,7 +4610,7 @@ static void notShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::not); + assertArraysEquals(r, a, Short512VectorTests::not); } @@ -4630,7 +4630,7 @@ static void NOTMaskedShort512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short512VectorTests::NOT); + assertArraysEquals(r, a, mask, Short512VectorTests::NOT); } @@ -4653,7 +4653,7 @@ static void ZOMOShort512VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short512VectorTests::ZOMO); + assertArraysEquals(r, a, Short512VectorTests::ZOMO); } @@ -4673,7 +4673,7 @@ static void ZOMOMaskedShort512VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Short512VectorTests::ZOMO); } @@ -4701,7 +4701,7 @@ static void gatherShort512VectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, Short512VectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, Short512VectorTests::gatherMasked); } static short[] scatter(short a[], int ix, int[] b, int iy) { @@ -4754,7 +4754,7 @@ static void scatterShort512VectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, Short512VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Short512VectorTests::scatterMasked); } @@ -4834,8 +4834,8 @@ static void toIntArrayShort512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4845,8 +4845,8 @@ static void toLongArrayShort512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4856,8 +4856,8 @@ static void toDoubleArrayShort512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4923,7 +4923,7 @@ static void ADDReduceLongShort512VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Short512VectorTests::ADDReduceLong, Short512VectorTests::ADDReduceAllLong); } @@ -4964,7 +4964,7 @@ static void ADDReduceLongShort512VectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Short512VectorTests::ADDReduceLongMasked, Short512VectorTests::ADDReduceAllLongMasked); } @@ -4976,7 +4976,7 @@ static void BroadcastLongShort512VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -4994,7 +4994,7 @@ static void blendShort512VectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Short512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Short512VectorTests::blend); } @@ -5011,7 +5011,7 @@ static void SelectFromShort512VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") @@ -5030,7 +5030,7 @@ static void SelectFromShort512VectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5107,7 +5107,7 @@ static void maskEqShort512VectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Short512VectorTests::beq); + assertArraysEquals(r, a, b, Short512VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java index 81e3412bd2e..c42913ae311 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng Short64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation Short64VectorLoadStoreTests * */ @@ -58,47 +58,25 @@ public class Short64VectorLoadStoreTests extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8)); - static void assertArraysEquals(short[] a, short[] r, boolean[] mask) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(short[] a, short[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -401,7 +379,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "shortProviderForIOOBE") @@ -472,7 +450,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new short[a.length]; @@ -483,7 +461,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortMaskProviderForIOOBE") @@ -556,7 +534,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -580,7 +558,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -667,7 +645,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -682,7 +660,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -798,7 +776,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -879,7 +857,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -890,7 +868,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -967,7 +945,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -978,7 +956,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index c24cd7b583a..adc10b3b4b9 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch Short64VectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -68,7 +68,7 @@ interface FUnOp { short apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -83,7 +83,7 @@ interface FUnArrayOp { short[] apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -93,13 +93,13 @@ static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -118,17 +118,17 @@ interface FReductionAllOp { short apply(short[] a); } - static void assertReductionArraysEquals(short[] a, short[] b, short c, + static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -140,17 +140,17 @@ interface FReductionAllMaskedOp { short apply(short[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(short[] a, short[] b, short c, boolean[] mask, + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -162,17 +162,17 @@ interface FReductionAllOpLong { long apply(short[] a); } - static void assertReductionLongArraysEquals(short[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -184,17 +184,17 @@ interface FReductionAllMaskedOpLong { long apply(short[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(short[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -202,37 +202,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(short[] a, short[] b, short element, int index) { + static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -246,7 +246,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -260,7 +260,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, in } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -280,7 +280,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -300,7 +300,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, bo } } - static void assertBroadcastArraysEquals(short[]a, short[]r) { + static void assertBroadcastArraysEquals(short[] r, short[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -329,7 +329,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -340,7 +340,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -352,7 +352,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -364,11 +364,11 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBi } } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -379,11 +379,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -397,11 +397,11 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -415,7 +415,7 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boo } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -429,11 +429,11 @@ static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -459,7 +459,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -470,11 +470,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTern } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -486,7 +486,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boole } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -499,7 +499,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -512,12 +512,12 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -533,12 +533,12 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -554,7 +554,7 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -569,12 +569,12 @@ static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, s } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -597,7 +597,7 @@ interface FBinArrayOp { short apply(short[] a, int b); } - static void assertArraysEquals(short[] a, short[] r, FBinArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -612,7 +612,7 @@ interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, FGatherScatterOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -639,7 +639,7 @@ interface FScatterMaskedOp { short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -649,7 +649,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -660,7 +660,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -670,7 +670,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FS } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -687,7 +687,7 @@ interface FLaneOp { short[] apply(short[] a, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -697,7 +697,7 @@ static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -707,7 +707,7 @@ interface FLaneBop { short[] apply(short[] a, short[] b, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLaneBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -717,7 +717,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLan } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -728,7 +728,7 @@ interface FLaneMaskedBop { short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -738,7 +738,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, bool } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -749,7 +749,7 @@ interface FLanePartBop { short[] apply(short[] a, short[] b, int origin, int part, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -759,7 +759,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -771,7 +771,7 @@ interface FLanePartMaskedBop { short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -781,7 +781,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -790,7 +790,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } - static void assertArraysEquals(short[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -803,7 +803,7 @@ static void assertArraysEquals(short[] a, int[] r, int offs) { - static void assertArraysEquals(short[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -814,7 +814,7 @@ static void assertArraysEquals(short[] a, long[] r, int offs) { } } - static void assertArraysEquals(short[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1278,7 +1278,7 @@ static void ADDShort64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::ADD); + assertArraysEquals(r, a, b, Short64VectorTests::ADD); } static short add(short a, short b) { return (short)(a + b); @@ -1296,7 +1296,7 @@ static void addShort64VectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::add); + assertArraysEquals(r, a, b, Short64VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1316,7 +1316,7 @@ static void ADDShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::SUB); + assertArraysEquals(r, a, b, Short64VectorTests::SUB); } static short sub(short a, short b) { return (short)(a - b); @@ -1372,7 +1372,7 @@ static void subShort64VectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::sub); + assertArraysEquals(r, a, b, Short64VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1392,7 +1392,7 @@ static void SUBShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::MUL); + assertArraysEquals(r, a, b, Short64VectorTests::MUL); } static short mul(short a, short b) { return (short)(a * b); @@ -1448,7 +1448,7 @@ static void mulShort64VectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::mul); + assertArraysEquals(r, a, b, Short64VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1468,7 +1468,7 @@ static void MULShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::DIV); + assertArraysEquals(r, a, b, Short64VectorTests::DIV); } static short div(short a, short b) { return (short)(a / b); @@ -1533,7 +1533,7 @@ static void divShort64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::div); + assertArraysEquals(r, a, b, Short64VectorTests::div); } @@ -1557,7 +1557,7 @@ static void DIVShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, Short64VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1620,7 +1620,7 @@ static void FIRST_NONZEROShort64VectorTestsMasked(IntFunction fa, IntFu } } - assertArraysEquals(a, b, r, mask, Short64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, Short64VectorTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -1641,7 +1641,7 @@ static void ANDShort64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::AND); + assertArraysEquals(r, a, b, Short64VectorTests::AND); } static short and(short a, short b) { return (short)(a & b); @@ -1659,7 +1659,7 @@ static void andShort64VectorTests(IntFunction fa, IntFunction av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::and); + assertArraysEquals(r, a, b, Short64VectorTests::and); } @@ -1681,7 +1681,7 @@ static void ANDShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Short64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, Short64VectorTests::AND_NOT); } @@ -1747,7 +1747,7 @@ static void ORShort64VectorTests(IntFunction fa, IntFunction f } } - assertArraysEquals(a, b, r, Short64VectorTests::OR); + assertArraysEquals(r, a, b, Short64VectorTests::OR); } static short or(short a, short b) { return (short)(a | b); @@ -1765,7 +1765,7 @@ static void orShort64VectorTests(IntFunction fa, IntFunction f av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::or); + assertArraysEquals(r, a, b, Short64VectorTests::or); } @@ -1787,7 +1787,7 @@ static void ORShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::XOR); + assertArraysEquals(r, a, b, Short64VectorTests::XOR); } @@ -1831,7 +1831,7 @@ static void XORShort64VectorTestsMasked(IntFunction fa, IntFunction fa, Int av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1863,7 +1863,7 @@ static void addShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::add); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1877,7 +1877,7 @@ static void subShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1894,7 +1894,7 @@ static void subShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1908,7 +1908,7 @@ static void mulShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1925,7 +1925,7 @@ static void mulShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::mul); } @@ -1944,7 +1944,7 @@ static void divShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::div); } @@ -1965,7 +1965,7 @@ static void divShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::div); } @@ -1981,7 +1981,7 @@ static void ORShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1995,7 +1995,7 @@ static void orShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntF av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::or); } @@ -2014,7 +2014,7 @@ static void ORShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::OR); } @@ -2030,7 +2030,7 @@ static void ANDShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2044,7 +2044,7 @@ static void andShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::and); } @@ -2063,7 +2063,7 @@ static void ANDShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::AND); } @@ -2079,7 +2079,7 @@ static void ORShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::OR); } @@ -2098,7 +2098,7 @@ static void ORShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, Short64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -2130,7 +2130,7 @@ static void ADDShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::LSHL); + assertArraysEquals(r, a, b, Short64VectorTests::LSHL); } @@ -2177,7 +2177,7 @@ static void LSHLShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::ASHR); + assertArraysEquals(r, a, b, Short64VectorTests::ASHR); } @@ -2225,7 +2225,7 @@ static void ASHRShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::LSHR); + assertArraysEquals(r, a, b, Short64VectorTests::LSHR); } @@ -2273,7 +2273,7 @@ static void LSHRShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::MIN); + assertArraysEquals(r, a, b, Short64VectorTests::MIN); } static short min(short a, short b) { return (short)(Math.min(a, b)); @@ -2450,7 +2450,7 @@ static void minShort64VectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::min); + assertArraysEquals(r, a, b, Short64VectorTests::min); } static short MAX(short a, short b) { return (short)(Math.max(a, b)); @@ -2470,7 +2470,7 @@ static void MAXShort64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, Short64VectorTests::MAX); + assertArraysEquals(r, a, b, Short64VectorTests::MAX); } static short max(short a, short b) { return (short)(Math.max(a, b)); @@ -2488,7 +2488,7 @@ static void maxShort64VectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::max); + assertArraysEquals(r, a, b, Short64VectorTests::max); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2502,7 +2502,7 @@ static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2516,7 +2516,7 @@ static void minShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::min); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2530,7 +2530,7 @@ static void MAXShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2544,7 +2544,7 @@ static void maxShort64VectorTestsBroadcastSmokeTest(IntFunction fa, Int av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, Short64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, Short64VectorTests::max); } static short ANDReduce(short[] a, int idx) { @@ -2587,7 +2587,7 @@ static void ANDReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::ANDReduce, Short64VectorTests::ANDReduceAll); } @@ -2635,7 +2635,7 @@ static void ANDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::ANDReduceMasked, Short64VectorTests::ANDReduceAllMasked); } @@ -2680,7 +2680,7 @@ static void ORReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::ORReduce, Short64VectorTests::ORReduceAll); } @@ -2728,7 +2728,7 @@ static void ORReduceShort64VectorTestsMasked(IntFunction fa, IntFunctio } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::ORReduceMasked, Short64VectorTests::ORReduceAllMasked); } @@ -2773,7 +2773,7 @@ static void XORReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::XORReduce, Short64VectorTests::XORReduceAll); } @@ -2821,7 +2821,7 @@ static void XORReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::XORReduceMasked, Short64VectorTests::XORReduceAllMasked); } @@ -2863,7 +2863,7 @@ static void ADDReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::ADDReduce, Short64VectorTests::ADDReduceAll); } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2907,7 +2907,7 @@ static void ADDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::ADDReduceMasked, Short64VectorTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { @@ -2948,7 +2948,7 @@ static void MULReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::MULReduce, Short64VectorTests::MULReduceAll); } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2992,7 +2992,7 @@ static void MULReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::MULReduceMasked, Short64VectorTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { @@ -3033,7 +3033,7 @@ static void MINReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::MINReduce, Short64VectorTests::MINReduceAll); } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3078,7 +3078,7 @@ static void MINReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::MINReduceMasked, Short64VectorTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { @@ -3119,7 +3119,7 @@ static void MAXReduceShort64VectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, Short64VectorTests::MAXReduce, Short64VectorTests::MAXReduceAll); } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3164,7 +3164,7 @@ static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::MAXReduceMasked, Short64VectorTests::MAXReduceAllMasked); } @@ -3190,7 +3190,7 @@ static void anyTrueShort64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, Short64VectorTests::anyTrue); } @@ -3216,7 +3216,7 @@ static void allTrueShort64VectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, Short64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, Short64VectorTests::allTrue); } @@ -3232,7 +3232,7 @@ static void withShort64VectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (short)4, 0); + assertInsertArraysEquals(r, a, (short)4, 0); } static boolean testIS_DEFAULT(short a) { return bits(a)==0; @@ -3781,7 +3781,7 @@ static void blendShort64VectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") @@ -3816,7 +3816,7 @@ static void RearrangeShort64VectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpProvider") static void getShort64VectorTests(IntFunction fa) { @@ -3971,7 +3971,7 @@ static void getShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::get); + assertArraysEquals(r, a, Short64VectorTests::get); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3985,7 +3985,7 @@ static void BroadcastShort64VectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4032,7 +4032,7 @@ static void sliceUnaryShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, Short64VectorTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4061,7 +4061,7 @@ static void sliceBinaryShort64VectorTestsBinary(IntFunction fa, IntFunc } } - assertArraysEquals(a, b, r, origin, Short64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, Short64VectorTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4094,7 +4094,7 @@ static void sliceShort64VectorTestsMasked(IntFunction fa, IntFunction fa) { } } - assertArraysEquals(a, r, origin, Short64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, Short64VectorTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { short[] res = new short[SPECIES.length()]; @@ -4160,7 +4160,7 @@ static void unsliceBinaryShort64VectorTestsBinary(IntFunction fa, IntFu } } - assertArraysEquals(a, b, r, origin, part, Short64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, Short64VectorTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4216,7 +4216,7 @@ static void unsliceShort64VectorTestsMasked(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, origin, part, mask, Short64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, Short64VectorTests::unslice); } @@ -4265,7 +4265,7 @@ static void BITWISE_BLENDShort64VectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, c, r, Short64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") static void bitwiseBlendShort64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4281,7 +4281,7 @@ static void bitwiseBlendShort64VectorTests(IntFunction fa, IntFunction< av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, Short64VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend); } @@ -4304,7 +4304,7 @@ static void BITWISE_BLENDShort64VectorTestsMasked(IntFunction fa, IntFu } } - assertArraysEquals(a, b, c, r, mask, Short64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND); } @@ -4322,7 +4322,7 @@ static void BITWISE_BLENDShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4351,7 +4351,7 @@ static void bitwiseBlendShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4437,7 +4437,7 @@ static void bitwiseBlendShort64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::NEG); + assertArraysEquals(r, a, Short64VectorTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4495,7 +4495,7 @@ static void negShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::neg); + assertArraysEquals(r, a, Short64VectorTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4513,7 +4513,7 @@ static void NEGMaskedShort64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short64VectorTests::NEG); + assertArraysEquals(r, a, mask, Short64VectorTests::NEG); } static short ABS(short a) { @@ -4536,7 +4536,7 @@ static void ABSShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::ABS); + assertArraysEquals(r, a, Short64VectorTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4551,7 +4551,7 @@ static void absShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::abs); + assertArraysEquals(r, a, Short64VectorTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4569,7 +4569,7 @@ static void ABSMaskedShort64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short64VectorTests::ABS); + assertArraysEquals(r, a, mask, Short64VectorTests::ABS); } @@ -4595,7 +4595,7 @@ static void NOTShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::NOT); + assertArraysEquals(r, a, Short64VectorTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4610,7 +4610,7 @@ static void notShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::not); + assertArraysEquals(r, a, Short64VectorTests::not); } @@ -4630,7 +4630,7 @@ static void NOTMaskedShort64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short64VectorTests::NOT); + assertArraysEquals(r, a, mask, Short64VectorTests::NOT); } @@ -4653,7 +4653,7 @@ static void ZOMOShort64VectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, Short64VectorTests::ZOMO); + assertArraysEquals(r, a, Short64VectorTests::ZOMO); } @@ -4673,7 +4673,7 @@ static void ZOMOMaskedShort64VectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, Short64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, Short64VectorTests::ZOMO); } @@ -4701,7 +4701,7 @@ static void gatherShort64VectorTests(IntFunction fa, BiFunction fa, BiFunction fa, BiFunction fa, IntFunction } } - assertArraysEquals(a, b, r, mask, Short64VectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, Short64VectorTests::scatterMasked); } @@ -4834,8 +4834,8 @@ static void toIntArrayShort64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4845,8 +4845,8 @@ static void toLongArrayShort64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4856,8 +4856,8 @@ static void toDoubleArrayShort64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4923,7 +4923,7 @@ static void ADDReduceLongShort64VectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, Short64VectorTests::ADDReduceLong, Short64VectorTests::ADDReduceAllLong); } @@ -4964,7 +4964,7 @@ static void ADDReduceLongShort64VectorTestsMasked(IntFunction fa, IntFu ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, Short64VectorTests::ADDReduceLongMasked, Short64VectorTests::ADDReduceAllLongMasked); } @@ -4976,7 +4976,7 @@ static void BroadcastLongShort64VectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -4994,7 +4994,7 @@ static void blendShort64VectorTestsBroadcastLongSmokeTest(IntFunction f av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, Short64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::blend); } @@ -5011,7 +5011,7 @@ static void SelectFromShort64VectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") @@ -5030,7 +5030,7 @@ static void SelectFromShort64VectorTestsMaskedSmokeTest(IntFunction fa, bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5107,7 +5107,7 @@ static void maskEqShort64VectorTestsSmokeTest(IntFunction fa, IntFunc var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, Short64VectorTests::beq); + assertArraysEquals(r, a, b, Short64VectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java index 45cd6dedb0a..98429a4f088 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * ShortMaxVectorLoadStoreTests + * -XX:-TieredCompilation ShortMaxVectorLoadStoreTests * */ @@ -67,47 +67,25 @@ static VectorShape getMaxBit() { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8)); - static void assertArraysEquals(short[] a, short[] r, boolean[] mask) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : (short) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, int[] im) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals(short[] a, short[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : (short) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } @@ -410,7 +388,7 @@ static void loadStoreArray(IntFunction fa) { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "shortProviderForIOOBE") @@ -481,7 +459,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new short[a.length]; @@ -492,7 +470,7 @@ static void loadStoreMaskArray(IntFunction fa, av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortMaskProviderForIOOBE") @@ -565,7 +543,7 @@ static void loadStoreMask(IntFunction fa, vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -589,7 +567,7 @@ static void loadStoreByteBuffer(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -676,7 +654,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -691,7 +669,7 @@ static void loadStoreByteBufferMask(IntFunction fa, Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -807,7 +785,7 @@ static void loadStoreByteArray(IntFunction fa, av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "shortByteProviderForIOOBE") @@ -888,7 +866,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -899,7 +877,7 @@ static void loadStoreByteArrayMask(IntFunction fa, av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "shortByteMaskProviderForIOOBE") @@ -976,7 +954,7 @@ static void loadStoreMask(IntFunction fm) { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -987,7 +965,7 @@ static void loadStoreShuffle() { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index b056149e5b3..7e4d7e3fa09 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch ShortMaxVectorTests + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -73,7 +73,7 @@ interface FUnOp { short apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -88,7 +88,7 @@ interface FUnArrayOp { short[] apply(short a); } - static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -98,13 +98,13 @@ static void assertArraysEquals(short[] a, short[] r, FUnArrayOp f) { } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals(short[] a, short[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -123,17 +123,17 @@ interface FReductionAllOp { short apply(short[] a); } - static void assertReductionArraysEquals(short[] a, short[] b, short c, + static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -145,17 +145,17 @@ interface FReductionAllMaskedOp { short apply(short[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked(short[] a, short[] b, short c, boolean[] mask, + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -167,17 +167,17 @@ interface FReductionAllOpLong { long apply(short[] a); } - static void assertReductionLongArraysEquals(short[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -189,17 +189,17 @@ interface FReductionAllMaskedOpLong { long apply(short[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked(short[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -207,37 +207,37 @@ interface FBoolReductionOp { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals(short[] a, short[] b, short element, int index) { + static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -251,7 +251,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, int v } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -265,7 +265,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, in } } - static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -285,7 +285,7 @@ static void assertRearrangeArraysEquals(short[] a, short[] r, int[] order, boole } } - static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -305,7 +305,7 @@ static void assertSelectFromArraysEquals(short[] a, short[] r, short[] order, bo } } - static void assertBroadcastArraysEquals(short[]a, short[]r) { + static void assertBroadcastArraysEquals(short[] r, short[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -334,7 +334,7 @@ static FBinMaskOp lift(FBinOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -345,7 +345,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -357,7 +357,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -369,11 +369,11 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, FBi } } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -384,11 +384,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -402,11 +402,11 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean } } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -420,7 +420,7 @@ static void assertBroadcastLongArraysEquals(short[] a, short[] b, short[] r, boo } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -434,11 +434,11 @@ static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) { } } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -464,7 +464,7 @@ static FTernMaskOp lift(FTernOp f) { } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -475,11 +475,11 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, FTern } } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -491,7 +491,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] c, short[] r, boole } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -504,7 +504,7 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,12 +517,12 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -538,12 +538,12 @@ static void assertBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] } } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -559,7 +559,7 @@ static void assertAltBroadcastArraysEquals(short[] a, short[] b, short[] c, shor } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -574,12 +574,12 @@ static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, s } } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals(short[] a, short[] b, short[] c, short[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -602,7 +602,7 @@ interface FBinArrayOp { short apply(short[] a, int b); } - static void assertArraysEquals(short[] a, short[] r, FBinArrayOp f) { + static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -617,7 +617,7 @@ interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, FGatherScatterOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -644,7 +644,7 @@ interface FScatterMaskedOp { short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -654,7 +654,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -665,7 +665,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FG } } - static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -675,7 +675,7 @@ static void assertArraysEquals(short[] a, int[] b, short[] r, boolean[] mask, FS } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -692,7 +692,7 @@ interface FLaneOp { short[] apply(short[] a, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -702,7 +702,7 @@ static void assertArraysEquals(short[] a, short[] r, int origin, FLaneOp f) { } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -712,7 +712,7 @@ interface FLaneBop { short[] apply(short[] a, short[] b, int origin, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLaneBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -722,7 +722,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, FLan } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -733,7 +733,7 @@ interface FLaneMaskedBop { short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -743,7 +743,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, bool } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -754,7 +754,7 @@ interface FLanePartBop { short[] apply(short[] a, short[] b, int origin, int part, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -764,7 +764,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -776,7 +776,7 @@ interface FLanePartMaskedBop { short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -786,7 +786,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -795,7 +795,7 @@ static void assertArraysEquals(short[] a, short[] b, short[] r, int origin, int } - static void assertArraysEquals(short[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -808,7 +808,7 @@ static void assertArraysEquals(short[] a, int[] r, int offs) { - static void assertArraysEquals(short[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -819,7 +819,7 @@ static void assertArraysEquals(short[] a, long[] r, int offs) { } } - static void assertArraysEquals(short[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1283,7 +1283,7 @@ static void ADDShortMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::ADD); + assertArraysEquals(r, a, b, ShortMaxVectorTests::ADD); } static short add(short a, short b) { return (short)(a + b); @@ -1301,7 +1301,7 @@ static void addShortMaxVectorTests(IntFunction fa, IntFunction av.add(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::add); + assertArraysEquals(r, a, b, ShortMaxVectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1321,7 +1321,7 @@ static void ADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::SUB); + assertArraysEquals(r, a, b, ShortMaxVectorTests::SUB); } static short sub(short a, short b) { return (short)(a - b); @@ -1377,7 +1377,7 @@ static void subShortMaxVectorTests(IntFunction fa, IntFunction av.sub(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::sub); + assertArraysEquals(r, a, b, ShortMaxVectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1397,7 +1397,7 @@ static void SUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::MUL); + assertArraysEquals(r, a, b, ShortMaxVectorTests::MUL); } static short mul(short a, short b) { return (short)(a * b); @@ -1453,7 +1453,7 @@ static void mulShortMaxVectorTests(IntFunction fa, IntFunction av.mul(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::mul); + assertArraysEquals(r, a, b, ShortMaxVectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1473,7 +1473,7 @@ static void MULShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::DIV); + assertArraysEquals(r, a, b, ShortMaxVectorTests::DIV); } static short div(short a, short b) { return (short)(a / b); @@ -1538,7 +1538,7 @@ static void divShortMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::div); + assertArraysEquals(r, a, b, ShortMaxVectorTests::div); } @@ -1562,7 +1562,7 @@ static void DIVShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1625,7 +1625,7 @@ static void FIRST_NONZEROShortMaxVectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, mask, ShortMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -1646,7 +1646,7 @@ static void ANDShortMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::AND); + assertArraysEquals(r, a, b, ShortMaxVectorTests::AND); } static short and(short a, short b) { return (short)(a & b); @@ -1664,7 +1664,7 @@ static void andShortMaxVectorTests(IntFunction fa, IntFunction av.and(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::and); + assertArraysEquals(r, a, b, ShortMaxVectorTests::and); } @@ -1686,7 +1686,7 @@ static void ANDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, ShortMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND_NOT); } @@ -1752,7 +1752,7 @@ static void ORShortMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::OR); + assertArraysEquals(r, a, b, ShortMaxVectorTests::OR); } static short or(short a, short b) { return (short)(a | b); @@ -1770,7 +1770,7 @@ static void orShortMaxVectorTests(IntFunction fa, IntFunction av.or(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::or); + assertArraysEquals(r, a, b, ShortMaxVectorTests::or); } @@ -1792,7 +1792,7 @@ static void ORShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::XOR); + assertArraysEquals(r, a, b, ShortMaxVectorTests::XOR); } @@ -1836,7 +1836,7 @@ static void XORShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, In av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1868,7 +1868,7 @@ static void addShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::add); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1882,7 +1882,7 @@ static void subShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1899,7 +1899,7 @@ static void subShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1913,7 +1913,7 @@ static void mulShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -1930,7 +1930,7 @@ static void mulShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul); } @@ -1949,7 +1949,7 @@ static void divShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::div); } @@ -1970,7 +1970,7 @@ static void divShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::div); } @@ -1986,7 +1986,7 @@ static void ORShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, Int av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2000,7 +2000,7 @@ static void orShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, Int av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::or); } @@ -2019,7 +2019,7 @@ static void ORShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); } @@ -2035,7 +2035,7 @@ static void ANDShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2049,7 +2049,7 @@ static void andShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::and); } @@ -2068,7 +2068,7 @@ static void ANDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND); } @@ -2084,7 +2084,7 @@ static void ORShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, ShortMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::OR); } @@ -2103,7 +2103,7 @@ static void ORShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(a, b, r, ShortMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -2135,7 +2135,7 @@ static void ADDShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::MIN); + assertArraysEquals(r, a, b, ShortMaxVectorTests::MIN); } static short min(short a, short b) { return (short)(Math.min(a, b)); @@ -2455,7 +2455,7 @@ static void minShortMaxVectorTests(IntFunction fa, IntFunction av.min(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::min); + assertArraysEquals(r, a, b, ShortMaxVectorTests::min); } static short MAX(short a, short b) { return (short)(Math.max(a, b)); @@ -2475,7 +2475,7 @@ static void MAXShortMaxVectorTests(IntFunction fa, IntFunction } } - assertArraysEquals(a, b, r, ShortMaxVectorTests::MAX); + assertArraysEquals(r, a, b, ShortMaxVectorTests::MAX); } static short max(short a, short b) { return (short)(Math.max(a, b)); @@ -2493,7 +2493,7 @@ static void maxShortMaxVectorTests(IntFunction fa, IntFunction av.max(bv).intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::max); + assertArraysEquals(r, a, b, ShortMaxVectorTests::max); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2507,7 +2507,7 @@ static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2521,7 +2521,7 @@ static void minShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::min); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2535,7 +2535,7 @@ static void MAXShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") @@ -2549,7 +2549,7 @@ static void maxShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::max); } static short ANDReduce(short[] a, int idx) { @@ -2592,7 +2592,7 @@ static void ANDReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::ANDReduce, ShortMaxVectorTests::ANDReduceAll); } @@ -2640,7 +2640,7 @@ static void ANDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::ANDReduceMasked, ShortMaxVectorTests::ANDReduceAllMasked); } @@ -2685,7 +2685,7 @@ static void ORReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::ORReduce, ShortMaxVectorTests::ORReduceAll); } @@ -2733,7 +2733,7 @@ static void ORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFuncti } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::ORReduceMasked, ShortMaxVectorTests::ORReduceAllMasked); } @@ -2778,7 +2778,7 @@ static void XORReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::XORReduce, ShortMaxVectorTests::XORReduceAll); } @@ -2826,7 +2826,7 @@ static void XORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::XORReduceMasked, ShortMaxVectorTests::XORReduceAllMasked); } @@ -2868,7 +2868,7 @@ static void ADDReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::ADDReduce, ShortMaxVectorTests::ADDReduceAll); } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2912,7 +2912,7 @@ static void ADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::ADDReduceMasked, ShortMaxVectorTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { @@ -2953,7 +2953,7 @@ static void MULReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::MULReduce, ShortMaxVectorTests::MULReduceAll); } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { @@ -2997,7 +2997,7 @@ static void MULReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::MULReduceMasked, ShortMaxVectorTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { @@ -3038,7 +3038,7 @@ static void MINReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::MINReduce, ShortMaxVectorTests::MINReduceAll); } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3083,7 +3083,7 @@ static void MINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::MINReduceMasked, ShortMaxVectorTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { @@ -3124,7 +3124,7 @@ static void MAXReduceShortMaxVectorTests(IntFunction fa) { } } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, ShortMaxVectorTests::MAXReduce, ShortMaxVectorTests::MAXReduceAll); } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { @@ -3169,7 +3169,7 @@ static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked); } @@ -3195,7 +3195,7 @@ static void anyTrueShortMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, ShortMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::anyTrue); } @@ -3221,7 +3221,7 @@ static void allTrueShortMaxVectorTests(IntFunction fm) { } } - assertReductionBoolArraysEquals(mask, r, ShortMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue); } @@ -3237,7 +3237,7 @@ static void withShortMaxVectorTests(IntFunction fa) { } } - assertInsertArraysEquals(a, r, (short)4, 0); + assertInsertArraysEquals(r, a, (short)4, 0); } static boolean testIS_DEFAULT(short a) { return bits(a)==0; @@ -3786,7 +3786,7 @@ static void blendShortMaxVectorTests(IntFunction fa, IntFunction fa, } } - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") @@ -3821,7 +3821,7 @@ static void RearrangeShortMaxVectorTestsMaskedSmokeTest(IntFunction fa, av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpProvider") static void getShortMaxVectorTests(IntFunction fa) { @@ -3976,7 +3976,7 @@ static void getShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::get); + assertArraysEquals(r, a, ShortMaxVectorTests::get); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3990,7 +3990,7 @@ static void BroadcastShortMaxVectorTests(IntFunction fa) { } } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @@ -4037,7 +4037,7 @@ static void sliceUnaryShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, ShortMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortMaxVectorTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4066,7 +4066,7 @@ static void sliceBinaryShortMaxVectorTestsBinary(IntFunction fa, IntFun } } - assertArraysEquals(a, b, r, origin, ShortMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortMaxVectorTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4099,7 +4099,7 @@ static void sliceShortMaxVectorTestsMasked(IntFunction fa, IntFunction< } } - assertArraysEquals(a, b, r, origin, mask, ShortMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortMaxVectorTests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { short[] res = new short[SPECIES.length()]; @@ -4126,7 +4126,7 @@ static void unsliceUnaryShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, origin, ShortMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortMaxVectorTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { short[] res = new short[SPECIES.length()]; @@ -4165,7 +4165,7 @@ static void unsliceBinaryShortMaxVectorTestsBinary(IntFunction fa, IntF } } - assertArraysEquals(a, b, r, origin, part, ShortMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortMaxVectorTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { short[] res = new short[SPECIES.length()]; @@ -4221,7 +4221,7 @@ static void unsliceShortMaxVectorTestsMasked(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, origin, part, mask, ShortMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortMaxVectorTests::unslice); } @@ -4270,7 +4270,7 @@ static void BITWISE_BLENDShortMaxVectorTests(IntFunction fa, IntFunctio } } - assertArraysEquals(a, b, c, r, ShortMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") static void bitwiseBlendShortMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4286,7 +4286,7 @@ static void bitwiseBlendShortMaxVectorTests(IntFunction fa, IntFunction av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(a, b, c, r, ShortMaxVectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); } @@ -4309,7 +4309,7 @@ static void BITWISE_BLENDShortMaxVectorTestsMasked(IntFunction fa, IntF } } - assertArraysEquals(a, b, c, r, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); } @@ -4327,7 +4327,7 @@ static void BITWISE_BLENDShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4356,7 +4356,7 @@ static void bitwiseBlendShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { @@ -4442,7 +4442,7 @@ static void bitwiseBlendShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction< av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, ShortMaxVectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); } @@ -4461,7 +4461,7 @@ static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFu av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); } @@ -4485,7 +4485,7 @@ static void NEGShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::NEG); + assertArraysEquals(r, a, ShortMaxVectorTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4500,7 +4500,7 @@ static void negShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::neg); + assertArraysEquals(r, a, ShortMaxVectorTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4518,7 +4518,7 @@ static void NEGMaskedShortMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ShortMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, ShortMaxVectorTests::NEG); } static short ABS(short a) { @@ -4541,7 +4541,7 @@ static void ABSShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::ABS); + assertArraysEquals(r, a, ShortMaxVectorTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4556,7 +4556,7 @@ static void absShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::abs); + assertArraysEquals(r, a, ShortMaxVectorTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") @@ -4574,7 +4574,7 @@ static void ABSMaskedShortMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ShortMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, ShortMaxVectorTests::ABS); } @@ -4600,7 +4600,7 @@ static void NOTShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::NOT); + assertArraysEquals(r, a, ShortMaxVectorTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4615,7 +4615,7 @@ static void notShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::not); + assertArraysEquals(r, a, ShortMaxVectorTests::not); } @@ -4635,7 +4635,7 @@ static void NOTMaskedShortMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ShortMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, ShortMaxVectorTests::NOT); } @@ -4658,7 +4658,7 @@ static void ZOMOShortMaxVectorTests(IntFunction fa) { } } - assertArraysEquals(a, r, ShortMaxVectorTests::ZOMO); + assertArraysEquals(r, a, ShortMaxVectorTests::ZOMO); } @@ -4678,7 +4678,7 @@ static void ZOMOMaskedShortMaxVectorTests(IntFunction fa, } } - assertArraysEquals(a, r, mask, ShortMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortMaxVectorTests::ZOMO); } @@ -4706,7 +4706,7 @@ static void gatherShortMaxVectorTests(IntFunction fa, BiFunction fa, BiFunction< } } - assertArraysEquals(a, b, r, mask, ShortMaxVectorTests::gatherMasked); + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::gatherMasked); } static short[] scatter(short a[], int ix, int[] b, int iy) { @@ -4759,7 +4759,7 @@ static void scatterShortMaxVectorTests(IntFunction fa, BiFunction fa, IntFunctio } } - assertArraysEquals(a, b, r, mask, ShortMaxVectorTests::scatterMasked); + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::scatterMasked); } @@ -4839,8 +4839,8 @@ static void toIntArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -4850,8 +4850,8 @@ static void toLongArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -4861,8 +4861,8 @@ static void toDoubleArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } @@ -4928,7 +4928,7 @@ static void ADDReduceLongShortMaxVectorTests(IntFunction fa) { ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, ShortMaxVectorTests::ADDReduceLong, ShortMaxVectorTests::ADDReduceAllLong); } @@ -4969,7 +4969,7 @@ static void ADDReduceLongShortMaxVectorTestsMasked(IntFunction fa, IntF ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, ShortMaxVectorTests::ADDReduceLongMasked, ShortMaxVectorTests::ADDReduceAllLongMasked); } @@ -4981,7 +4981,7 @@ static void BroadcastLongShortMaxVectorTestsSmokeTest(IntFunction fa) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "shortBinaryOpMaskProvider") @@ -4999,7 +4999,7 @@ static void blendShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, ShortMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend); } @@ -5016,7 +5016,7 @@ static void SelectFromShortMaxVectorTests(IntFunction fa, bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") @@ -5035,7 +5035,7 @@ static void SelectFromShortMaxVectorTestsMaskedSmokeTest(IntFunction fa bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -5112,7 +5112,7 @@ static void maskEqShortMaxVectorTestsSmokeTest(IntFunction fa, IntFun var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, ShortMaxVectorTests::beq); + assertArraysEquals(r, a, b, ShortMaxVectorTests::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java index 24b67ed245b..b59e5ff7841 100644 --- a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java @@ -31,20 +31,30 @@ /** * @test + * @requires (os.arch != "ppc64") & (os.arch != "ppc64le") * @modules jdk.incubator.vector * @modules java.base/jdk.internal.vm.annotation * @run testng/othervm -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED * Vector64ConversionTests */ +/** + * @test VectorConversionHighTimeout + * @requires os.arch == "ppc64" | os.arch == "ppc64le" + * @modules jdk.incubator.vector + * @modules java.base/jdk.internal.vm.annotation + * @run testng/othervm/timeout=1800 -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED + * Vector64ConversionTests + */ + /* * @test VectorConversionPPC64 * @bug 8256479 - * @requires os.arch =="ppc64" | os.arch == "ppc64le" + * @requires os.arch == "ppc64" | os.arch == "ppc64le" * @summary VectorConversion on PPC64 without Vector Register usage * @modules jdk.incubator.vector * @modules java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-SuperwordUseVSX -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED + * @run testng/othervm/timeout=1800 -XX:-SuperwordUseVSX -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED * Vector64ConversionTests */ diff --git a/test/jdk/jdk/incubator/vector/VectorReshapeTests.java b/test/jdk/jdk/incubator/vector/VectorReshapeTests.java index 83e86ea3736..01dcc4caf85 100644 --- a/test/jdk/jdk/incubator/vector/VectorReshapeTests.java +++ b/test/jdk/jdk/incubator/vector/VectorReshapeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ * @modules jdk.incubator.vector * @modules java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * VectorReshapeTests + * -XX:-TieredCompilation VectorReshapeTests */ @Test @@ -416,7 +416,7 @@ else if (partLimit >= 0) ", origin=" + origin); System.out.println("expect: "+Arrays.toString(expected)); System.out.println("output: "+Arrays.toString(output)); - Assert.assertEquals(expected, output); + Assert.assertEquals(output, expected); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Long-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Long-op.template index 42626dee596..364742220cc 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Long-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Long-op.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$BroadcastLongSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertBroadcastLongArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + assertBroadcastLongArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-Long-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-Long-op.template index b80ec25be8c..4e207dafc64 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-Long-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-Long-op.template @@ -3,5 +3,5 @@ static void [[TEST]]$vectorteststype$BroadcastMaskedLongSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertBroadcastLongArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]]); + assertBroadcastLongArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-op.template index 0c79d51ba32..887e2e56982 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-op.template @@ -3,5 +3,5 @@ static void [[TEST]]$vectorteststype$BroadcastMaskedSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertBroadcastArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]]); + assertBroadcastArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op-math.template index 5abbf1feac3..7964661ece7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op-math.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$BroadcastSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertBroadcastArraysEqualsWithinOneUlp(a, b, r, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op.template index 64c74455b94..737d282a62a 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$BroadcastSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertBroadcastArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + assertBroadcastArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-op.template index fe3af3e1fd1..df0a1d55131 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-op.template @@ -3,5 +3,5 @@ static void [[TEST]]$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template index 82c141fc32a..6d845a652e9 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template @@ -9,6 +9,6 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertArraysEqualsWithinOneUlp(a, b, r, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); + assertArraysEqualsWithinOneUlp(r, a, b, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op.template index 9fff3c0751c..aa7dc156cfe 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op.template @@ -5,5 +5,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Blend-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Blend-op.template index c048c9c5643..519ea524ff8 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Blend-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Blend-op.template @@ -7,5 +7,5 @@ static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, mask, $vectorteststype$::blend); + assertArraysEquals(r, a, b, mask, $vectorteststype$::blend); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-BoolReduction-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-BoolReduction-op.template index 2c92614fd4b..b3127c1383c 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-BoolReduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-BoolReduction-op.template @@ -1,5 +1,5 @@ @Test(dataProvider = "boolUnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction fm) { [[KERNEL]] - assertReductionBoolArraysEquals(mask, r, $vectorteststype$::[[TEST]]); + assertReductionBoolArraysEquals(r, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Broadcast.template b/test/jdk/jdk/incubator/vector/templates/Unit-Broadcast.template index 5c3d22ab2b4..a5748c3f8ae 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Broadcast.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Broadcast.template @@ -2,7 +2,7 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void Broadcast$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Gather-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Gather-Masked-op.template index 9f25e4edd99..1f106214601 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Gather-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Gather-Masked-op.template @@ -12,6 +12,6 @@ @Test(dataProvider = "$type$UnaryMaskedOpIndexProvider") static void [[TEST]][[TEST_TYPE]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction fs, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]); + assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Gather-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Gather-op.template index a44602eb9b6..b16472f8a1c 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Gather-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Gather-op.template @@ -10,5 +10,5 @@ @Test(dataProvider = "$type$UnaryOpIndexProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction fs) { [[KERNEL]] - assertArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template index 00f1a8300c0..9feb403171c 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template @@ -1,5 +1,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void get$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(a, r, $vectorteststype$::get); + assertArraysEquals(r, a, $vectorteststype$::get); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Masked-op.template index c6a97475bca..551d99d7c83 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Masked-op.template @@ -3,5 +3,5 @@ static void [[TEST]]Masked$vectorteststype$(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, r, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template index 059bb42b939..6e97d1517d7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template @@ -45,8 +45,8 @@ for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - int [] r = av.toIntArray(); - assertArraysEquals(a, r, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); } } @@ -60,8 +60,8 @@ for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - long [] r = av.toLongArray(); - assertArraysEquals(a, r, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); } } @@ -72,8 +72,8 @@ for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - double [] r = av.toDoubleArray(); - assertArraysEquals(a, r, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); } } #end[!Double] @@ -115,7 +115,7 @@ $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); av.reinterpretAsBytes().intoArray(r, i); } - assertArraysEquals(a, r, 0); + assertArraysEquals(r, a, 0); } #end[byte] @@ -154,7 +154,7 @@ ra += r[i]; } - assertReductionLongArraysEquals(a, r, ra, + assertReductionLongArraysEquals(r, ra, a, $vectorteststype$::ADDReduceLong, $vectorteststype$::ADDReduceAllLong); } @@ -195,7 +195,7 @@ ra += r[i]; } - assertReductionLongArraysEqualsMasked(a, r, ra, mask, + assertReductionLongArraysEqualsMasked(r, ra, a, mask, $vectorteststype$::ADDReduceLongMasked, $vectorteststype$::ADDReduceAllLongMasked); } @@ -211,7 +211,7 @@ for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$.broadcast(SPECIES, (long)a[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, r); + assertBroadcastArraysEquals(r, a); } @Test(dataProvider = "$type$BinaryOpMaskProvider") @@ -229,7 +229,7 @@ av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(a, b, r, mask, $vectorteststype$::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, $vectorteststype$::blend); } #end[!Long] @@ -250,7 +250,7 @@ ra += r[i]; } - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, $vectorteststype$::ADDReduce, $vectorteststype$::ADDReduceAll); } @@ -272,7 +272,7 @@ ra += r[i]; } - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, $vectorteststype$::ADDReduceMasked, $vectorteststype$::ADDReduceAllMasked); } #end[Long] @@ -294,7 +294,7 @@ bv.selectFrom(av).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); } #if[Int] @@ -317,7 +317,7 @@ bv.selectFrom(av, vmask).intoArray(r, i); } - assertSelectFromArraysEquals(a, r, order, mask, SPECIES.length()); + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); } @Test(dataProvider = "shuffleProvider") @@ -394,7 +394,7 @@ var cv = av.eq(bv); cv.intoArray(r, i); } - assertArraysEquals(a, b, r, $vectorteststype$::beq); + assertArraysEquals(r, a, b, $vectorteststype$::beq); } @Test(dataProvider = "maskProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Rearrange.template b/test/jdk/jdk/incubator/vector/templates/Unit-Rearrange.template index f4feba0efa8..de66f1ae234 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Rearrange.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Rearrange.template @@ -3,7 +3,7 @@ static void Rearrange$vectorteststype$(IntFunction<$type$[]> fa, BiFunction fs) { [[KERNEL]] - assertRearrangeArraysEquals(a, r, order, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); } @Test(dataProvider = "$type$UnaryOpShuffleMaskProvider") @@ -21,5 +21,5 @@ av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); } - assertRearrangeArraysEquals(a, r, order, mask, SPECIES.length()); + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Max-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Max-op.template index 892b99ae923..70ffa79bf6f 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Max-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Max-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpMaskProvider") static void [[TEST]]Reduce$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, $vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Min-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Min-op.template index 892b99ae923..70ffa79bf6f 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Min-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-Min-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpMaskProvider") static void [[TEST]]Reduce$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, $vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-op.template index 892b99ae923..70ffa79bf6f 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Masked-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpMaskProvider") static void [[TEST]]Reduce$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] - assertReductionArraysEqualsMasked(a, r, ra, mask, + assertReductionArraysEqualsMasked(r, ra, a, mask, $vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Max-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Max-op.template index 9bd17186aa6..b86248f3f09 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Max-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Max-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]Reduce$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, $vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Min-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Min-op.template index 9bd17186aa6..b86248f3f09 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Min-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Min-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]Reduce$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, $vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template index 9bd17186aa6..b86248f3f09 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template @@ -1,6 +1,6 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]Reduce$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertReductionArraysEquals(a, r, ra, + assertReductionArraysEquals(r, ra, a, $vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-Masked-op.template index d08ba62dba0..e40018bbdfd 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-Masked-op.template @@ -21,6 +21,6 @@ @Test(dataProvider = "scatterMaskedOpIndexProvider") static void [[TEST]][[TEST_TYPE]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, BiFunction fs, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]); + assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-op.template index 2cfda9f730c..db04500e3e7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Scatter-op.template @@ -10,6 +10,6 @@ @Test(dataProvider = "$type$UnaryOpIndexProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction fs) { [[KERNEL]] - assertArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Shift-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Shift-Masked-op.template index 5787ea68e68..608217c3571 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Shift-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Shift-Masked-op.template @@ -3,5 +3,5 @@ static void [[TEST]]$vectorteststype$Shift(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertShiftArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]]_unary); + assertShiftArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]]_unary); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Shift-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Shift-op.template index e958c459375..b225da4b22b 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Shift-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Shift-op.template @@ -5,5 +5,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$Shift(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertShiftArraysEquals(a, b, r, $vectorteststype$::[[TEST]]_unary); + assertShiftArraysEquals(r, a, b, $vectorteststype$::[[TEST]]_unary); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Single-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Single-op.template index 95ebdd12a68..5c60e43c4ed 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Single-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Single-op.template @@ -8,5 +8,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(a, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-Masked-bop.template b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-Masked-bop.template index bb4a5f41e28..08ef495038b 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-Masked-bop.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-Masked-bop.template @@ -15,5 +15,5 @@ static void [[TEST]]$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, origin, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, origin, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-bop.template b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-bop.template index 51c9f4ec025..7382e86c046 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-bop.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-bop.template @@ -14,5 +14,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$Binary(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertArraysEquals(a, b, r, origin, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, origin, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-op.template index 57357bbae29..6ee07f388b9 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Slice-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Slice-op.template @@ -12,5 +12,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(a, r, origin, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, origin, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-Masked-op.template index 6ea50407f9f..2bd267d574e 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-Masked-op.template @@ -14,7 +14,7 @@ av.lanewise(VectorOperators.[[TEST]], bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, mask, $vectorteststype$::[[TEST]]); + assertBroadcastArraysEquals(r, a, b, c, mask, $vectorteststype$::[[TEST]]); } @Test(dataProvider = "$type$TernaryOpMaskProvider") @@ -33,5 +33,5 @@ av.lanewise(VectorOperators.[[TEST]], b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, mask, $vectorteststype$::[[TEST]]); + assertAltBroadcastArraysEquals(r, a, b, c, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-op.template index 7a64b4331c7..0815e57c50f 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Broadcast-op.template @@ -10,7 +10,7 @@ $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.[[TEST]], bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(a, b, c, r, $vectorteststype$::[[TEST]]); + assertBroadcastArraysEquals(r, a, b, c, $vectorteststype$::[[TEST]]); } @Test(dataProvider = "$type$TernaryOpProvider") @@ -25,5 +25,5 @@ $abstractvectortype$ cv = $abstractvectortype$.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.[[TEST]], b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(a, b, c, r, $vectorteststype$::[[TEST]]); + assertAltBroadcastArraysEquals(r, a, b, c, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-Masked-op.template index 5dc2d9c2c38..706a39d616a 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-Masked-op.template @@ -11,5 +11,5 @@ final int INVOC_COUNT = count; #end[double] [[KERNEL]] - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, $vectorteststype$::[[TEST]]); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-op.template index e828078db06..9c2fd9312b4 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Double-Broadcast-op.template @@ -10,5 +10,5 @@ final int INVOC_COUNT = count; #end[double] [[KERNEL]] - assertDoubleBroadcastArraysEquals(a, b, c, r, $vectorteststype$::[[TEST]]); + assertDoubleBroadcastArraysEquals(r, a, b, c, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Masked-op.template index e852234fbde..1b079e965d4 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-Masked-op.template @@ -11,5 +11,5 @@ final int INVOC_COUNT = count; #end[double] [[KERNEL]] - assertArraysEquals(a, b, c, r, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, c, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-op.template index d60d65b6ee2..386ceff6a34 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Ternary-op.template @@ -10,5 +10,5 @@ final int INVOC_COUNT = count; #end[double] [[KERNEL]] - assertArraysEquals(a, b, c, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, c, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-Masked-op.template index c6a97475bca..551d99d7c83 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-Masked-op.template @@ -3,5 +3,5 @@ static void [[TEST]]Masked$vectorteststype$(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, r, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template index 9f282f71476..543ba9a7715 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template @@ -9,5 +9,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEqualsWithinOneUlp(a, r, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); + assertArraysEqualsWithinOneUlp(r, a, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op.template index fe7b6ef7bdd..b662fe81c35 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(a, r, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-Masked-bop.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-Masked-bop.template index fbe15996944..760a5393a11 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-Masked-bop.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-Masked-bop.template @@ -38,5 +38,5 @@ static void [[TEST]]$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, IntFunction fm) { [[KERNEL]] - assertArraysEquals(a, b, r, origin, part, mask, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, origin, part, mask, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-bop.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-bop.template index b162bcfa9b8..e723cfd341c 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-bop.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-bop.template @@ -23,5 +23,5 @@ @Test(dataProvider = "$type$BinaryOpProvider") static void [[TEST]]$vectorteststype$Binary(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { [[KERNEL]] - assertArraysEquals(a, b, r, origin, part, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, b, origin, part, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-op.template index 78cb4c07bb7..60e7bba21b6 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unslice-op.template @@ -14,5 +14,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(a, r, origin, $vectorteststype$::[[TEST]]); + assertArraysEquals(r, a, origin, $vectorteststype$::[[TEST]]); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template b/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template index fda74a19e35..cb44361c094 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void with$vectorteststype$(IntFunction<$type$ []> fa) { [[KERNEL]] - assertInsertArraysEquals(a, r, ($type$)4, 0); + assertInsertArraysEquals(r, a, ($type$)4, 0); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index a5b677a02d9..d7c428fce12 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @modules jdk.incubator.vector - * @run testng/othervm -ea -esa -Xbatch $vectorteststype$ + * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation $vectorteststype$ */ #warn This file is preprocessed before being compiled @@ -97,7 +97,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ apply($type$ a); } - static void assertArraysEquals($type$[] a, $type$[] r, FUnOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -112,7 +112,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$ a); } - static void assertArraysEquals($type$[] a, $type$[] r, FUnArrayOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -122,13 +122,13 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a[i]); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } } - static void assertArraysEquals($type$[] a, $type$[] r, boolean[] mask, FUnOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -147,17 +147,17 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ apply($type$[] a); } - static void assertReductionArraysEquals($type$[] a, $type$[] b, $type$ c, + static void assertReductionArraysEquals($type$[] r, $type$ rc, $type$[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -169,17 +169,17 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ apply($type$[] a, boolean[] mask); } - static void assertReductionArraysEqualsMasked($type$[] a, $type$[] b, $type$ c, boolean[] mask, + static void assertReductionArraysEqualsMasked($type$[] r, $type$ rc, $type$[] a, boolean[] mask, FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -192,17 +192,17 @@ public class $vectorteststype$ extends AbstractVectorTest { long apply($type$[] a); } - static void assertReductionLongArraysEquals($type$[] a, long[] b, long c, + static void assertReductionLongArraysEquals(long[] r, long rc, $type$[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a)); + Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -214,17 +214,17 @@ public class $vectorteststype$ extends AbstractVectorTest { long apply($type$[] a, boolean[] mask); } - static void assertReductionLongArraysEqualsMasked($type$[] a, long[] b, long c, boolean[] mask, + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, $type$[] a, boolean[] mask, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(c, fa.apply(a, mask)); + Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i, mask)); + Assert.assertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(c, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(b[i], f.apply(a, i, mask), "at index #" + i); + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } #end[!Long] @@ -233,37 +233,37 @@ public class $vectorteststype$ extends AbstractVectorTest { boolean apply(boolean[] a, int idx); } - static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) { + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(b[i], f.apply(a, i)); + Assert.assertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); } } - static void assertInsertArraysEquals($type$[] a, $type$[] b, $type$ element, int index) { + static void assertInsertArraysEquals($type$[] r, $type$[] a, $type$ element, int index) { int i = 0; try { for (; i < a.length; i += 1) { if(i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element); + Assert.assertEquals(r[i], element); } else { - Assert.assertEquals(b[i], a[i]); + Assert.assertEquals(r[i], a[i]); } } } catch (AssertionError e) { if (i%SPECIES.length() == index) { - Assert.assertEquals(b[i], element, "at index #" + i); + Assert.assertEquals(r[i], element, "at index #" + i); } else { - Assert.assertEquals(b[i], a[i], "at index #" + i); + Assert.assertEquals(r[i], a[i], "at index #" + i); } } } - static void assertRearrangeArraysEquals($type$[] a, $type$[] r, int[] order, int vector_len) { + static void assertRearrangeArraysEquals($type$[] r, $type$[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -277,7 +277,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertSelectFromArraysEquals($type$[] a, $type$[] r, $type$[] order, int vector_len) { + static void assertSelectFromArraysEquals($type$[] r, $type$[] a, $type$[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -291,7 +291,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertRearrangeArraysEquals($type$[] a, $type$[] r, int[] order, boolean[] mask, int vector_len) { + static void assertRearrangeArraysEquals($type$[] r, $type$[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -311,7 +311,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertSelectFromArraysEquals($type$[] a, $type$[] r, $type$[] order, boolean[] mask, int vector_len) { + static void assertSelectFromArraysEquals($type$[] r, $type$[] a, $type$[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { @@ -331,7 +331,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEquals($type$[]a, $type$[]r) { + static void assertBroadcastArraysEquals($type$[] r, $type$[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; @@ -360,7 +360,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, FBinOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -371,7 +371,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] r, FBinOp f) { + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -383,7 +383,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastLongArraysEquals($type$[] a, $type$[] b, $type$[] r, FBinOp f) { + static void assertBroadcastLongArraysEquals($type$[] r, $type$[] a, $type$[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -395,11 +395,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { - assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinMaskOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -410,11 +410,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { - assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -428,11 +428,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastLongArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { - assertBroadcastLongArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertBroadcastLongArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertBroadcastLongArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinMaskOp f) { + static void assertBroadcastLongArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -446,7 +446,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertShiftArraysEquals($type$[] a, $type$[] b, $type$[] r, FBinOp f) { + static void assertShiftArraysEquals($type$[] r, $type$[] a, $type$[] b, FBinOp f) { int i = 0; int j = 0; try { @@ -460,11 +460,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertShiftArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { - assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + static void assertShiftArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); } - static void assertShiftArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinMaskOp f) { + static void assertShiftArraysEquals($type$[] r, $type$[] a, $type$[] b, boolean[] mask, FBinMaskOp f) { int i = 0; int j = 0; try { @@ -490,7 +490,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, FTernOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -501,11 +501,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, FTernOp f) { - assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, FTernMaskOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -517,7 +517,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, FTernOp f) { + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -530,7 +530,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertAltBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, FTernOp f) { + static void assertAltBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -543,12 +543,12 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernOp f) { - assertBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -564,12 +564,12 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertAltBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernOp f) { - assertAltBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertAltBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertAltBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -585,7 +585,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertDoubleBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, FTernOp f) { + static void assertDoubleBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -600,12 +600,12 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertDoubleBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernOp f) { - assertDoubleBroadcastArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f)); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); } - static void assertDoubleBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] c, $type$[] r, boolean[] mask, + static void assertDoubleBroadcastArraysEquals($type$[] r, $type$[] a, $type$[] b, $type$[] c, boolean[] mask, FTernMaskOp f) { int i = 0; try { @@ -645,7 +645,7 @@ public class $vectorteststype$ extends AbstractVectorTest { return true; } - static void assertArraysEqualsWithinOneUlp($type$[] a, $type$[] r, FUnOp mathf, FUnOp strictmathf) { + static void assertArraysEqualsWithinOneUlp($type$[] r, $type$[] a, FUnOp mathf, FUnOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -659,7 +659,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEqualsWithinOneUlp($type$[] a, $type$[] b, $type$[] r, FBinOp mathf, FBinOp strictmathf) { + static void assertArraysEqualsWithinOneUlp($type$[] r, $type$[] a, $type$[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. @@ -673,7 +673,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertBroadcastArraysEqualsWithinOneUlp($type$[] a, $type$[] b, $type$[] r, + static void assertBroadcastArraysEqualsWithinOneUlp($type$[] r, $type$[] a, $type$[] b, FBinOp mathf, FBinOp strictmathf) { int i = 0; try { @@ -704,7 +704,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ apply($type$[] a, int b); } - static void assertArraysEquals($type$[] a, $type$[] r, FBinArrayOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, FBinArrayOp f) { int i = 0; try { for (; i < a.length; i++) { @@ -719,7 +719,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, int ix, int[] b, int iy); } - static void assertArraysEquals($type$[] a, int[] b, $type$[] r, FGatherScatterOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -746,7 +746,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] r, $type$[] a, int ix, boolean[] mask, int[] b, int iy); } - static void assertArraysEquals($type$[] a, int[] b, $type$[] r, boolean[] mask, FGatherMaskedOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -756,7 +756,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, i, mask, b, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -767,7 +767,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } } - static void assertArraysEquals($type$[] a, int[] b, $type$[] r, boolean[] mask, FScatterMaskedOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -777,7 +777,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(r, a, i, mask, b, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -794,7 +794,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, int origin, int idx); } - static void assertArraysEquals($type$[] a, $type$[] r, int origin, FLaneOp f) { + static void assertArraysEquals($type$[] r, $type$[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -804,7 +804,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, origin, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -814,7 +814,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, $type$[] b, int origin, int idx); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, int origin, FLaneBop f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, int origin, FLaneBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -824,7 +824,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -835,7 +835,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, $type$[] b, int origin, boolean[] mask, int idx); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, int origin, boolean[] mask, FLaneMaskedBop f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, int origin, boolean[] mask, FLaneMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -845,7 +845,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, mask, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -856,7 +856,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, $type$[] b, int origin, int part, int idx); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, int origin, int part, FLanePartBop f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, int origin, int part, FLanePartBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -866,7 +866,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, part, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -878,7 +878,7 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$[] apply($type$[] a, $type$[] b, int origin, int part, boolean[] mask, int idx); } - static void assertArraysEquals($type$[] a, $type$[] b, $type$[] r, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + static void assertArraysEquals($type$[] r, $type$[] a, $type$[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { @@ -888,7 +888,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, part, mask, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(ref, res, "(ref: " + Arrays.toString(ref) + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -934,7 +934,7 @@ public class $vectorteststype$ extends AbstractVectorTest { #end[!byteOrShort] #end[!Int] - static void assertArraysEquals($type$[] a, int[] r, int offs) { + static void assertArraysEquals(int[] r, $type$[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -984,7 +984,7 @@ public class $vectorteststype$ extends AbstractVectorTest { #end[!Long] #if[byte] - static void assertArraysEquals($type$[] a, $type$[] r, int offs) { + static void assertArraysEquals($type$[] r, $type$[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -996,7 +996,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } #end[byte] - static void assertArraysEquals($type$[] a, long[] r, int offs) { + static void assertArraysEquals(long[] r, $type$[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { @@ -1008,7 +1008,7 @@ public class $vectorteststype$ extends AbstractVectorTest { } #if[!Double] - static void assertArraysEquals($type$[] a, double[] r, int offs) { + static void assertArraysEquals(double[] r, $type$[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { diff --git a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template index cb952e3566b..5596ac33a2d 100644 --- a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template +++ b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,9 @@ * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation #if[MaxBit] * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * $vectorteststype$ + * -XX:-TieredCompilation $vectorteststype$ #else[MaxBit] - * @run testng $vectorteststype$ + * @run testng/othervm -XX:-TieredCompilation $vectorteststype$ #end[MaxBit] * */ @@ -84,48 +84,26 @@ public class $vectorteststype$ extends AbstractVectorTest { static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * ($bits$ / 8)); - static void assertArraysEquals($type$[] a, $type$[] r, boolean[] mask) { + static void assertArraysEquals($type$[] r, $type$[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : ($type$) 0, r[i]); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : ($type$) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[i] : ($type$) 0, r[i], "at index #" + i); - } - } - - static void assertArraysEquals($type$[] a, $type$[] r, int[] im) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(a[im[i]], r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(a[im[i]], r[i], "at index #" + i); - } - } - - static void assertArraysEquals($type$[] a, $type$[] r, int[] im, boolean[] mask) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : ($type$) 0, r[i]); - } - } catch (AssertionError e) { - Assert.assertEquals(mask[i % SPECIES.length()] ? a[im[i]] : ($type$) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : ($type$) 0, "at index #" + i); } } #if[!byte] - static void assertArraysEquals(byte[] a, byte[] r, boolean[] mask) { + static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i]); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0); } } catch (AssertionError e) { - Assert.assertEquals(mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, r[i], "at index #" + i); + Assert.assertEquals(r[i], mask[(i*8/SPECIES.elementSize()) % SPECIES.length()] ? a[i] : (byte) 0, "at index #" + i); } } #end[!byte] @@ -433,7 +411,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test(dataProvider = "$type$ProviderForIOOBE") @@ -504,7 +482,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoArray(r, i); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new $type$[a.length]; @@ -515,7 +493,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoArray(r, i, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "$type$MaskProviderForIOOBE") @@ -588,7 +566,7 @@ public class $vectorteststype$ extends AbstractVectorTest { vmask.intoArray(r, i); } } - Assert.assertEquals(mask, r); + Assert.assertEquals(r, mask); } @@ -612,7 +590,7 @@ public class $vectorteststype$ extends AbstractVectorTest { Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - Assert.assertEquals(a, r, "Buffers not equal"); + Assert.assertEquals(r, a, "Buffers not equal"); } @Test(dataProvider = "$type$ByteProviderForIOOBE") @@ -699,7 +677,7 @@ public class $vectorteststype$ extends AbstractVectorTest { Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); r = fb.apply(a.limit()); @@ -714,7 +692,7 @@ public class $vectorteststype$ extends AbstractVectorTest { Assert.assertEquals(a.limit(), l, "Input buffer limit changed"); Assert.assertEquals(r.position(), 0, "Result buffer position changed"); Assert.assertEquals(r.limit(), l, "Result buffer limit changed"); - assertArraysEquals(_a, bufferToArray(r), mask); + assertArraysEquals(bufferToArray(r), _a, mask); } @Test(dataProvider = "$type$ByteMaskProviderForIOOBE") @@ -830,7 +808,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoByteArray(r, i, bo); } } - Assert.assertEquals(a, r, "Byte arrays not equal"); + Assert.assertEquals(r, a, "Byte arrays not equal"); } @Test(dataProvider = "$type$ByteProviderForIOOBE") @@ -911,7 +889,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoByteArray(r, i, bo); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); r = new byte[a.length]; @@ -922,7 +900,7 @@ public class $vectorteststype$ extends AbstractVectorTest { av.intoByteArray(r, i, bo, vmask); } } - assertArraysEquals(a, r, mask); + assertArraysEquals(r, a, mask); } @Test(dataProvider = "$type$ByteMaskProviderForIOOBE") @@ -999,7 +977,7 @@ public class $vectorteststype$ extends AbstractVectorTest { vmask.intoArray(r, i); } } - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } @Test @@ -1010,7 +988,7 @@ public class $vectorteststype$ extends AbstractVectorTest { int [] r = shuffle.toArray(); int [] a = expectedShuffle(SPECIES.length(), fn); - Assert.assertEquals(a, r); + Assert.assertEquals(r, a); } } } diff --git a/test/jdk/jdk/internal/jrtfs/UriTests.java b/test/jdk/jdk/internal/jrtfs/UriTests.java new file mode 100644 index 00000000000..be90e2d032f --- /dev/null +++ b/test/jdk/jdk/internal/jrtfs/UriTests.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8242258 + * @summary (jrtfs) Path::toUri throws AssertionError for malformed input + * @run testng UriTests + */ + +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.net.URI; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +public class UriTests { + private FileSystem theFileSystem; + + @BeforeClass + public void setup() { + theFileSystem = FileSystems.getFileSystem(URI.create("jrt:/")); + } + + @DataProvider(name = "problemStrings") + private Object[][] problemStrings() { + return new Object[][] { + { "[", "jrt:/%5B" }, + { "]", "jrt:/%5D" }, + { "{", "jrt:/%7B" }, + { "}", "jrt:/%7D" }, + { "`", "jrt:/%60" }, + { "%", "jrt:/%25" }, + { " xyz", "jrt:/%20xyz" }, + { "xyz ", "jrt:/xyz%20" }, + { "xy z", "jrt:/xy%20z" }, + }; + } + + @Test(dataProvider = "problemStrings") + public void testPathToURI(String pathSuffix, String uriStr) { + URI uri = theFileSystem.getPath("/modules/" + pathSuffix).toUri(); + assertEquals(uri.toString(), uriStr); + } + + @Test(dataProvider = "problemStrings") + public void testURIToPath(String pathSuffix, String uriStr) { + Path path = theFileSystem.provider().getPath(URI.create(uriStr)); + assertEquals(path.toString(), "/modules/" + pathSuffix); + } +} diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java new file mode 100644 index 00000000000..837b34a6132 --- /dev/null +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnMetadata.java @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.api.consumer.recordingstream; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Semaphore; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.consumer.EventStream; +import jdk.jfr.consumer.MetadataEvent; +import jdk.jfr.consumer.RecordingStream; + +/** + * @test + * @summary Tests RecordingStream::onMetadata(...) + * @key jfr + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestOnMetadata + */ +public class TestOnMetadata { + + public static void main(String... args) throws Throwable { + testDirectoryStream(true, false); + testFileStream(true, false); + + testAddAfterStart(); + testRemove(); + testNull(); + testUnmodifiable(); + } + + private static void testUnmodifiable() throws Exception { + AtomicBoolean fail = new AtomicBoolean(); + try (RecordingStream r = new RecordingStream()) { + r.onMetadata(m -> { + EventType t = FlightRecorder.getFlightRecorder().getEventTypes().get(0); + try { + m.getEventTypes().add(t); + System.out.println("Should not be able to modify getEventTypes()"); + fail.set(true); + } catch (UnsupportedOperationException uoe) { + // as expected; + } + try { + m.getRemovedEventTypes().add(t); + System.out.println("Should not be able to modify getRemovedEventTypes()"); + fail.set(true); + } catch (UnsupportedOperationException uoe) { + // as expected; + } + try { + m.getAddedEventTypes().add(t); + System.out.println("Should not be able to modify getAddedEventTypes()"); + fail.set(true); + } catch (UnsupportedOperationException uoe) { + // as expected; + } + r.close(); + }); + r.start(); + r.awaitTermination(); + if (fail.get()) { + throw new Exception("Metadata event could be mofified"); + } + } + } + + private static void testNull() throws Exception { + try (RecordingStream r = new RecordingStream()) { + try { + r.onMetadata(null); + throw new Exception("Expected NullPointerException"); + } catch (NullPointerException e) { + // as expected; + } + } + } + + private static void testRemove() throws Exception { + class RemoveEvent extends Event { + } + AtomicBoolean receviedMetadata = new AtomicBoolean(); + try (RecordingStream r = new RecordingStream()) { + Consumer m = e -> { + receviedMetadata.set(true); + }; + r.onMetadata(m); + r.remove(m); + r.onEvent(e -> { + r.close(); + }); + r.remove(m); + r.startAsync(); + RemoveEvent t = new RemoveEvent(); + t.commit(); + r.awaitTermination(); + if (receviedMetadata.get()) { + throw new Exception("Unexpected MetadataEvent!"); + } + } + } + + private static void testAddAfterStart() throws Exception { + try (RecordingStream rs = new RecordingStream()) { + rs.startAsync(); + rs.onMetadata(m -> { + }); + throw new Exception("Expected exception if handler is added after start"); + } catch (IllegalStateException ise) { + // as expected + } + } + + private static void testFileStream(boolean ordered, boolean reuse) throws Exception { + class Spider extends Event { + + } + AtomicInteger counter = new AtomicInteger(); + try (Recording rs = new Recording()) { + rs.start(); // event 1 + rotateChunk(); + FlightRecorder.register(Spider.class); + final EventType spiderType = EventType.getEventType(Spider.class); + // event 2 + rotateChunk(); + FlightRecorder.unregister(Spider.class); + // event 3 + rs.stop(); + Path p = Paths.get("test-file-stream-jfr"); + rs.dump(p); + try (EventStream s = EventStream.openFile(p)) { + System.out.println("Testing file: ordered=" + ordered + " reuse=" + reuse); + + s.setOrdered(ordered); + s.setReuse(reuse); + s.onMetadata(e -> { + int count = counter.get(); + if (count == 1) { + assertinitialEventypes(e); + } + if (count == 2) { + assertAddedEventType(e, spiderType); + } + if (count == 3) { + assertRemovedEventType(e, spiderType); + } + }); + s.start(); + if (counter.get() > 3) { + throw new Exception("Unexpected number of Metadata events"); + } + } + } + } + + private static void testDirectoryStream(boolean ordered, boolean reuse) throws Throwable { + @Registered(false) + class Turtle extends Event { + } + + class AssertEventTypes implements Consumer { + private final Semaphore semaphore = new Semaphore(0); + private volatile Throwable exception; + private volatile Consumer assertMethod; + + @Override + public void accept(MetadataEvent t) { + try { + assertMethod.accept(t); + } catch (Throwable e) { + this.exception = e; + e.printStackTrace(); + } + semaphore.release(); + } + + public void await() throws Throwable { + semaphore.acquire(); + if (exception != null) { + throw exception; + } + } + } + + try (RecordingStream rs = new RecordingStream()) { + System.out.println("Testing directory: ordered=" + ordered + " reuse=" + reuse); + rs.setOrdered(ordered); + rs.setReuse(reuse); + + AssertEventTypes assertion = new AssertEventTypes(); + + // Check initial event types + assertion.assertMethod = e -> assertinitialEventypes(e); + rs.onMetadata(assertion); + rs.startAsync(); + assertion.await(); + + // Check added event type + assertion.assertMethod = e -> assertAddedEventType(e, EventType.getEventType(Turtle.class)); + FlightRecorder.register(Turtle.class); + final EventType turtleType = EventType.getEventType(Turtle.class); + assertion.await(); + + // Check removal of turtle event + assertion.assertMethod = e -> assertRemovedEventType(e, turtleType); + FlightRecorder.unregister(Turtle.class); + rotateChunk(); + assertion.await(); + } + } + + private static void assertRemovedEventType(MetadataEvent m, EventType removedType) { + List eventTypes = FlightRecorder.getFlightRecorder().getEventTypes(); + List added = m.getAddedEventTypes(); + List all = m.getEventTypes(); + List removed = m.getRemovedEventTypes(); + + assertEventTypes(all, eventTypes); + assertEventTypes(added, Collections.emptyList()); + assertEventTypes(removed, List.of(removedType)); + } + + private static void assertAddedEventType(MetadataEvent m, EventType addedType) { + List eventTypes = FlightRecorder.getFlightRecorder().getEventTypes(); + List added = m.getAddedEventTypes(); + List all = m.getEventTypes(); + List removed = m.getRemovedEventTypes(); + + assertEventTypes(all, eventTypes); + assertEventTypes(added, List.of(addedType)); + assertEventTypes(removed, Collections.emptyList()); + } + + private static void assertinitialEventypes(MetadataEvent m) { + List added = m.getAddedEventTypes(); + List all = m.getEventTypes(); + List removed = m.getRemovedEventTypes(); + List eventTypes = FlightRecorder.getFlightRecorder().getEventTypes(); + + assertEventTypes(all, eventTypes); + assertEventTypes(added, eventTypes); + assertEventTypes(removed, Collections.emptyList()); + } + + private static void assertEventTypes(List eventTypes, List expected) { + if (eventTypes.size() != expected.size()) { + fail(eventTypes, expected); + } + Set set = new HashSet<>(); + for (EventType eb : expected) { + set.add(eb.getId()); + } + for (EventType ea : eventTypes) { + if (!set.contains(ea.getId())) { + fail(eventTypes, expected); + } + } + } + + private static void fail(List evenTypes, List expected) { + System.out.println("Event types don't match"); + System.out.println("Expected:"); + for (EventType t : expected) { + System.out.println(t.getName()); + } + System.out.println("Got:"); + for (EventType t : expected) { + System.out.println(t.getName()); + } + throw new RuntimeException("EventTypes don't match!"); + } + + private static void rotateChunk() { + try (Recording r = new Recording()) { + r.start(); + } + } +} diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java new file mode 100644 index 00000000000..dea919c2723 --- /dev/null +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestRecordingName.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, NTT DATA. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.api.consumer.recordingstream; + +import jdk.jfr.consumer.RecordingStream; +import jdk.test.lib.jfr.EventNames; + +/** +* @test +* @bug 8257424 +* @summary Tests recording name for RecordingStrream +* @key jfr +* @requires vm.hasJFR +* @library /test/lib +* @run main/othervm jdk.jfr.api.consumer.recordingstream.TestRecordingName +*/ +public class TestRecordingName { + + public static void main(String... args) throws Exception { + try (RecordingStream r = new RecordingStream()) { + r.enable(EventNames.ActiveRecording); + r.onEvent(e -> { + System.out.println(e); + String name = e.getString("name"); + if (name.startsWith("Recording Stream: ")) { + r.close(); + return; + } + System.err.println("Recording name not set, was " + name + ", but expected \"Recording Stream: \""); + }); + r.start(); + } + } +} diff --git a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java index f041c04489a..dd74c1942b7 100644 --- a/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java +++ b/test/jdk/jdk/jfr/api/metadata/eventtype/TestGetField.java @@ -44,13 +44,17 @@ public static void main(String[] args) throws Throwable { EventType type = EventType.getEventType(MyEvent.class); ValueDescriptor v = type.getField("myByte"); - Asserts.assertNotNull(v, "getFiled(myByte) was null"); + Asserts.assertNotNull(v, "getField(myByte) was null"); Asserts.assertEquals(v.getTypeName(), "byte", "myByte was not type byte"); v = type.getField("myInt"); - Asserts.assertNotNull(v, "getFiled(myInt) was null"); + Asserts.assertNotNull(v, "getField(myInt) was null"); Asserts.assertEquals(v.getTypeName(), "int", "myInt was not type int"); + v = type.getField("eventThread.group.name"); + Asserts.assertNotNull(v, "getField(eventThread.group.name) was null"); + Asserts.assertEquals(v.getTypeName(), "java.lang.String", "eventThread.group.name was not type java.lang.String"); + v = type.getField("myStatic"); Asserts.assertNull(v, "got static field"); @@ -60,6 +64,7 @@ public static void main(String[] args) throws Throwable { v = type.getField(""); Asserts.assertNull(v, "got field for empty name"); + try { v = type.getField(null); Asserts.fail("No Exception when getField(null)"); diff --git a/test/jdk/jdk/jfr/event/compiler/TestAllocInNewTLAB.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java similarity index 65% rename from test/jdk/jdk/jfr/event/compiler/TestAllocInNewTLAB.java rename to test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java index 61c23665584..51d4f2767c4 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestAllocInNewTLAB.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,18 +23,15 @@ * questions. */ -package jdk.jfr.event.compiler; +package jdk.jfr.event.allocation; import static java.lang.Math.floor; -import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; -import static jdk.test.lib.Asserts.assertLessThanOrEqual; - -import java.time.Duration; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; import jdk.test.lib.jfr.EventNames; import jdk.test.lib.jfr.Events; +import jdk.test.lib.Asserts; /** * @test @@ -42,8 +39,8 @@ * @key jfr * @requires vm.hasJFR * @library /test/lib - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 jdk.jfr.event.compiler.TestAllocInNewTLAB - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 -Xint jdk.jfr.event.compiler.TestAllocInNewTLAB + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 -Xint jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent */ /** @@ -56,56 +53,32 @@ * max TLAB waste at refill is set to minimum (-XX:TLABRefillWasteFraction=1), * to provoke a new TLAB creation. */ -public class TestAllocInNewTLAB { +public class TestObjectAllocationInNewTLABEvent { private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB; private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array. private static final int OBJECT_SIZE = 100 * 1024; - private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops + private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops. private static final int OBJECTS_TO_ALLOCATE = 100; private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); private static final int INITIAL_TLAB_SIZE = 100 * 1024; + private static int countAllTlabs; // Count all matching tlab allocations. + private static int countFullTlabs; // Count matching tlab allocations with full tlab size. - // make sure allocation isn't dead code eliminated + // Make sure allocation isn't dead code eliminated. public static byte[] tmp; public static void main(String[] args) throws Exception { Recording recording = new Recording(); - recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); - + recording.enable(EVENT_NAME); recording.start(); System.gc(); - for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { - tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; - } + allocate(); recording.stop(); - - int countAllTlabs = 0; // Count all matching tlab allocations. - int countFullTlabs = 0; // Count matching tlab allocations with full tlab size. - for (RecordedEvent event : Events.fromRecording(recording)) { - if (!EVENT_NAME.equals(event.getEventType().getName())) { - continue; - } - System.out.println("Event:" + event); - - long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); - long tlabSize = Events.assertField(event, "tlabSize").atLeast(allocationSize).getValue(); - String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); - - boolean isMyEvent = Thread.currentThread().getId() == event.getThread().getJavaThreadId() - && className.equals(BYTE_ARRAY_CLASS_NAME) - && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT); - if (isMyEvent) { - countAllTlabs++; - if (tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE || tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE_ALT) { - countFullTlabs++; - } - } - } - + verifyRecording(recording); int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); - assertGreaterThanOrEqual(countAllTlabs, minCount, "Too few tlab objects allocated"); - assertLessThanOrEqual(countAllTlabs, OBJECTS_TO_ALLOCATE, "Too many tlab objects allocated"); + Asserts.assertGreaterThanOrEqual(countAllTlabs, minCount, "Too few tlab objects allocated"); + Asserts.assertLessThanOrEqual(countAllTlabs, OBJECTS_TO_ALLOCATE, "Too many tlab objects allocated"); // For most GCs we expect the size of each tlab to be // INITIAL_TLAB_SIZE + ALLOCATION_SIZE, but that is not always true for G1. @@ -119,7 +92,33 @@ public static void main(String[] args) throws Exception { // It is only the last tlab in each region that has a smaller size. // This means that at least 50% of the allocated tlabs should // have the expected size (1 full tlab, and 1 fractional tlab). - assertGreaterThanOrEqual(2*countFullTlabs, countAllTlabs, "Too many fractional tlabs."); + Asserts.assertGreaterThanOrEqual(2*countFullTlabs, countAllTlabs, "Too many fractional tlabs."); } + private static void allocate() { + for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { + tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; + } + } + + private static void verifyRecording(Recording recording) throws Exception { + for (RecordedEvent event : Events.fromRecording(recording)) { + verify(event); + } + } + + private static void verify(RecordedEvent event) { + if (Thread.currentThread().getId() != event.getThread().getJavaThreadId()) { + return; + } + long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); + long tlabSize = Events.assertField(event, "tlabSize").atLeast(allocationSize).getValue(); + String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); + if (className.equals(BYTE_ARRAY_CLASS_NAME) && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT)) { + countAllTlabs++; + if (tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE || tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE_ALT) { + countFullTlabs++; + } + } + } } diff --git a/test/jdk/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java similarity index 66% rename from test/jdk/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java rename to test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java index ec90d3d6d88..9efbf4b778a 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,18 +23,15 @@ * questions. */ -package jdk.jfr.event.compiler; +package jdk.jfr.event.allocation; import static java.lang.Math.floor; -import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; -import static jdk.test.lib.Asserts.assertLessThanOrEqual; - -import java.time.Duration; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; import jdk.test.lib.jfr.EventNames; import jdk.test.lib.jfr.Events; +import jdk.test.lib.Asserts; /** * @test @@ -42,8 +39,8 @@ * @key jfr * @requires vm.hasJFR * @library /test/lib - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 jdk.jfr.event.compiler.TestAllocOutsideTLAB - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 -Xint jdk.jfr.event.compiler.TestAllocOutsideTLAB + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 jdk.jfr.event.allocation.TestObjectAllocationOutsideTLABEvent + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 -Xint jdk.jfr.event.allocation.TestObjectAllocationOutsideTLABEvent */ /** @@ -56,7 +53,7 @@ * max TLAB waste at refill is set to 256 (-XX:TLABRefillWasteFraction=256), * to prevent a new TLAB creation. */ -public class TestAllocOutsideTLAB { +public class TestObjectAllocationOutsideTLABEvent { private static final String EVENT_NAME = EventNames.ObjectAllocationOutsideTLAB; private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array @@ -64,39 +61,43 @@ public class TestAllocOutsideTLAB { private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops private static final int OBJECTS_TO_ALLOCATE = 100; private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); + private static int eventCount; - public static byte[] tmp; // Used to prevent optimizer from removing code. + // Make sure allocation isn't dead code eliminated. + public static byte[] tmp; public static void main(String[] args) throws Exception { Recording recording = new Recording(); - recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.enable(EVENT_NAME); recording.start(); + allocate(); + recording.stop(); + verifyRecording(recording); + int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); + Asserts.assertGreaterThanOrEqual(eventCount, minCount, "Too few objects allocated"); + Asserts.assertLessThanOrEqual(eventCount, OBJECTS_TO_ALLOCATE, "Too many objects allocated"); + } + + private static void allocate() { for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; } - recording.stop(); + } - int countEvents = 0; + private static void verifyRecording(Recording recording) throws Exception { for (RecordedEvent event : Events.fromRecording(recording)) { - if (!EVENT_NAME.equals(event.getEventType().getName())) { - continue; - } - System.out.println("Event:" + event); - - long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); - String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); - - boolean isMyEvent = Thread.currentThread().getId() == event.getThread().getJavaThreadId() - && className.equals(BYTE_ARRAY_CLASS_NAME) - && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT); - if (isMyEvent) { - ++countEvents; - } + verify(event); } - - int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); - assertGreaterThanOrEqual(countEvents, minCount, "Too few tlab objects allocated"); - assertLessThanOrEqual(countEvents, OBJECTS_TO_ALLOCATE, "Too many tlab objects allocated"); } + private static void verify(RecordedEvent event) { + if (Thread.currentThread().getId() != event.getThread().getJavaThreadId()) { + return; + } + long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); + String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); + if (className.equals(BYTE_ARRAY_CLASS_NAME) && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT)) { + ++eventCount; + } + } } diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java new file mode 100644 index 00000000000..f16d9eedd9f --- /dev/null +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEvent.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.allocation; + +import java.util.concurrent.CountDownLatch; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingStream; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests ObjectAllocationSampleEvent + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=2k -XX:-ResizeTLAB jdk.jfr.event.allocation.TestObjectAllocationSampleEvent + */ +public class TestObjectAllocationSampleEvent { + private static final String EVENT_NAME = EventNames.ObjectAllocationSample; + private static final int OBJECT_SIZE = 4 * 1024; + private static final int OBJECTS_TO_ALLOCATE = 16; + private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); + + // Make sure allocation isn't dead code eliminated. + public static byte[] tmp; + + public static void main(String... args) throws Exception { + CountDownLatch delivered = new CountDownLatch(1); + Thread current = Thread.currentThread(); + try (RecordingStream rs = new RecordingStream()) { + rs.enable(EVENT_NAME); + rs.onEvent(EVENT_NAME, e -> { + if (verify(e, current)) { + delivered.countDown(); + } + }); + rs.startAsync(); + for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { + tmp = new byte[OBJECT_SIZE]; + } + delivered.await(); + } + } + + private static boolean verify(RecordedEvent event, Thread thread) { + if (thread.getId() != event.getThread().getJavaThreadId()) { + return false; + } + if (Events.assertField(event, "objectClass.name").notEmpty().getValue().equals(BYTE_ARRAY_CLASS_NAME)) { + Events.assertField(event, "weight").atLeast(1L); + return true; + } + return false; + } +} diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java new file mode 100644 index 00000000000..1e09441fbdd --- /dev/null +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.allocation; + +import static java.lang.Math.floor; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test that when an object is allocated outside a TLAB an event will be triggered. + * @key jfr + * @requires vm.hasJFR + * @library /test/lib +* @run main/othervm -XX:+UseTLAB -XX:TLABSize=2k -XX:-ResizeTLAB jdk.jfr.event.allocation.TestObjectAllocationSampleEventThrottling + */ + +public class TestObjectAllocationSampleEventThrottling { + private static final String EVENT_NAME = EventNames.ObjectAllocationSample; + + private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array + private static final int OBJECT_SIZE = 100 * 1024; + private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops + private static final int OBJECTS_TO_ALLOCATE = 100; + private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); + private static int eventCount; + + // Make sure allocation isn't dead code eliminated. + public static byte[] tmp; + + public static void main(String[] args) throws Exception { + testZeroPerSecond(); + testThrottleSettings(); + } + + private static void testZeroPerSecond() throws Exception { + Recording r1 = new Recording(); + setThrottle(r1, "0/s"); + r1.start(); + allocate(); + r1.stop(); + List events = Events.fromRecording(r1); + Asserts.assertTrue(events.isEmpty(), "throttle rate 0/s should not emit any events"); + } + + private static void testThrottleSettings() throws Exception { + Recording r1 = new Recording(); + // 0/s will not emit any events + setThrottle(r1, "0/s"); + r1.start(); + Recording r2 = new Recording(); + // 1/ns is a *very* high emit rate, it should trump the previous 0/s value + // to allow the allocation sample events to be recorded. + setThrottle(r2, "1/ns"); + r2.start(); + allocate(); + r2.stop(); + r1.stop(); + verifyRecording(r2); + int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); + Asserts.assertGreaterThanOrEqual(eventCount, minCount, "Too few object samples allocated"); + List events = Events.fromRecording(r1); + Asserts.assertFalse(events.isEmpty(), "r1 should also have events"); + } + + private static void setThrottle(Recording recording, String rate) { + recording.enable(EVENT_NAME).with("throttle", rate); + } + + private static void allocate() { + for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { + tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; + } + } + + private static void verifyRecording(Recording recording) throws Exception { + for (RecordedEvent event : Events.fromRecording(recording)) { + verify(event); + } + } + + private static void verify(RecordedEvent event) { + if (Thread.currentThread().getId() != event.getThread().getJavaThreadId()) { + return; + } + if (Events.assertField(event, "objectClass.name").notEmpty().getValue().equals(BYTE_ARRAY_CLASS_NAME)) { + Events.assertField(event, "weight").atLeast(1L); + ++eventCount; + } + } +} diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java new file mode 100644 index 00000000000..3fb5ba27bc2 --- /dev/null +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test TestGCLockerEvent + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx32m -Xms32m -Xmn12m -XX:+UseG1GC jdk.jfr.event.gc.detailed.TestGCLockerEvent + */ + +package jdk.jfr.event.gc.detailed; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.concurrent.CountDownLatch; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +import sun.hotspot.WhiteBox; + +public class TestGCLockerEvent { + + private static final String EVENT_NAME = EventNames.GCLocker; + + private static final int CRITICAL_THREAD_COUNT = 4; + + private static final CountDownLatch LOCK_COUNT_SIGNAL = new CountDownLatch(CRITICAL_THREAD_COUNT); + + private static final CountDownLatch UNLOCK_SIGNAL = new CountDownLatch(1); + + private static final CountDownLatch UNLOCK_COUNT_SIGNAL = new CountDownLatch(CRITICAL_THREAD_COUNT); + + private static final String CRITICAL_THREAD_NAME_PREFIX = "Critical Thread "; + + private static final int STALL_THREAD_COUNT = 8; + + private static final CountDownLatch STALL_COUNT_SIGNAL = new CountDownLatch(STALL_THREAD_COUNT); + + private static final int LOOP = 32; + + private static final int M = 1024 * 1024; + + public static void main(String[] args) throws Exception { + var recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + + startCriticalThreads(); + LOCK_COUNT_SIGNAL.await(); + startStallThreads(); + STALL_COUNT_SIGNAL.await(); + + // Wait threads to be stalled + Thread.sleep(1500); + + UNLOCK_SIGNAL.countDown(); + UNLOCK_COUNT_SIGNAL.await(); + recording.stop(); + + // Verify recording + var all = Events.fromRecording(recording); + Events.hasEvents(all); + var event = all.get(0); + + assertTrue(Events.isEventType(event, EVENT_NAME)); + Events.assertField(event, "lockCount").equal(CRITICAL_THREAD_COUNT); + Events.assertField(event, "stallCount").atLeast(STALL_THREAD_COUNT); + assertTrue(event.getThread().getJavaName().startsWith(CRITICAL_THREAD_NAME_PREFIX)); + + recording.close(); + } + + private static void startCriticalThreads() { + for (var i = 0; i < CRITICAL_THREAD_COUNT; i++) { + new Thread(() -> { + try { + WhiteBox.getWhiteBox().lockCritical(); + LOCK_COUNT_SIGNAL.countDown(); + + UNLOCK_SIGNAL.await(); + WhiteBox.getWhiteBox().unlockCritical(); + UNLOCK_COUNT_SIGNAL.countDown(); + } catch (InterruptedException ex) { + } + }, CRITICAL_THREAD_NAME_PREFIX + i).start(); + } + } + + private static void startStallThreads() { + var ts = new Thread[STALL_THREAD_COUNT]; + for (var i = 0; i < STALL_THREAD_COUNT; i++) { + ts[i] = new Thread(() -> { + STALL_COUNT_SIGNAL.countDown(); + for (int j = 0; j < LOOP; j++) { + byte[] bytes = new byte[M]; + } + }); + } + for (Thread t : ts) { + t.start(); + } + } +} + diff --git a/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java b/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java index 8ba88792281..1a5e893a916 100644 --- a/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java +++ b/test/jdk/jdk/jfr/event/metadata/TestLookForUntestedEvents.java @@ -82,7 +82,7 @@ public class TestLookForUntestedEvents { // Experimental events private static final Set experimentalEvents = new HashSet<>( Arrays.asList( - "Flush", "SyncOnPrimitiveWrapper") + "Flush", "SyncOnValueBasedClass") ); diff --git a/test/jdk/jdk/jfr/event/runtime/TestSyncOnPrimitiveWrapperEvent.java b/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java similarity index 86% rename from test/jdk/jdk/jfr/event/runtime/TestSyncOnPrimitiveWrapperEvent.java rename to test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java index bf8f31699e4..85b01e4198c 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSyncOnPrimitiveWrapperEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java @@ -38,10 +38,10 @@ * @requires vm.hasJFR * @key jfr * @library /test/lib - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:DiagnoseSyncOnPrimitiveWrappers=2 jdk.jfr.event.runtime.TestSyncOnPrimitiveWrapperEvent + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:DiagnoseSyncOnValueBasedClasses=2 jdk.jfr.event.runtime.TestSyncOnValueBasedClassEvent */ -public class TestSyncOnPrimitiveWrapperEvent { - static final String EVENT_NAME = EventNames.SyncOnPrimitiveWrapper; +public class TestSyncOnValueBasedClassEvent { + static final String EVENT_NAME = EventNames.SyncOnValueBasedClass; static String[] classesWanted = {"java/lang/Character", "java/lang/Boolean", "java/lang/Byte", "java/lang/Short", "java/lang/Integer", "java/lang/Long", "java/lang/Float", "java/lang/Double"}; static List testObjects = new ArrayList(); @@ -74,7 +74,7 @@ public static void main(String[] args) throws Throwable { List events = Events.fromRecording(recording); Events.hasEvents(events); for (RecordedEvent event : Events.fromRecording(recording)) { - String className = Events.assertField(event, "boxClass.name").notEmpty().getValue(); + String className = Events.assertField(event, "valueBasedClass.name").notEmpty().getValue(); RecordedThread jt = event.getThread(); if (Thread.currentThread().getName().equals(jt.getJavaName())) { classesFound.add(className); @@ -82,11 +82,11 @@ public static void main(String[] args) throws Throwable { } for (String classWanted : classesWanted) { if (!classesFound.contains(classWanted)) { - throw new AssertionError("No matching event SyncOnPrimitiveWrapper with \"boxClass=" + classWanted + "\" and current thread as caller"); + throw new AssertionError("No matching event SyncOnValueBasedClass with \"valueBasedClass=" + classWanted + "\" and current thread as caller"); } } if (classesFound.size() != classesWanted.length) { - throw new AssertionError("Invalid number of SyncOnPrimitiveWrapper events for current thread"); + throw new AssertionError("Invalid number of SyncOnValueBasedClass events for current thread"); } } } diff --git a/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java b/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java index 7d771d5ab2d..02035ad2533 100644 --- a/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java @@ -48,12 +48,11 @@ public static void main(String[] args) throws Exception { recording.enable(EventNames.X509Certificate); recording.start(); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - TestCertificate.ONE.generate(cf); - TestCertificate.TWO.generate(cf); + TestCertificate.ONE.certificate(); + TestCertificate.TWO.certificate(); // Generate twice to make sure only one event per certificate is generated - TestCertificate.ONE.generate(cf); - TestCertificate.TWO.generate(cf); + TestCertificate.ONE.certificate(); + TestCertificate.TWO.certificate(); recording.stop(); diff --git a/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java b/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java index c6327753df1..50f472301f0 100644 --- a/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java +++ b/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java @@ -47,8 +47,8 @@ public static void main(String[] args) throws Exception { try (Recording recording = new Recording()) { recording.enable(EventNames.X509Validation); recording.start(); - // intermeditate certificate test - TestCertificate.generateChain(false); + // intermediate certificate test + TestCertificate.generateChain(false, true); recording.stop(); List events = Events.fromRecording(recording); Asserts.assertEquals(events.size(), 3, "Incorrect number of events"); @@ -59,12 +59,23 @@ public static void main(String[] args) throws Exception { recording.enable(EventNames.X509Validation); recording.start(); // self signed certificate test - TestCertificate.generateChain(true); + TestCertificate.generateChain(true, true); recording.stop(); List events = Events.fromRecording(recording); Asserts.assertEquals(events.size(), 2, "Incorrect number of events"); assertEvent2(events); } + + try (Recording recording = new Recording()) { + recording.enable(EventNames.X509Validation); + recording.start(); + // intermediate certificate test, with no Cert for trust anchor + TestCertificate.generateChain(true, false); + recording.stop(); + List events = Events.fromRecording(recording); + Asserts.assertEquals(events.size(), 2, "Incorrect number of events"); + assertEvent3(events); + } } private static void assertEvent1(List events) throws Exception { @@ -108,4 +119,26 @@ private static void assertEvent2(List events) throws Exception { } } } + /* + * Self signed certificate test + */ + private static void assertEvent3(List events) throws Exception { + for (RecordedEvent e : events) { + int pos = e.getInt("certificatePosition"); + switch (pos) { + // use public key of cert provided in TrustAnchor + case 1: + Asserts.assertEquals(e.getLong("certificateId"), + Long.valueOf(TestCertificate.ROOT_CA.certificate().getPublicKey().hashCode())); + break; + case 2: + Events.assertField(e, "certificateId") + .equal(TestCertificate.ROOT_CA.certId); + break; + default: + System.out.println(events); + throw new Exception("Unexpected position:" + pos); + } + } + } } diff --git a/test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java b/test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java index 0e19589d65d..5a4cd4f534f 100644 --- a/test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java +++ b/test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java @@ -35,12 +35,10 @@ import jdk.test.lib.Asserts; import jdk.test.lib.jfr.EventNames; -// Java agent that emits in multiple threads +// Java agent that emits events public class EventEmitterAgent { - private static final int THREADS = 5; - private static final int EVENTS_PER_THREAD = 150_000; - private static final int EXPECTED_COUNT = THREADS * EVENTS_PER_THREAD; + private static final long EVENTS = 150_000; private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath(); // Called when agent is loaded from command line @@ -58,20 +56,13 @@ private static void agentWork() throws Exception { r.enable(EventNames.JavaExceptionThrow); r.setDestination(DUMP_PATH); r.start(); - Thread[] threads = new Thread[THREADS]; - for (int i = 0; i < THREADS; i++) { - threads[i] = new Thread(EventEmitterAgent::emitEvents); - threads[i].start(); - } - for (int i = 0; i < THREADS; i++) { - threads[i].join(); - } + emitEvents(); r.stop(); } } public static void emitEvents() { - for (int i = 0; i < EVENTS_PER_THREAD; i++) { + for (int i = 0; i < EVENTS; i++) { TestEvent e = new TestEvent(); e.msg = "Long message that puts pressure on the string pool " + i % 100; e.count = i; @@ -80,7 +71,7 @@ public static void emitEvents() { e.commit(); if (i % 10000 == 0) { try { - Thread.sleep(1); + Thread.sleep(10); } catch (InterruptedException ie) { // ignore } @@ -101,6 +92,6 @@ public static void validateRecording() throws Exception { .stream() .filter(e -> e.getEventType().getName().equals("Test")) .count(); - Asserts.assertTrue(testEventCount == EXPECTED_COUNT, "Mismatch in TestEvent count"); + Asserts.assertEquals(testEventCount, EVENTS, "Mismatch in TestEvent count"); } } diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestClose.java b/test/jdk/jdk/jfr/jmx/streaming/TestClose.java new file mode 100644 index 00000000000..f21b6298641 --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestClose.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Event; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that a RemoteRecordingStream can be closed + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestClose + */ +public class TestClose { + + static class TestCloseEvent extends Event { + } + + public static void main(String... args) throws Exception { + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + Path p = Files.createDirectory(Paths.get("test-close-" + System.currentTimeMillis())); + + RemoteRecordingStream e = new RemoteRecordingStream(conn, p); + e.startAsync(); + // Produce enough to generate multiple chunks + for (int i = 0; i < 200_000; i++) { + TestCloseEvent event = new TestCloseEvent(); + event.commit(); + } + e.onFlush(() -> { + e.close(); // <- should clean up files. + }); + e.awaitTermination(); + int count = 0; + for (Object path : Files.list(p).toArray()) { + System.out.println(path); + count++; + } + if (count > 0) { + throw new Exception("Expected repository to be empty"); + } + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java b/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java new file mode 100644 index 00000000000..9e204cd4c97 --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestDelegated.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.time.Duration; +import java.util.concurrent.CountDownLatch; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Event; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Sanity test methods that delegates to an ordinary stream + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestDelegated + */ +public class TestDelegated { + + private static MBeanServerConnection CONNECTION = ManagementFactory.getPlatformMBeanServer(); + + static class TestDelegatedEvent extends Event { + } + + // The assumption here is that the following methods don't + // need t be tested fully since they all delegate to the + // same implementation class that is tested elsewhere. + + public static void main(String[] args) throws Exception { + testRemove(); + testReuse(); + testOrdered(); + testOnEvent(); + testOnEventName(); + testOnFlush(); + testOnError(); + testOnClose(); + testSetMaxAge(); + testAwaitTermination(); + testAwaitTerminationWithDuration(); + } + + private static void testSetMaxAge() throws Exception { + try (RemoteRecordingStream stream = new RemoteRecordingStream(CONNECTION)) { + try { + stream.setMaxAge(null); + throw new Exception("Expected NullPointerException"); + } catch (NullPointerException npe) { + // As expected + } + } + } + + private static void testAwaitTerminationWithDuration() throws Exception { + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onEvent(e -> { + rs.close(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + rs.awaitTermination(Duration.ofDays(1)); + } + } + + private static void testAwaitTermination() throws Exception { + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onEvent(e -> { + rs.close(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + rs.awaitTermination(); + } + } + + private static void testOnClose() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onClose(() -> { + latch.countDown(); + }); + rs.startAsync(); + rs.close(); + latch.await(); + } + } + + private static void testOnError() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onEvent(TestDelegatedEvent.class.getName(), e -> { + throw new RuntimeException("Testing"); + }); + rs.onError(t -> { + latch.countDown(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + latch.await(); + } + } + + private static void testOnFlush() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onFlush(() -> { + latch.countDown(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + latch.await(); + } + } + + private static void testOnEventName() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onEvent(TestDelegatedEvent.class.getName(), e -> { + latch.countDown(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + latch.await(); + } + } + + private static void testOnEvent() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.onEvent(e -> { + System.out.println(e); + latch.countDown(); + }); + rs.startAsync(); + TestDelegatedEvent e = new TestDelegatedEvent(); + e.commit(); + latch.await(); + } + + } + + private static void testOrdered() throws Exception { + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.setOrdered(true); + rs.setOrdered(false); + } + } + + private static void testReuse() throws Exception { + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + rs.setReuse(true); + rs.setReuse(false); + } + } + + private static void testRemove() throws Exception { + try (RemoteRecordingStream rs = new RemoteRecordingStream(CONNECTION)) { + Runnable r1 = () -> { + }; + Runnable r2 = () -> { + }; + rs.onFlush(r1); + if (!rs.remove(r1)) { + throw new Exception("Expected remove to return true"); + } + if (rs.remove(r2)) { + throw new Exception("Expected remove to return false"); + } + } + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java b/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java new file mode 100644 index 00000000000..d8459924577 --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestEnableDisable.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.util.concurrent.CountDownLatch; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Name; + +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that event settings for a RemoteRecordingStream can be changed + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestEnableDisable + */ +public class TestEnableDisable { + @Name("Zebra") + @Enabled(false) + static class Zebra extends Event { + } + + @Name("Tiger") + @Enabled(true) + static class Tiger extends Event { + } + + public static void main(String... args) throws Exception { + CountDownLatch zebraLatch = new CountDownLatch(1); + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (RemoteRecordingStream stream = new RemoteRecordingStream(conn)) { + stream.enable("Zebra"); + stream.disable("Tiger"); + + stream.onEvent("Zebra", e -> { + System.out.println(e); + zebraLatch.countDown(); + }); + stream.onEvent("Tiger", e -> { + System.out.println(e); + throw new RuntimeException("Unexpected Tiger"); // will close stream + }); + + stream.startAsync(); + + Tiger t = new Tiger(); + t.commit(); + + Zebra z = new Zebra(); + z.commit(); + + zebraLatch.await(); + } + + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java b/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java new file mode 100644 index 00000000000..23bb05e5016 --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.jmx.streaming; + +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Event; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that max size can be set for a RemoteRecordingStream + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestMaxSize + */ +public class TestMaxSize { + + static class Monkey extends Event { + } + + public static void main(String... args) throws Exception { + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + Path dir = Files.createDirectories(Paths.get("max-size-" + System.currentTimeMillis())); + System.out.println(dir); + AtomicBoolean finished = new AtomicBoolean(); + try (RemoteRecordingStream e = new RemoteRecordingStream(conn, dir)) { + e.startAsync(); + e.onEvent(ev -> { + if (finished.get()) { + return; + } + // Consume some events, but give back control + // to stream so it can be closed. + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + // ignore + } + }); + while (directorySize(dir) < 50_000_000) { + emitEvents(500_000); + } + e.setMaxSize(1_000_000); + long count = fileCount(dir); + if (count > 2) { + // Two chunks can happen when header of new chunk is written and previous + // chunk is not finalized. + throw new Exception("Expected only one or two chunks with setMaxSize(1_000_000). Found " + count); + } + finished.set(true); + } + } + + private static void emitEvents(int count) throws InterruptedException { + for (int i = 0; i < count; i++) { + Monkey m = new Monkey(); + m.commit(); + } + System.out.println("Emitted " + count + " events"); + Thread.sleep(1000); + } + + private static int fileCount(Path dir) throws IOException { + System.out.println("Files:"); + AtomicInteger count = new AtomicInteger(); + Files.list(dir).forEach(p -> { + System.out.println(p); + count.incrementAndGet(); + }); + return count.get(); + } + + private static long directorySize(Path dir) throws IOException { + long p = Files.list(dir).mapToLong(f -> { + try { + return Files.size(f); + } catch (IOException e) { + return 0; + } + }).sum(); + System.out.println("Directory size: " + p); + return p; + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java b/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java new file mode 100644 index 00000000000..ff89b09ab5e --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestMultipleChunks.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.util.concurrent.CountDownLatch; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that a RemoteRecordingStream can stream over multiple chunks + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestMultipleChunks + */ +public class TestMultipleChunks { + + static class Snake extends Event { + } + + public static void main(String... args) throws Exception { + CountDownLatch latch = new CountDownLatch(5); + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (RemoteRecordingStream s = new RemoteRecordingStream(conn)) { + s.onEvent(e -> latch.countDown()); + s.startAsync(); + for (int i = 0; i < 5; i++) { + Snake snake = new Snake(); + snake.commit(); + rotate(); + } + } + } + + private static void rotate() { + try (Recording r = new Recording()) { + r.start(); + } + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestNew.java b/test/jdk/jdk/jfr/jmx/streaming/TestNew.java new file mode 100644 index 00000000000..d23911e21e1 --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestNew.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.jmx.streaming; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.lang.management.ManagementFactory; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Test constructors of RemoteRecordingStream + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestNew + */ +public class TestNew { + + private final static ObjectName MXBEAN = createObjectName(); + + public static void main(String... args) throws Exception { + testNullArguments(); + testMissingDirectory(); + testNotDirectory(); + testDefaultDIrectory(); + TestUserDefinedDirectory(); + + testMissingFlightRecorderMXBean(); + } + + private static void TestUserDefinedDirectory() throws IOException { + Path p = Paths.get("user-repository-" + System.currentTimeMillis()); + Files.createDirectory(p); + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (RemoteRecordingStream s = new RemoteRecordingStream(conn, p)) { + // success + } + } + + private static void testDefaultDIrectory() throws IOException { + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (RemoteRecordingStream s = new RemoteRecordingStream(conn)) { + // success + } + } + + private static void testNotDirectory() throws Exception { + Path p = Paths.get("file.txt"); + RandomAccessFile raf = new RandomAccessFile(p.toFile(), "rw"); + raf.close(); + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (var s = new RemoteRecordingStream(conn, p)) { + throw new Exception("Expected IOException"); + } catch (IOException ioe) { + if (!ioe.getMessage().contains("Download location must be a directory")) { + throw new Exception("Unexpected message " + ioe.getMessage()); + } + } + } + + private static void testMissingDirectory() throws Exception { + Path p = Paths.get("/missing"); + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (var s = new RemoteRecordingStream(conn, p)) { + throw new Exception("Expected IOException"); + } catch (IOException ioe) { + if (!ioe.getMessage().contains("Download directory doesn't exist")) { + throw new Exception("Unexpected message " + ioe.getMessage()); + } + } + } + + private static void testNullArguments() throws Exception { + try (var s = new RemoteRecordingStream(null)) { + throw new Exception("Expected NullPointerException"); + } catch (NullPointerException npe) { + // as expected + } + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (var s = new RemoteRecordingStream(conn, null)) { + throw new Exception("Expected NullPointerException"); + } catch (NullPointerException npe) { + // as expected + } + } + + private static void testMissingFlightRecorderMXBean() throws Exception { + + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + conn.unregisterMBean(MXBEAN); + try (var s = new RemoteRecordingStream(conn)) { + throw new Exception("Expected IOException"); + } catch (IOException npe) { + // as expected + } + } + + private static ObjectName createObjectName() { + try { + return new ObjectName(FlightRecorderMXBean.MXBEAN_NAME); + } catch (Exception e) { + throw new InternalError("Unexpected exception", e); + } + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java new file mode 100644 index 00000000000..05a0bab74da --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.CountDownLatch; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.StackTrace; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that streaming can work over chunk rotations + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestRotate + */ +public class TestRotate { + + @StackTrace(false) + static class TestRotateEvent extends Event { + int value; + } + + public static void main(String... args) throws Exception { + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + Path p = Files.createDirectory(Paths.get("test-stream-rotate-" + System.currentTimeMillis())); + CountDownLatch latch = new CountDownLatch(100); + try (RemoteRecordingStream r = new RemoteRecordingStream(conn, p)) { + r.onEvent(e -> { + System.out.println(e); + latch.countDown(); + }); + r.startAsync(); + for (int i = 1; i <= 100; i++) { + TestRotateEvent e = new TestRotateEvent(); + e.value = i; + e.commit(); + if (i % 30 == 0) { + rotate(); + } + Thread.sleep(10); + } + System.out.println("Events generated. Awaiting consumption"); + latch.await(); + } + } + + private static void rotate() { + try (Recording r = new Recording()) { + r.start(); + } + } +} diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java b/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java new file mode 100644 index 00000000000..667ae5c8d5b --- /dev/null +++ b/test/jdk/jdk/jfr/jmx/streaming/TestSetSettings.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.jmx.streaming; + +import java.lang.management.ManagementFactory; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +import javax.management.MBeanServerConnection; + +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.StackTrace; +import jdk.management.jfr.RemoteRecordingStream; + +/** + * @test + * @key jfr + * @summary Tests that a RemoteRecordingStream can be configured using + * setSettings + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jmx.streaming.TestSetSettings + */ +public class TestSetSettings { + + @Enabled(false) + @StackTrace(false) + @Name("Event1") + static class Event1 extends Event { + } + + @Enabled(false) + @StackTrace(false) + @Name("Event2") + static class Event2 extends Event { + } + + public static void main(String... args) throws Exception { + CountDownLatch latch1 = new CountDownLatch(1); + CountDownLatch latch2 = new CountDownLatch(1); + + MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer(); + try (RemoteRecordingStream r = new RemoteRecordingStream(conn)) { + r.onEvent("Event1", e -> { + System.out.println("Found event: " + e.getEventType().getName()); + if (e.getStackTrace() == null) { + System.out.println("Missing strack trace"); + return; + } + latch1.countDown(); + }); + r.onEvent("Event2", e -> { + System.out.println("Found event: " + e.getEventType().getName()); + if (e.getStackTrace() == null) { + System.out.println("Missing strack trace"); + return; + } + latch2.countDown(); + }); + // Set settings before start + Map settings = new HashMap<>(); + settings.put("Event1#enabled", "true"); + settings.put("Event1#stackTrace", "true"); + r.setSettings(settings); + + r.startAsync(); + + Event1 e1 = new Event1(); + e1.commit(); + System.out.println("Awaiting latch 1"); + latch1.await(); + + // Set settings when running + settings = new HashMap<>(); + settings.put("Event2#enabled", "true"); + settings.put("Event2#stackTrace", "true"); + r.setSettings(settings); + Event2 e2 = new Event2(); + e2.commit(); + System.out.println("Awaiting latch 2"); + latch2.await(); + } + } +} diff --git a/test/jdk/jdk/jfr/tool/EndTicksComparator.java b/test/jdk/jdk/jfr/tool/EndTicksComparator.java new file mode 100644 index 00000000000..fb8d97d46e5 --- /dev/null +++ b/test/jdk/jdk/jfr/tool/EndTicksComparator.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.tool; + +import java.util.Comparator; +import jdk.jfr.consumer.RecordedEvent; + +public class EndTicksComparator implements Comparator { + public long readEndTicks(RecordedEvent event) { + long timestamp = event.getLong("startTime"); + if (event.hasField("duration")) { + timestamp += event.getLong("duration"); + } + return timestamp; + } + + @Override + public int compare(RecordedEvent a, RecordedEvent b) { + return Long.compare(readEndTicks(a), readEndTicks(b)); + } +} diff --git a/test/jdk/jdk/jfr/tool/TestPrintJSON.java b/test/jdk/jdk/jfr/tool/TestPrintJSON.java index 2e63a99d327..65cf0cff41e 100644 --- a/test/jdk/jdk/jfr/tool/TestPrintJSON.java +++ b/test/jdk/jdk/jfr/tool/TestPrintJSON.java @@ -65,13 +65,13 @@ public static void main(String... args) throws Throwable { JSONValue recording = o.get("recording"); JSONArray jsonEvents = recording.get("events").asArray(); List events = RecordingFile.readAllEvents(recordingFile); - Collections.sort(events, (e1, e2) -> e1.getEndTime().compareTo(e2.getEndTime())); + Collections.sort(events, new EndTicksComparator()); // Verify events are equal Iterator it = events.iterator(); for (JSONValue jsonEvent : jsonEvents) { RecordedEvent recordedEvent = it.next(); String typeName = recordedEvent.getEventType().getName(); - Asserts.assertEquals(typeName, jsonEvent.get("type").asString()); + Asserts.assertEquals(typeName, jsonEvent.get("type").asString()); assertEquals(jsonEvent, recordedEvent); } Asserts.assertFalse(events.size() != jsonEvents.size(), "Incorrect number of events"); @@ -80,7 +80,7 @@ public static void main(String... args) throws Throwable { private static void assertEquals(Object jsonObject, Object jfrObject) throws Exception { // Check object if (jfrObject instanceof RecordedObject) { - JSONValue values = ((JSONValue)jsonObject).get("values"); + JSONValue values = ((JSONValue) jsonObject).get("values"); RecordedObject recObject = (RecordedObject) jfrObject; Asserts.assertEquals(values.size(), recObject.getFields().size()); for (ValueDescriptor v : recObject.getFields()) { @@ -89,7 +89,7 @@ private static void assertEquals(Object jsonObject, Object jfrObject) throws Exc Object expectedValue = recObject.getValue(name); if (v.getAnnotation(Timestamp.class) != null) { // Make instant of OffsetDateTime - String text = ((JSONValue)jsonValue).asString(); + String text = ((JSONValue) jsonValue).asString(); jsonValue = OffsetDateTime.parse(text).toInstant().toString(); expectedValue = recObject.getInstant(name); } @@ -103,7 +103,7 @@ private static void assertEquals(Object jsonObject, Object jfrObject) throws Exc // Check array if (jfrObject != null && jfrObject.getClass().isArray()) { Object[] jfrArray = (Object[]) jfrObject; - JSONArray jsArray = ((JSONArray)jsonObject); + JSONArray jsArray = ((JSONArray) jsonObject); for (int i = 0; i < jfrArray.length; i++) { assertEquals(jsArray.get(i), jfrArray[i]); } diff --git a/test/jdk/jdk/jfr/tool/TestPrintXML.java b/test/jdk/jdk/jfr/tool/TestPrintXML.java index f84ee1372c4..54b32e2b167 100644 --- a/test/jdk/jdk/jfr/tool/TestPrintXML.java +++ b/test/jdk/jdk/jfr/tool/TestPrintXML.java @@ -96,7 +96,7 @@ public static void main(String... args) throws Throwable { // Verify that all data was written correctly List events = RecordingFile.readAllEvents(recordingFile); - Collections.sort(events, (e1, e2) -> e1.getEndTime().compareTo(e2.getEndTime())); + Collections.sort(events, new EndTicksComparator()); Iterator it = events.iterator(); for (XMLEvent xmlEvent : handler.events) { RecordedEvent re = it.next(); diff --git a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java index 23722c0c09f..4718e10e862 100644 --- a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java +++ b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java @@ -74,7 +74,7 @@ static void check(ModuleDescriptor md) { "jdk.internal.vm.ci/jdk.vm.ci.hotspot", "jdk.internal.vm.ci/jdk.vm.ci.meta", "jdk.internal.vm.ci/jdk.vm.ci.code", - "java.base/jdk.internal"); + "java.base/jdk.internal.javac"); static void checkExports(ModuleDescriptor md) { // build a map of upgradeable module to Exports that are qualified to it diff --git a/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java index efc69a610d0..d5994ce0add 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java @@ -95,7 +95,7 @@ public void testSetGetOptionServerSocketChannel() throws IOException { @Test public void testSocketChannel() throws Exception { - int socketID, clientID, tempID = 0; + int socketID, clientID, originalClientID = 0; boolean initialRun = true; try (var ss = AsynchronousServerSocketChannel.open()) { ss.bind(new InetSocketAddress(hostAddr, 0)); @@ -108,20 +108,21 @@ public void testSocketChannel() throws Exception { for (int i = 0; i < 10; i++) { s.write(ByteBuffer.wrap("test".getBytes())); + socketID = s.getOption(SO_INCOMING_NAPI_ID); assertEquals(socketID, 0, "AsynchronousSocketChannel: Sender"); - c.read(ByteBuffer.allocate(128)); + c.read(ByteBuffer.allocate(128)).get(); clientID = ss.getOption(SO_INCOMING_NAPI_ID); // check ID remains consistent if (initialRun) { assertTrue(clientID >= 0, "AsynchronousSocketChannel: Receiver"); - } else { - assertEquals(clientID, tempID); initialRun = false; + originalClientID = clientID; + } else { + assertEquals(clientID, originalClientID); } - tempID = clientID; } } } diff --git a/test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java b/test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java index f38aa0d0629..60fea1b9ac9 100644 --- a/test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java +++ b/test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java @@ -24,10 +24,12 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.*; import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.List; @@ -38,7 +40,7 @@ /** * @test - * @bug 8255380 + * @bug 8255380 8257445 * @summary Test that Zip FS can access the LOC offset from the Zip64 extra field * @modules jdk.zipfs * @requires (os.family == "linux") | (os.family == "mac") @@ -91,14 +93,29 @@ public static void createZipWithZip64Ext() { rc.assertSuccess(); } + /* + * DataProvider used to verify that a Zip file that contains a Zip64 Extra + * (EXT) header can be traversed + */ + @DataProvider(name = "zipInfoTimeMap") + protected Object[][] zipInfoTimeMap() { + return new Object[][]{ + {Map.of()}, + {Map.of("zipinfo-time", "False")}, + {Map.of("zipinfo-time", "true")}, + {Map.of("zipinfo-time", "false")} + }; + } + /** * Navigate through the Zip file entries using Zip FS + * @param env Zip FS properties to use when accessing the Zip file * @throws IOException if an error occurs */ - @Test - public void walkZipFSTest() throws IOException { + @Test(dataProvider = "zipInfoTimeMap") + public void walkZipFSTest(final Map env) throws IOException { try (FileSystem fs = - FileSystems.newFileSystem(Paths.get(ZIP_FILE_NAME), Map.of("zipinfo-time", "False"))) { + FileSystems.newFileSystem(Paths.get(ZIP_FILE_NAME), env)) { for (Path root : fs.getRootDirectories()) { Files.walkFileTree(root, new SimpleFileVisitor<>() { @Override diff --git a/test/jdk/jdk/security/logging/TestX509CertificateLog.java b/test/jdk/jdk/security/logging/TestX509CertificateLog.java index 215e62f4a3e..cbeb03039d1 100644 --- a/test/jdk/jdk/security/logging/TestX509CertificateLog.java +++ b/test/jdk/jdk/security/logging/TestX509CertificateLog.java @@ -58,9 +58,8 @@ public static void main(String[] args) throws Exception { public static class GenerateX509Certicate { public static void main(String[] args) throws Exception { - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - TestCertificate.ONE.generate(cf); - TestCertificate.TWO.generate(cf); + TestCertificate.ONE.certificate(); + TestCertificate.TWO.certificate(); } } } diff --git a/test/jdk/jdk/security/logging/TestX509ValidationLog.java b/test/jdk/jdk/security/logging/TestX509ValidationLog.java index 7fe659764b8..1963fd83294 100644 --- a/test/jdk/jdk/security/logging/TestX509ValidationLog.java +++ b/test/jdk/jdk/security/logging/TestX509ValidationLog.java @@ -43,14 +43,19 @@ public static void main(String[] args) throws Exception { l.addExpected("FINE: ValidationChain: " + TestCertificate.ROOT_CA.certId + ", " + TestCertificate.ROOT_CA.certId); + l.addExpected("FINE: ValidationChain: " + + TestCertificate.ROOT_CA.certificate().getPublicKey().hashCode() + + ", " + TestCertificate.ROOT_CA.certId); l.testExpected(); } public static class GenerateCertificateChain { public static void main(String[] args) throws Exception { - TestCertificate.generateChain(false); + TestCertificate.generateChain(false, true); // self signed test - TestCertificate.generateChain(true); + TestCertificate.generateChain(true, true); + // no cert for trust anchor + TestCertificate.generateChain(true, false); } } } diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicClassBuilder.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicClassBuilder.java index 0449628cb61..f2d807f1a8e 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicClassBuilder.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicClassBuilder.java @@ -32,6 +32,10 @@ public BasicClassBuilder(String thisClass, int majorVersion, int minorVersion) { withThisClass(thisClass); } + public BasicClassBuilder(BytePoolHelper poolHelper, TypeHelper typeHelper) { + super(poolHelper, typeHelper); + } + public BasicClassBuilder() { super(new BytePoolHelper<>(s->s, s->s), new BasicTypeHelper()); } diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicTypeHelper.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicTypeHelper.java index 42d5e6335b2..d66ceb1e9f1 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicTypeHelper.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BasicTypeHelper.java @@ -45,16 +45,27 @@ public String arrayOf(String s) { return "[" + s; } + @Override + public boolean isInlineClass(String t) { + return t.charAt(0) == 'Q' && t.endsWith(";"); + } + @Override public String type(String s) { return "L" + s + ";"; } + @Override + public String valueType(String s) { + return "Q" + s + ";"; + } + @Override public TypeTag tag(String s) { switch (s.charAt(0)) { case '[': case 'L': + case 'Q': return TypeTag.A; case 'B': case 'C': @@ -70,9 +81,10 @@ public TypeTag tag(String s) { return TypeTag.D; case 'V': return TypeTag.V; - case 'Q': - return TypeTag.Q; default: + if (s == nullType()) { + return TypeTag.A; + } throw new IllegalStateException("Bad type: " + s); } } diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java index 6461cdfb8f1..a79d09b412e 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java @@ -24,6 +24,7 @@ package jdk.experimental.bytecode; import java.lang.invoke.MethodHandleInfo; +import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -336,6 +337,11 @@ public int putClass(S symbol) { return putClassInternal(symbolToString.apply(symbol)); } + @Override + public int putInlineClass(S symbol) { + return putClassInternal("Q" + symbolToString.apply(symbol) + ";"); + } + private int putClassInternal(String symbol) { key.setClass(symbol); PoolKey poolKey = entries.lookup(key); diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/CodeBuilder.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/CodeBuilder.java index d16cd138fff..01057d6ce45 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/CodeBuilder.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/CodeBuilder.java @@ -99,14 +99,14 @@ public C getfield(S owner, CharSequence name, T type) { return thisBuilder(); } - public C vgetfield(S owner, CharSequence name, T type) { - emitOp(Opcode.VGETFIELD, type); + public C putfield(S owner, CharSequence name, T type) { + emitOp(Opcode.PUTFIELD, type); code.writeChar(poolHelper.putFieldRef(owner, name, type)); return thisBuilder(); } - public C putfield(S owner, CharSequence name, T type) { - emitOp(Opcode.PUTFIELD, type); + public C withfield(S owner, CharSequence name, T type) { + emitOp(Opcode.WITHFIELD, type); code.writeChar(poolHelper.putFieldRef(owner, name, type)); return thisBuilder(); } @@ -155,15 +155,9 @@ public C new_(S clazz) { return thisBuilder(); } - public C vnew_(S clazz, CharSequence name, T desc) { - emitOp(Opcode.VNEW, clazz); - code.writeChar(poolHelper.putMethodRef(clazz, name, desc, false)); - return thisBuilder(); - } - - public C vnewarray(S array) { - emitOp(Opcode.VNEWARRAY, array); - code.writeChar(poolHelper.putClass(array)); + public C defaultvalue(S clazz) { + emitOp(Opcode.DEFAULTVALUE, clazz); + code.writeChar(poolHelper.putClass(clazz)); return thisBuilder(); } @@ -201,24 +195,6 @@ public C multianewarray(S array, byte dims) { return thisBuilder(); } - public C multivnewarray(S array, byte dims) { - emitOp(Opcode.MULTIVNEWARRAY, new Object[]{array, dims}); - code.writeChar(poolHelper.putClass(array)).writeByte(dims); - return thisBuilder(); - } - - public C vbox(S target) { - emitOp(Opcode.VBOX, target); - code.writeChar(poolHelper.putClass(target)); - return thisBuilder(); - } - - public C vunbox(S target) { - emitOp(Opcode.VUNBOX, target); - code.writeChar(poolHelper.putClass(target)); - return thisBuilder(); - } - public C ldc(int i) { return ldc(pool -> pool.putInt(i), false); } @@ -293,10 +269,6 @@ public C return_() { return emitOp(Opcode.RETURN); } - public C vreturn() { - return emitOp(Opcode.VRETURN); - } - protected C emitWideIfNeeded(Opcode opcode, int n) { boolean wide = n > Byte.MAX_VALUE; if (wide) { @@ -325,90 +297,6 @@ protected C emitWideIfNeeded(Opcode opcode, int n, int v) { return thisBuilder(); } - public TypedBuilder typed(TypeTag typeTag) { - return typed(typeTag, _unused -> new TypedBuilder()); - } - - protected TB typed(TypeTag typeTag, Function typedBuilderFunc) { - emitOp(Opcode.TYPED); - code.writeChar(poolHelper.putType(typeHelper.fromTag(typeTag))); - return typedBuilderFunc.apply(typeTag); - } - - public class TypedBuilder { - public C aload_0() { - return CodeBuilder.this.aload_0(); - } - - public C aload_1() { - return CodeBuilder.this.aload_1(); - } - - public C aload_2() { - return CodeBuilder.this.aload_2(); - } - - public C aload_3() { - return CodeBuilder.this.aload_3(); - } - - public C aload(int n) { - return CodeBuilder.this.aload(n); - } - - public C astore_0() { - return CodeBuilder.this.astore_0(); - } - - public C astore_1() { - return CodeBuilder.this.astore_1(); - } - - public C astore_2() { - return CodeBuilder.this.astore_2(); - } - - public C astore_3() { - return CodeBuilder.this.astore_3(); - } - - public C astore(int n) { - return CodeBuilder.this.astore(n); - } - - public C aaload() { - return CodeBuilder.this.aaload(); - } - - public C aastore() { - return CodeBuilder.this.aastore(); - } - - public C areturn() { - return CodeBuilder.this.areturn(); - } - - public C anewarray(S s) { - return CodeBuilder.this.anewarray(s); - } - - public C aconst_null() { - return CodeBuilder.this.aconst_null(); - } - - public C if_acmpeq(short target) { - return CodeBuilder.this.if_acmpeq(target); - } - - public C if_acmpne(short target) { - return CodeBuilder.this.if_acmpeq(target); - } - } - - public C vload(int i) { - return emitWideIfNeeded(Opcode.VLOAD, i); - } - public C aload(int i) { return emitWideIfNeeded(Opcode.ALOAD, i); } @@ -509,10 +397,6 @@ public C dload_3() { return emitOp(Opcode.DLOAD_3); } - public C vstore(int i) { - return emitWideIfNeeded(Opcode.VSTORE, i); - } - public C astore(int i) { return emitWideIfNeeded(Opcode.ASTORE, i); } @@ -631,10 +515,6 @@ public C daload() { return emitOp(Opcode.DALOAD); } - public C vaload() { - return emitOp(Opcode.VALOAD); - } - public C aaload() { return emitOp(Opcode.AALOAD); } @@ -667,10 +547,6 @@ public C dastore() { return emitOp(Opcode.DASTORE); } - public C vastore() { - return emitOp(Opcode.VASTORE); - } - public C aastore() { return emitOp(Opcode.AASTORE); } @@ -1280,7 +1156,8 @@ private void writeStackMapType(T t) { } else { //TODO: uninit this, top? stackmaps.writeByte(7); - stackmaps.writeChar(poolHelper.putClass(typeHelper.symbol(t))); + stackmaps.writeChar(typeHelper.isInlineClass(t) ? + poolHelper.putInlineClass(typeHelper.symbol(t)) : poolHelper.putClass(typeHelper.symbol(t))); } break; default: diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Flag.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Flag.java index 47da97ab1a6..3dd647cc209 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Flag.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Flag.java @@ -43,6 +43,7 @@ public enum Flag { ACC_BRIDGE(0x0040), ACC_VARARGS(0x0080), ACC_NATIVE(0x0100), + ACC_INLINE(0x0100), ACC_STRICT(0x0800); public int flag; diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/IsolatedMethodBuilder.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/IsolatedMethodBuilder.java index 7d84af52263..9b7ea90b1b8 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/IsolatedMethodBuilder.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/IsolatedMethodBuilder.java @@ -53,6 +53,11 @@ public int putClass(Class symbol) { return putIfAbsent(symbol); } + @Override + public int putInlineClass(Class symbol) { + return putIfAbsent(symbol); + } + @Override public int putFieldRef(Class owner, CharSequence name, String type) { try { diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/MacroCodeBuilder.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/MacroCodeBuilder.java index 4cd50cc8789..ed8953bbb40 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/MacroCodeBuilder.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/MacroCodeBuilder.java @@ -115,40 +115,32 @@ public MacroCodeBuilder(MethodBuilder methodBuilder) { } public C load(TypeTag type, int n) { - if (type == TypeTag.Q) { - return vload(n); - } else { - switch (n) { - case 0: - return emitOp(Opcode.ILOAD_0.at(type, 4)); - case 1: - return emitOp(Opcode.ILOAD_1.at(type, 4)); - case 2: - return emitOp(Opcode.ILOAD_2.at(type, 4)); - case 3: - return emitOp(Opcode.ILOAD_3.at(type, 4)); - default: - return emitWideIfNeeded(Opcode.ILOAD.at(type), n); - } + switch (n) { + case 0: + return emitOp(Opcode.ILOAD_0.at(type, 4)); + case 1: + return emitOp(Opcode.ILOAD_1.at(type, 4)); + case 2: + return emitOp(Opcode.ILOAD_2.at(type, 4)); + case 3: + return emitOp(Opcode.ILOAD_3.at(type, 4)); + default: + return emitWideIfNeeded(Opcode.ILOAD.at(type), n); } } public C store(TypeTag type, int n) { - if (type == TypeTag.Q) { - return vstore(n); - } else { - switch (n) { - case 0: - return emitOp(Opcode.ISTORE_0.at(type, 4)); - case 1: - return emitOp(Opcode.ISTORE_1.at(type, 4)); - case 2: - return emitOp(Opcode.ISTORE_2.at(type, 4)); - case 3: - return emitOp(Opcode.ISTORE_3.at(type, 4)); - default: - return emitWideIfNeeded(Opcode.ISTORE.at(type), n); - } + switch (n) { + case 0: + return emitOp(Opcode.ISTORE_0.at(type, 4)); + case 1: + return emitOp(Opcode.ISTORE_1.at(type, 4)); + case 2: + return emitOp(Opcode.ISTORE_2.at(type, 4)); + case 3: + return emitOp(Opcode.ISTORE_3.at(type, 4)); + default: + return emitWideIfNeeded(Opcode.ISTORE.at(type), n); } } @@ -308,29 +300,13 @@ public C xor(TypeTag type) { public C return_(TypeTag type) { switch (type) { case V: - return return_(); case Q: - return vreturn(); + return return_(); default: return emitOp(Opcode.IRETURN.at(type)); } } - @Override - public LabelledTypedBuilder typed(TypeTag typeTag) { - return super.typed(typeTag, _unused -> new LabelledTypedBuilder()); - } - - public class LabelledTypedBuilder extends TypedBuilder { - public C if_acmpeq(CharSequence target) { - return ifcmp(TypeTag.A, CondKind.EQ, target); - } - - public C if_acmpne(CharSequence target) { - return ifcmp(TypeTag.A, CondKind.NE, target); - } - } - public C conv(TypeTag from, TypeTag to) { switch (from) { case B: diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Opcode.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Opcode.java index d3fa013e650..6dcc3367f0c 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Opcode.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/Opcode.java @@ -229,18 +229,9 @@ public enum Opcode { IF_NONNULL(199), GOTO_W(200), JSR_W(201), - VLOAD(203), - VSTORE(204), - VALOAD(205), - VASTORE(206), - VNEW(207), - VNEWARRAY(208), - MULTIVNEWARRAY(209), - VRETURN(210), - VGETFIELD(211), - TYPED(212), - VBOX(216), - VUNBOX(217); + DEFAULTVALUE(203), + WITHFIELD(204); + int code; diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/PoolHelper.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/PoolHelper.java index d85579635e1..4ab14782721 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/PoolHelper.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/PoolHelper.java @@ -36,6 +36,8 @@ public interface PoolHelper { int putClass(S symbol); + int putInlineClass(S symbol); + int putFieldRef(S owner, CharSequence name, T type); int putMethodRef(S owner, CharSequence name, T type, boolean isInterface); diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypeHelper.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypeHelper.java index fedb6043209..11250cb1541 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypeHelper.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypeHelper.java @@ -83,6 +83,24 @@ public interface TypeHelper { */ T type(S s); + /** + * Return true if the parameter is a value type. + * + * @param t the type descreiptor + * @return true if the given type is a value type + */ + boolean isInlineClass(T t); + + /** + * For a symbol that corresponds to a value type, return the type descriptor. + * + * @param s the symbol + * @return the type descriptor + */ + default T valueType(S s) { + return type(s); + } + /** * Return the symbol corresponding to a type descriptor. * diff --git a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypedCodeBuilder.java b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypedCodeBuilder.java index dc82ad67af3..407bcff3658 100644 --- a/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypedCodeBuilder.java +++ b/test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/TypedCodeBuilder.java @@ -137,95 +137,6 @@ public SwitchBuilder withDefault(Consumer defaultCase) { } } - @Override - public StatefulTypedBuilder typed(TypeTag tag) { - return super.typed(tag, StatefulTypedBuilder::new); - } - - public class StatefulTypedBuilder extends LabelledTypedBuilder { - - TypeTag tag; - - StatefulTypedBuilder(TypeTag tag) { - this.tag = tag; - } - - @Override - public C astore_0() { - return storeAndUpdate(super::astore_0); - } - - @Override - public C astore_1() { - return storeAndUpdate(super::astore_1); - } - - @Override - public C astore_2() { - return storeAndUpdate(super::astore_2); - } - - @Override - public C astore_3() { - return storeAndUpdate(super::astore_3); - } - - @Override - public C astore(int n) { - return storeAndUpdate(() -> super.astore(n)); - } - - @Override - public C aastore() { - return storeAndUpdate(super::aastore); - } - - @Override - public C areturn() { - state.pop(tag); - state.push(typeHelper.nullType()); - return super.areturn(); - } - - @Override - public C anewarray(S s) { - super.anewarray(s); - state.pop(); - state.push(typeHelper.arrayOf(typeHelper.type(s))); - return thisBuilder(); - } - - @Override - public C aconst_null() { - super.aconst_null(); - state.pop(); - state.push(tag); - return thisBuilder(); - } - - public C if_acmpeq(CharSequence label) { - return jumpAndUpdate(() -> super.if_acmpeq(label)); - } - - public C if_acmpne(CharSequence label) { - return jumpAndUpdate(() -> super.if_acmpne(label)); - } - - private C storeAndUpdate(Supplier op) { - state.pop(tag); - state.push(typeHelper.nullType()); - return op.get(); - } - - private C jumpAndUpdate(Supplier op) { - state.pop(tag); - state.pop(tag); - state.push(typeHelper.nullType()); - state.push(typeHelper.nullType()); - return op.get(); - } - } - public class State { public final ArrayList stack; public final Vector locals; @@ -386,7 +297,6 @@ int width(T o) { @SuppressWarnings("unchecked") public void updateState(Opcode op, Object optValue) { switch (op) { - case VALOAD: case AALOAD: state.pop(); state.push(typeHelper.elemtype(state.pop())); @@ -395,6 +305,7 @@ public void updateState(Opcode op, Object optValue) { state.alive = false; break; case NOP: + case IINC: case INEG: case LNEG: case FNEG: @@ -458,7 +369,6 @@ public void updateState(Opcode op, Object optValue) { case ALOAD: case LLOAD: case DLOAD: - case VLOAD: state.push(state.locals.get((Integer) optValue)); break; case IALOAD: @@ -507,7 +417,6 @@ public void updateState(Opcode op, Object optValue) { case ISTORE: case FSTORE: case ASTORE: - case VSTORE: state.load(state.pop(), (int) optValue); break; case LSTORE_0: @@ -536,7 +445,6 @@ public void updateState(Opcode op, Object optValue) { case LUSHR: state.pop(); break; - case VRETURN: case ARETURN: case IRETURN: case FRETURN: @@ -576,7 +484,6 @@ public void updateState(Opcode op, Object optValue) { state.pop(); state.push(TypeTag.I); break; - case VASTORE: case AASTORE: state.pop(); state.pop(); @@ -823,8 +730,8 @@ public void updateState(Opcode op, Object optValue) { case MONITOREXIT: state.pop(); break; - case VNEW: case NEW: + case DEFAULTVALUE: state.push(typeHelper.type((S) optValue)); break; case NEWARRAY: @@ -835,13 +742,6 @@ public void updateState(Opcode op, Object optValue) { state.pop(); state.push(typeHelper.arrayOf(typeHelper.arrayOf(typeHelper.type((S)optValue)))); break; - case VNEWARRAY: - case VBOX: - case VUNBOX: - state.pop(); - state.push(typeHelper.type((S) optValue)); - break; - case MULTIVNEWARRAY: case MULTIANEWARRAY: for (int i = 0; i < (byte) ((Object[]) optValue)[1]; i++) { state.pop(); @@ -858,7 +758,6 @@ public void updateState(Opcode op, Object optValue) { case GETSTATIC: state.push((T) optValue); break; - case VGETFIELD: case GETFIELD: state.pop(); state.push((T) optValue); @@ -882,6 +781,15 @@ public void updateState(Opcode op, Object optValue) { state.pop(); break; } + case WITHFIELD: { + TypeTag tag = typeHelper.tag((T) optValue); + if (tag.width == 1) { + state.pop(); + } else { + state.pop2(); + } + break; + } case BIPUSH: case SIPUSH: state.push(TypeTag.I); @@ -916,7 +824,6 @@ public void updateState(Opcode op, Object optValue) { state.pop(); state.push(TypeTag.Z); break; - case TYPED: case CHECKCAST: break; @@ -964,6 +871,11 @@ public int putClass(S symbol) { return poolHelper.putClass(symbol); } + @Override + public int putInlineClass(S symbol) { + throw new IllegalStateException(); + } + @Override public int putInt(int i) { type = typeHelper.fromTag(TypeTag.I); diff --git a/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java b/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java index 61af1db93a9..474aab56cad 100644 --- a/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java +++ b/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java @@ -35,10 +35,11 @@ import java.util.HashMap; import java.util.Map; import java.util.zip.ZipFile; -import jdk.security.jarsigner.JarSigner; +import java.io.File; -import jdk.test.lib.util.JarBuilder; +import jdk.security.jarsigner.JarSigner; import jdk.test.lib.compiler.Compiler; +import jdk.test.lib.util.JarBuilder; public class CreateMultiReleaseTestJars { final private String main = diff --git a/test/jdk/lib/testlibrary/java/util/jar/SimpleHttpServer.java b/test/jdk/lib/testlibrary/java/util/jar/SimpleHttpServer.java deleted file mode 100644 index 839bebaf62e..00000000000 --- a/test/jdk/lib/testlibrary/java/util/jar/SimpleHttpServer.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import com.sun.net.httpserver.*; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -/** - * Extremely simple server that only performs one task. The server listens for - * requests on the ephemeral port. If it sees a request that begins with - * "/multi-release.jar", it consumes the request and returns a stream of bytes - * representing the jar file multi-release.jar found in "userdir". - */ -class SimpleHttpServer { - private static final String userdir = System.getProperty("user.dir", "."); - private static final Path multirelease = Paths.get(userdir, "multi-release.jar"); - - private final HttpServer server; - private final InetAddress address; - - public SimpleHttpServer() throws IOException { - this(null); - } - - public SimpleHttpServer(InetAddress addr) throws IOException { - address = addr; - server = HttpServer.create(); - } - - public void start() throws IOException { - server.bind(new InetSocketAddress(address, 0), 0); - server.createContext("/multi-release.jar", t -> { - try (InputStream is = t.getRequestBody()) { - is.readAllBytes(); // probably not necessary to consume request - byte[] bytes = Files.readAllBytes(multirelease); - t.sendResponseHeaders(200, bytes.length); - try (OutputStream os = t.getResponseBody()) { - os.write(bytes); - } - } - }); - server.setExecutor(null); // creates a default executor - server.start(); - } - - public void stop() { - server.stop(0); - } - - int getPort() { - return server.getAddress().getPort(); - } -} - diff --git a/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java b/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java index 2bb2571276a..ee7c3a98ad4 100644 --- a/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java +++ b/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +29,10 @@ import javax.swing.UIManager; import static org.testng.AssertJUnit.*; + +import org.netbeans.jemmy.drivers.DriverManager; +import org.netbeans.jemmy.drivers.scrolling.KeyboardJSliderScrollDriver; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.netbeans.jemmy.ClassReference; import org.netbeans.jemmy.ComponentChooser; @@ -68,6 +71,11 @@ public class SliderDemoTest { private static final int VERTICAL_MINOR_TICKS_SLIDER_MINIMUM = 0; private static final int VERTICAL_MINOR_TICKS_SLIDER_MAXIMUM = 100; + @BeforeClass + public void useKeyboardSliderDriver() { + DriverManager.setScrollDriver(new KeyboardJSliderScrollDriver()); + } + @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class) public void test(String lookAndFeel) throws Exception { UIManager.setLookAndFeel(lookAndFeel); @@ -139,70 +147,81 @@ private void disabled(JFrameOperator jfo, String accessibleName) private void checkMaximum(JSliderOperator jso, int maxValue) { jso.scrollToMaximum(); - waitSliderValue(jso, jSlider -> jSlider.getValue() == maxValue); + waitSliderValue(jso, jSlider -> jSlider.getValue() == maxValue, + "value == " + maxValue); } private void checkMinimum(JSliderOperator jso, int minValue) { jso.scrollToMinimum(); - waitSliderValue(jso, jSlider -> jSlider.getValue() == minValue); + waitSliderValue(jso, jSlider -> jSlider.getValue() == minValue, + "value == " + minValue); } private void checkKeyboard(JSliderOperator jso) { boolean isMotif = LookAndFeel.isMotif(); checkKeyPress(jso, KeyEvent.VK_HOME, - jSlider -> jSlider.getValue() == jso.getMinimum()); + jSlider -> jSlider.getValue() == jso.getMinimum(), + "value == " + jso.getMinimum()); { int expectedValue = jso.getValue() + 1; checkKeyPress(jso, KeyEvent.VK_UP, - jSlider -> jSlider.getValue() >= expectedValue); + jSlider -> jSlider.getValue() >= expectedValue, + "value >= " + expectedValue); } { int expectedValue = jso.getValue() + 1; checkKeyPress(jso, KeyEvent.VK_RIGHT, - jSlider -> jSlider.getValue() >= expectedValue); + jSlider -> jSlider.getValue() >= expectedValue, + "value >= " + expectedValue); } if (!isMotif) { int expectedValue = jso.getValue() + 11; checkKeyPress(jso, KeyEvent.VK_PAGE_UP, - jSlider -> jSlider.getValue() >= expectedValue); + jSlider -> jSlider.getValue() >= expectedValue, + "value >= " + expectedValue); } checkKeyPress(jso, KeyEvent.VK_END, - jSlider -> jSlider.getValue() == jso.getMaximum()); + jSlider -> jSlider.getValue() == jso.getMaximum(), + "value == " + jso.getMaximum()); { int expectedValue = jso.getValue() - 1; checkKeyPress(jso, KeyEvent.VK_DOWN, - jSlider -> jSlider.getValue() <= expectedValue); + jSlider -> jSlider.getValue() <= expectedValue, + "value <= " + expectedValue); } { int expectedValue = jso.getValue() - 1; checkKeyPress(jso, KeyEvent.VK_LEFT, - jSlider -> jSlider.getValue() <= expectedValue); + jSlider -> jSlider.getValue() <= expectedValue, + "value <= " + expectedValue); } if (!isMotif) { int expectedValue = jso.getValue() - 11; checkKeyPress(jso, KeyEvent.VK_PAGE_DOWN, - jSlider -> jSlider.getValue() <= expectedValue); + jSlider -> jSlider.getValue() <= expectedValue, + "value <= " + expectedValue); } } private void checkKeyPress(JSliderOperator jso, int keyCode, - Predicate predicate) { + Predicate predicate, + String description) { jso.pushKey(keyCode); - waitSliderValue(jso, predicate); + waitSliderValue(jso, predicate, description); } private void waitSliderValue(JSliderOperator jso, - Predicate predicate) { + Predicate predicate, String description) { jso.waitState(new ComponentChooser() { public boolean checkComponent(Component comp) { return predicate.test(jso); } public String getDescription() { - return "Wait till Slider attains the specified state."; + return description; } }); } @@ -211,14 +230,16 @@ private void checkMoveForward(JSliderOperator jso, int value) { jso.setValue(jso.getMinimum()); int finalValue = jso.getValue() + value; jso.scrollToValue(finalValue); - waitSliderValue(jso, jSlider -> jSlider.getValue() == finalValue); + waitSliderValue(jso, jSlider -> jSlider.getValue() == finalValue, + "value == " + finalValue); } private void checkSnapToTick(JSliderOperator jso, int expectedLower, int expectedHigher) { jso.pressMouse(jso.getCenterXForClick(), jso.getCenterYForClick()); waitSliderValue(jso, jSlider -> jSlider.getValue() == expectedLower - || jSlider.getValue() == expectedHigher); + || jSlider.getValue() == expectedHigher, + "value is either" + expectedLower + " or " + expectedHigher); jso.releaseMouse(); } @@ -230,13 +251,15 @@ private void checkMouse(JSliderOperator jso) { jso.setValue((jso.getMaximum() + jso.getMinimum()) / 2); jso.pressMouse(jso.getCenterXForClick(), jso.getCenterYForClick()); jso.dragMouse(jso.getWidth() + 10, jso.getHeight()); - waitSliderValue(jso, jSlider -> jSlider.getValue() == jSlider.getMaximum()); + waitSliderValue(jso, jSlider -> jSlider.getValue() == jSlider.getMaximum(), + "value == " + jso.getMaximum()); jso.releaseMouse(); // Check mouse click by clicking on the center of the track 2 times // and waiting till the slider value has changed from its previous // value as a result of the clicks. jso.clickMouse(jso.getCenterXForClick(), jso.getCenterYForClick(), 2); - waitSliderValue(jso, jSlider -> jSlider.getValue() != jSlider.getMaximum()); + waitSliderValue(jso, jSlider -> jSlider.getValue() != jSlider.getMaximum(), + "value != " + jso.getMaximum()); } } diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java index 4748fbc107a..0ae044b3fc2 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java @@ -24,8 +24,6 @@ */ package org.netbeans.jemmy.drivers; -import javax.swing.UIManager; - import org.netbeans.jemmy.ClassReference; import org.netbeans.jemmy.JemmyException; import org.netbeans.jemmy.JemmyProperties; @@ -41,7 +39,7 @@ import org.netbeans.jemmy.drivers.menus.DefaultJMenuDriver; import org.netbeans.jemmy.drivers.menus.QueueJMenuDriver; import org.netbeans.jemmy.drivers.scrolling.JScrollBarDriver; -import org.netbeans.jemmy.drivers.scrolling.KeyboardJSliderScrollDriver; +import org.netbeans.jemmy.drivers.scrolling.JSliderDriver; import org.netbeans.jemmy.drivers.scrolling.JSplitPaneDriver; import org.netbeans.jemmy.drivers.scrolling.ScrollPaneDriver; import org.netbeans.jemmy.drivers.scrolling.ScrollbarDriver; @@ -110,7 +108,7 @@ public DefaultDriverInstaller(boolean shortcutEvents) { new ScrollPaneDriver(), new JScrollBarDriver(), new JSplitPaneDriver(), - new KeyboardJSliderScrollDriver(), + new JSliderDriver(), createSpinnerDriver(), new ButtonMouseDriver(), new JTabMouseDriver(), diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/ComponentOperator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/ComponentOperator.java index b939005276e..99a076b7b4d 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/ComponentOperator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/ComponentOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,8 @@ import org.netbeans.jemmy.drivers.KeyDriver; import org.netbeans.jemmy.drivers.MouseDriver; +import javax.accessibility.AccessibleContext; + /** * Root class for all component operators. * @@ -122,6 +124,20 @@ public class ComponentOperator extends Operator */ public static final String NAME_DPROP = "Name:"; + /** + * Identifier for a name property. + * + * @see #getDump + */ + public static final String ACCESSIBLE_NAME_DPROP = "Accessible name:"; + + /** + * Identifier for a name property. + * + * @see #getDump + */ + public static final String ACCESSIBLE_DESCRIPTION_DPROP = "Accessible description:"; + /** * Identifier for a visible property. * @@ -1222,7 +1238,7 @@ public String toString() { /** * Wait till the component reaches exact location on screen. * - * @param exactLocation exact expected screen location. + * @param exactlocation exact expected screen location. */ public void waitComponentLocationOnScreen(Point exactlocation) { waitComponentLocationOnScreen(exactlocation, exactlocation); @@ -1270,6 +1286,15 @@ public Hashtable getDump() { if (getSource().getName() != null) { result.put(NAME_DPROP, getSource().getName()); } + AccessibleContext context = source.getAccessibleContext(); + if(context != null) { + if(context.getAccessibleName() != null) { + result.put(ACCESSIBLE_NAME_DPROP, context.getAccessibleName()); + } + if(context.getAccessibleDescription() != null) { + result.put(ACCESSIBLE_DESCRIPTION_DPROP, context.getAccessibleDescription()); + } + } result.put(IS_VISIBLE_DPROP, getSource().isVisible() ? "true" : "false"); result.put(IS_SHOWING_DPROP, getSource().isShowing() ? "true" : "false"); result.put(X_DPROP, Integer.toString(getSource().getX())); diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java index cc9fef5683d..21a9f63c8d1 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java @@ -43,6 +43,7 @@ import javax.swing.JTextField; import javax.swing.JToggleButton; import javax.swing.ListModel; +import javax.swing.UIManager; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileView; @@ -341,18 +342,18 @@ public String toString() { * @return a component being used to display directory content. */ public Component getFileList() { - int index = 0; - // In GTK and Motif L&F, there are two JLists, one is to list folders - // and second one one is to list files + final String fileListName; if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) { - index =1; + fileListName = UIManager.getString("FileChooser.filesLabelText", getLocale()); + } else { + fileListName = UIManager.getString("FileChooser.filesListAccessibleName", getLocale()); } return innerSearcher. findComponent(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { - return (comp != null - && (comp instanceof JList || comp instanceof JTable)); + return ((comp instanceof JList && fileListName.equals(comp.getAccessibleContext().getAccessibleName())) + || comp instanceof JTable); } @Override @@ -364,7 +365,7 @@ public String getDescription() { public String toString() { return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}'; } - }, index); + }); } /** diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JTextComponentOperator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JTextComponentOperator.java index daa26904e06..09d136f9125 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JTextComponentOperator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JTextComponentOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -828,10 +828,8 @@ public String toString() { public Hashtable getDump() { Hashtable result = super.getDump(); result.put(TEXT_DPROP, ((JTextComponent) getSource()).getText()); - if (((JTextComponent) getSource()).getSelectedText() != null - && !((JTextComponent) getSource()).getSelectedText().equals("")) { - result.put(SELECTED_TEXT_DPROP, ((JTextComponent) getSource()).getSelectedText()); - } + String selected = ((JTextComponent) getSource()).getSelectedText(); + result.put(SELECTED_TEXT_DPROP, (selected != null) ? selected : ""); result.put(IS_EDITABLE_DPROP, ((JTextComponent) getSource()).isEditable() ? "true" : "false"); return result; } diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JToolTipOperator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JToolTipOperator.java index 23093725756..5252b49db83 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JToolTipOperator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JToolTipOperator.java @@ -320,9 +320,8 @@ public String toString() { try { return stateWaiter.waitAction(null); } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw (new JemmyException("Waiting of " + waitable.getDescription() - + " state has been interrupted!")); + throw new JemmyException("Waiting of " + waitable.getDescription() + + " state has been interrupted!"); } } diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java index 3ea68794ed2..840362b73bd 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java @@ -720,10 +720,9 @@ public R waitState(Waitable waitable) { try { return stateWaiter.waitAction(null); } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw (new JemmyException( + throw new JemmyException( "Waiting of \"" + waitable.getDescription() - + "\" state has been interrupted!")); + + "\" state has been interrupted!"); } } @@ -735,14 +734,22 @@ public R waitState(Waitable waitable) { * defined by {@code "ComponentOperator.WaitStateTimeout"} */ public void waitStateOnQueue(final ComponentChooser state) { - waitState((comp) -> { - return (boolean) (queueTool.invokeSmoothly( - new QueueTool.QueueAction("checkComponent") { - @Override - public final Object launch() throws Exception { - return state.checkComponent(comp); - } - })); + waitState(new ComponentChooser() { + @Override + public boolean checkComponent(Component comp) { + return (boolean) (queueTool.invokeSmoothly( + new QueueTool.QueueAction("checkComponent") { + @Override + public final Object launch() throws Exception { + return state.checkComponent(comp); + } + })); + } + + @Override + public String getDescription() { + return state.getDescription(); + } }); } diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/TextComponentOperator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/TextComponentOperator.java index f61f926aa16..5a698b1a9a2 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/TextComponentOperator.java +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/TextComponentOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,13 @@ public class TextComponentOperator extends ComponentOperator */ public static final String TEXT_DPROP = "Text"; + /** + * Identifier for a "selected text" property. + * + * @see #getDump + */ + public static final String SELECTED_TEXT_DPROP = "Selected text"; + private final static long PUSH_KEY_TIMEOUT = 0; private final static long BETWEEN_KEYS_TIMEOUT = 0; private final static long CHANGE_CARET_POSITION_TIMEOUT = 60000; @@ -505,6 +512,8 @@ public String toString() { public Hashtable getDump() { Hashtable result = super.getDump(); result.put(TEXT_DPROP, ((TextComponent) getSource()).getText()); + String selected = ((TextComponent) getSource()).getSelectedText(); + result.put(SELECTED_TEXT_DPROP, (selected != null) ? selected : ""); return result; } diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info index 0aad8115cf9..a972d329c23 100644 --- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info +++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info @@ -1,6 +1,6 @@ Manifest-version: 1.0 Main-Class: org.netbeans.jemmy.JemmyProperties Jemmy-MajorVersion: 3.0 -Jemmy-MinorVersion: 8.0 +Jemmy-MinorVersion: 11.0 Jemmy-Build: @BUILD_NUMBER@ diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java new file mode 100644 index 00000000000..247502e6e6c --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8256421 + * @summary Interoperability tests with Harica CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath HaricaCA OCSP + * @run main/othervm -Djava.security.debug=certpath HaricaCA CRL + */ + +/* + * Obtain test artifacts for Harica CA from: + * + * CA has no published test sites so we will need to communicate with CA for test. + */ +public class HaricaCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + boolean ocspEnabled = false; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + ocspEnabled = true; + } + + new Harica_CA().runTest(pathValidator, ocspEnabled); + new Harica_ECC().runTest(pathValidator, ocspEnabled); + } +} + +class Harica_CA { + + // Owner: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions RootCA 2015, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 1bc8b59e0cea0b7c + // Valid from: Fri Apr 08 00:37:41 PDT 2016 until: Sat Apr 06 00:37:41 PDT 2024 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIHnjCCBYagAwIBAgIIG8i1ngzqC3wwDQYJKoZIhvcNAQELBQAwgaYxCzAJBgNV\n" + + "BAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFjYWRl\n" + + "bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAw\n" + + "PgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRp\n" + + "b25zIFJvb3RDQSAyMDE1MB4XDTE2MDQwODA3Mzc0MVoXDTI0MDQwNjA3Mzc0MVow\n" + + "ga0xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxl\n" + + "bmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0\n" + + "aG9yaXR5MUcwRQYDVQQDEz5IZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2gg\n" + + "SW5zdGl0dXRpb25zIENvZGUgU2lnbmluZyBDQSBSMTCCAiIwDQYJKoZIhvcNAQEB\n" + + "BQADggIPADCCAgoCggIBAJYQhJz8QjfP1wOc1sHxTKe9wy7d3oBScTslX5Yn1IE8\n" + + "j5SzsKilvbu9rp8bd8IKHnPrl1Vnjpvna/Vx/XKlXDxnIxgfLINfmbjJRoEbzj1t\n" + + "fxdTnZSN5c6vHYr5112/XCr2VQ7gIL+2jujXlJQYs/aUzAb9RR35dy4z2tQJQwtA\n" + + "gG/paNGgnOU2ROrcaEYfvG4YQWaHAwqjJ53ZY5HVD7NmLp5SZTA5Q3eHAYae99fq\n" + + "iEgMti3zMejzrAM1h+iVpLUxA7iMFh5nwCOvYJWVYqN3YOEmksxh7HOWlpe1PgDT\n" + + "5SezPCHmOilNizMSRsdW7fE8apYVq/O0yStFW32kS9RQzYiBsdgPvNzDGec7Jj8X\n" + + "SozhS6to+A6RdgfpHccHc2jhIRkFocA63OEde3Eo/NPf/WbFX2tpgDIv+HF/YZV3\n" + + "iaMeKeOKDIxa4c3t3qBsZNtFEGOQyDouVH4g2Y8gHhUCcR7gQrHEYy/9FbtUDviu\n" + + "abBVPFnNbEwT0uKS20aLgldkJ4/b3UzeTVzXVwLB8ruBfZX/e60YFaUJAZbbYRbE\n" + + "mD6KmDOCTfalpBRhXar6U1wf+GRp1wv01Vw88EJ6VEBxXAYrfQ28ER9IuLqVQRlN\n" + + "xpZCP71DRCvWljkXAKvWrs3JAw926n5K7sL+fv6mn+6iGBHrSEcyX8g8EZv6XuLP\n" + + "AgMBAAGjggHFMIIBwTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAT\n" + + "BgNVHSUEDDAKBggrBgEFBQcDAzAdBgNVHQ4EFgQUDyz8Ez5xsy3SqelOr4FBCaaY\n" + + "3UgwRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NybHYxLmhhcmljYS5nci9IYXJp\n" + + "Y2FSb290Q0EyMDE1L2NybHYxLmRlci5jcmwwHwYDVR0jBBgwFoAUcRVnyMjJvXVd\n" + + "ctA4GGqd83EkVAswbgYIKwYBBQUHAQEEYjBgMCEGCCsGAQUFBzABhhVodHRwOi8v\n" + + "b2NzcC5oYXJpY2EuZ3IwOwYIKwYBBQUHMAKGL2h0dHA6Ly93d3cuaGFyaWNhLmdy\n" + + "L2NlcnRzL0hhcmljYVJvb3RDQTIwMTUuY3J0MIGQBgNVHSAEgYgwgYUwgYIGBFUd\n" + + "IAAwejAyBggrBgEFBQcCARYmaHR0cDovL3d3dy5oYXJpY2EuZ3IvZG9jdW1lbnRz\n" + + "L0NQUy5waHAwRAYIKwYBBQUHAgIwOAw2VGhpcyBjZXJ0aWZpY2F0ZSBpcyBzdWJq\n" + + "ZWN0IHRvIEdyZWVrIGxhd3MgYW5kIG91ciBDUFMuMA0GCSqGSIb3DQEBCwUAA4IC\n" + + "AQA2t84B3ImFaWsnaYoPxwYu9njKaDc/QsaxT4AKP8env/Zr+fjD5s0Bjd1gZijC\n" + + "9LRTzIovpldc/yADy7SVboIH0uNEiBC0kc0DaCq0ceCGIe6dw92Mu9DJ3UpMGAuF\n" + + "fLpyearmfX9qzi0KhPGhjTxSTD4vWw3E0nvDVMBG54Im0OUGeVzZ9SpvRRhRnPOk\n" + + "1eplEYRRDVTGYQJ84GdVC4H4U3TjlbO9gppeSnBoVHyCqDDpyd8HhTuY3P5VRWaf\n" + + "dvAkwrW2Vv53zIYpDtcwG7mf4UXKbfYGtOIg/xaqHV82J6MYZHW1RNIlSh7F+1S5\n" + + "XamkPCQZZI87CMt/OZH+RaO87Vr2V02wkYwEeAvjOwq9l7LtOJaOznKS+BlMi009\n" + + "ljgHWUQcA2wk25hOAS3YtvhI1l2UrRHSqmHd7Jah4clskIjURt3b2Ez9nuZh1dC8\n" + + "NfaoPCkpK3leLBezubtq48MRe5jkAgen5UXvxq9zOZSen4pYeBK72ugNyLjzOhY8\n" + + "GrSeE1voLnvyZIguM2hrI8nEjI4rSXL6lsqXyG/ODzDMMdKq4FrjoW3y9KnV/n8t\n" + + "BvKTAlDcXQTqfdTykDWnxwNTp6dU+MOom9LGy6ZNFbei7XuvjrREiXUEJ/I2dGSD\n" + + "3zeNek32BS2BBZNN8jeP4szLs85G5HWql59OyePZfARA6Q==\n" + + "-----END CERTIFICATE-----"; + + // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=GR, OID.2.5.4.15=Private Organization, + // CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class A - Private Key created and stored in hardware CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 2c9a7af519251c645c1bed40b9d1aeca + // Valid from: Mon Sep 09 01:15:13 PDT 2019 until: Wed Sep 08 01:15:13 PDT 2021 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGyzCCBLOgAwIBAgIQLJp69RklHGRcG+1AudGuyjANBgkqhkiG9w0BAQsFADCB\n" + + "rTELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVu\n" + + "aWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRo\n" + + "b3JpdHkxRzBFBgNVBAMTPkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJ\n" + + "bnN0aXR1dGlvbnMgQ29kZSBTaWduaW5nIENBIFIxMB4XDTE5MDkwOTA4MTUxM1oX\n" + + "DTIxMDkwODA4MTUxM1owggEBMQswCQYDVQQGEwJHUjEPMA0GA1UEBwwGQXRoZW5z\n" + + "MSMwIQYDVQQKDBpHcmVlayBVbml2ZXJzaXRpZXMgTmV0d29yazFBMD8GA1UECww4\n" + + "Q2xhc3MgQSAtIFByaXZhdGUgS2V5IGNyZWF0ZWQgYW5kIHN0b3JlZCBpbiBoYXJk\n" + + "d2FyZSBDU1AxGDAWBgNVBAUTD1ZBVEdSLTA5OTAyODIyMDErMCkGA1UEAwwiR3Jl\n" + + "ZWsgVW5pdmVyc2l0aWVzIE5ldHdvcmsgKEdVbmV0KTEdMBsGA1UEDwwUUHJpdmF0\n" + + "ZSBPcmdhbml6YXRpb24xEzARBgsrBgEEAYI3PAIBAxMCR1IwggEiMA0GCSqGSIb3\n" + + "DQEBAQUAA4IBDwAwggEKAoIBAQDdkvuJzgjD3Hr1RoDtPZPp5ZelMl6Xh5vnKVuG\n" + + "KX9gwHbDaXpLkp2bF2497R3olBaeYcEgappsWLPvLMEA75BSRopFQmhX3PAsjfAG\n" + + "JZGM3A53n4NAQscCmtD6echJi4P6RThRcpfqObfe0vqZUVzSWRC8fU1P4lt/KzJj\n" + + "DGSJtOP/SJfgp3M7hEp54fn+15DlYp+0e4aa5HF2HpGIy2ghPbRvkMJWbHmp3KZG\n" + + "NOXViQdr/ogpqRsbdP7kN78WLhwrLu+xRUmf9A845jxyNO7269jOQHztfPAcgvDw\n" + + "NbZouGtN3IIWoXWMLipNgzC9CYdqgLsLI9lXV9oQrXaICQ27AgMBAAGjggGOMIIB\n" + + "ijAfBgNVHSMEGDAWgBQPLPwTPnGzLdKp6U6vgUEJppjdSDB0BggrBgEFBQcBAQRo\n" + + "MGYwQQYIKwYBBQUHMAKGNWh0dHA6Ly9yZXBvLmhhcmljYS5nci9jZXJ0cy9IYXJp\n" + + "Y2FDb2RlU2lnbmluZ0NBUjEuY3J0MCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5o\n" + + "YXJpY2EuZ3IwYAYDVR0gBFkwVzAHBgVngQwBAzAIBgYEAI96AQIwQgYMKwYBBAGB\n" + + "zxEBAQMDMDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vcmVwby5oYXJpY2EuZ3IvZG9j\n" + + "dW1lbnRzL0NQUzATBgNVHSUEDDAKBggrBgEFBQcDAzBLBgNVHR8ERDBCMECgPqA8\n" + + "hjpodHRwOi8vY3JsdjEuaGFyaWNhLmdyL0hhcmljYUNvZGVTaWduaW5nQ0FSMS9j\n" + + "cmx2MS5kZXIuY3JsMB0GA1UdDgQWBBR0K0c/UEGkfRtqAEwoONenOUa0WTAOBgNV\n" + + "HQ8BAf8EBAMCB4AwDQYJKoZIhvcNAQELBQADggIBAHXVdzMwKeZSWmXZu/MyoyH8\n" + + "yTHYi/yvaPpR88/Q/j5wxzuceECZJgH74xgePCIXx74IKTADUyIj7eWuTkzEnZF9\n" + + "yqJyG+tArrIH7zdnjC0OgbJVFeUUY45rS24u8n/+46LnXy4A+bRa0qX/QikHxMvj\n" + + "0I0/RTZpdQFjhnmhZyZzUWReFlAEG1fUz9TNwcCfGrv3z6YHCNAh/HWFtM7te6H7\n" + + "LNjoRw0fC5edqI16ca2VrOLObbg64zdk7Ll/fu3Ll5UcAthve/PTez6R1wm47ETT\n" + + "ItjinmQI3vRhIls/UwvF4ey5Linz80rnzIlrrMgn3G2gRpfJ55CxsXOZDGS9iy8C\n" + + "jU8EiKkjbdDH6mOdQO11+FlwhBwSxVbr004RDPJJqKHKtKTWx6mEbW+ZrMXaEUNZ\n" + + "mSPwDCUgDzrFfSspYJL0UW7zV+SbK9u5nf09m6qOpkZ5OE91IEpkotTWqMe/yOJu\n" + + "Yey5wvAmEqQM6fcQCTfV5JBtzU5LOsm5Uwg728DcHfal21dJWtY3fi7+CgDRutU3\n" + + "Ee8uZUmCd/KCSQgP8B/QTu7wLXHd4IQz2EP2tmN9Zrv/MsDjpSHgRrU6Hwi49bPQ\n" + + "R43rmXHC7e2GZpBdPsfG0VDnpzgCx5Kogi5nJwwUevbvC2CT11AAlaOmTQPflqQj\n" + + "w2LPatMDMTAga/l+CE8j\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class B - Private Key created and stored in software CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 29c4a7abf35bd0acb1638abbf22da1d3 + // Valid from: Mon Feb 17 01:47:19 PST 2020 until: Mon Feb 15 16:00:00 PST 2021 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGmDCCBICgAwIBAgIQKcSnq/Nb0KyxY4q78i2h0zANBgkqhkiG9w0BAQsFADCB\n" + + "rTELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVu\n" + + "aWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRo\n" + + "b3JpdHkxRzBFBgNVBAMTPkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJ\n" + + "bnN0aXR1dGlvbnMgQ29kZSBTaWduaW5nIENBIFIxMB4XDTIwMDIxNzA5NDcxOVoX\n" + + "DTIxMDIxNjAwMDAwMFowgc0xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHDAZBdGhlbnMx\n" + + "IzAhBgNVBAoMGkdyZWVrIFVuaXZlcnNpdGllcyBOZXR3b3JrMUEwPwYDVQQLDDhD\n" + + "bGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQgc3RvcmVkIGluIHNvZnR3\n" + + "YXJlIENTUDEYMBYGA1UEBRMPVkFUR1ItMDk5MDI4MjIwMSswKQYDVQQDDCJHcmVl\n" + + "ayBVbml2ZXJzaXRpZXMgTmV0d29yayAoR1VuZXQpMIIBIjANBgkqhkiG9w0BAQEF\n" + + "AAOCAQ8AMIIBCgKCAQEArSBfy0xwIHpFxFrAHiYpMOkILjOvlhRCBmfzrJFSILou\n" + + "8vc1wxZw/olBa38khtIybE0GJnzZqoFTsalAcLg0CzfqucDoWL+uVLURmEmYZExj\n" + + "ngYfjrpB7ypjWqxfBVqqLgxugY1XV3oaQRNWgFEn/mrQhv+0azySJdRSiW0BH4rP\n" + + "wXp9LHgzHc7oxVOHsOKApwRN7TRVKz0/EoPhyUzdk5xoRTQMRalwZ0/E24v+CyoF\n" + + "bPl/v+dlRK5n9It8yjCtqOMZ1z7l8sKmJ7q9iLvzAF58a8B5lPueC+opHPEy4VD0\n" + + "7xZHYgdHliDsVIcWDXAzfcfo7l9EUX17onEXKMWKDwIDAQABo4IBkDCCAYwwHwYD\n" + + "VR0jBBgwFoAUDyz8Ez5xsy3SqelOr4FBCaaY3UgwdAYIKwYBBQUHAQEEaDBmMEEG\n" + + "CCsGAQUFBzAChjVodHRwOi8vcmVwby5oYXJpY2EuZ3IvY2VydHMvSGFyaWNhQ29k\n" + + "ZVNpZ25pbmdDQVIxLmNydDAhBggrBgEFBQcwAYYVaHR0cDovL29jc3AuaGFyaWNh\n" + + "LmdyMGIGA1UdIARbMFkwCAYGZ4EMAQQBMAgGBgQAj3oBATBDBg0rBgEEAYHPEQEB\n" + + "AwEBMDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vcmVwby5oYXJpY2EuZ3IvZG9jdW1l\n" + + "bnRzL0NQUzATBgNVHSUEDDAKBggrBgEFBQcDAzBLBgNVHR8ERDBCMECgPqA8hjpo\n" + + "dHRwOi8vY3JsdjEuaGFyaWNhLmdyL0hhcmljYUNvZGVTaWduaW5nQ0FSMS9jcmx2\n" + + "MS5kZXIuY3JsMB0GA1UdDgQWBBTj6v8Qkmosm+VNGsd/prwylbsM7TAOBgNVHQ8B\n" + + "Af8EBAMCB4AwDQYJKoZIhvcNAQELBQADggIBADYBQvc68KwX28UFeE/nXcowBTSd\n" + + "z+tQexloeBa4Z5G0yRr9URPc95H1R4SJiGQxb/KKqX2LqZtowc5rOXFBchI3da24\n" + + "kn8pmoi4/U2o8iS+DSlAMsn4ZW2lyDd0jyNeRiuZXvkdpqxa9u/x0TyXJ6qUxSYM\n" + + "oUC/H7RI1rxA+NgQ+otLHVs4ye53qzO44mXJv5Qq4dQ+GEdD+dShrYs69WMC0mV0\n" + + "mVs//R1qp8G3tThAiJJF55kV8w1JH2+yv8RXAdQ2cRpN2W6wsnm2DxldHKM4Kel4\n" + + "ON0TXlARGjoGqfEjFyZYtvpjzIPGoj3MHgCdiVb+zQJavYZJfLymlnIXajVb80Hh\n" + + "9xSar/uZ0NwtZgX8EwOrBiDUuCjyvlYrcbpSN26Q4fuUfPdIJQXMQDLTFMQLQ/o4\n" + + "5dn9FLLaJF7CA8VFeyJYi9pWEiIIpmPzIibd2+CAEQ43Q87GAvLpC09Rf6yggRh5\n" + + "by/FAOOzfbEQMhvJfGcJrPeG8JdzG95N5ycAeeyb/iboYptRwsLWwurASmUEKn0y\n" + + "BHlQPhut0mqNJQsoxvW6yIipFAQPBxfRHeLG71UO1kRxCleDTMsb3Zzt8hv1G4+m\n" + + "Nsm3ZMOV8TMdlBxYO/xA9dqwAxMuPvShx6LdiiyQhdeEmIFvKZeTD22cIOVLDsrd\n" + + "D2GbhbvPInvh21Qz\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Feb 17 02:00:10 PST 2020", System.out); + } +} + +class Harica_ECC { + + // Owner: CN=HARICA Code Signing ECC SubCA R2, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions ECC RootCA 2015, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 1f6ea9c2f4d7f80ee6a046d8b822dd3f + // Valid from: Wed Mar 06 02:49:26 PST 2019 until: Thu Mar 02 02:49:26 PST 2034 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDxzCCA02gAwIBAgIQH26pwvTX+A7moEbYuCLdPzAKBggqhkjOPQQDAzCBqjEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0\n" + + "aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE5MDMwNjEwNDkyNloXDTM0MDMw\n" + + "MjEwNDkyNlowgY8xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHDAZBdGhlbnMxRDBCBgNV\n" + + "BAoMO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMg\n" + + "Q2VydC4gQXV0aG9yaXR5MSkwJwYDVQQDDCBIQVJJQ0EgQ29kZSBTaWduaW5nIEVD\n" + + "QyBTdWJDQSBSMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABKPWDfLT76KnCZ7dujms\n" + + "bFYFLTvCWTyk8l0JqdhvZ+Tk6dWYAViIX90fc8+3HPAdHvkofNWvI/PW0qlZoRn3\n" + + "De/Nrp+ZCWjg7UrUrmKH2z/N3A7lgZFqrwlWPxHSPSYVkqOCAU8wggFLMBIGA1Ud\n" + + "EwEB/wQIMAYBAf8CAQAwHwYDVR0jBBgwFoAUtCILgpkkAQ6cu+QO/b/7lyCTmSow\n" + + "cgYIKwYBBQUHAQEEZjBkMD8GCCsGAQUFBzAChjNodHRwOi8vcmVwby5oYXJpY2Eu\n" + + "Z3IvY2VydHMvSGFyaWNhRUNDUm9vdENBMjAxNS5jcnQwIQYIKwYBBQUHMAGGFWh0\n" + + "dHA6Ly9vY3NwLmhhcmljYS5ncjARBgNVHSAECjAIMAYGBFUdIAAwEwYDVR0lBAww\n" + + "CgYIKwYBBQUHAwMwSQYDVR0fBEIwQDA+oDygOoY4aHR0cDovL2NybHYxLmhhcmlj\n" + + "YS5nci9IYXJpY2FFQ0NSb290Q0EyMDE1L2NybHYxLmRlci5jcmwwHQYDVR0OBBYE\n" + + "FMdgA8SpJhybKTZTnW4Xu3NWRKZeMA4GA1UdDwEB/wQEAwIBhjAKBggqhkjOPQQD\n" + + "AwNoADBlAjAcJj7q9ujC+87/b81QowGo87VJhn9XWzRtpwjQFbIilqEfO3ot1d5F\n" + + "MWT1Xn2Qg3sCMQCoM+eV2KkQluHn2N6+GMImJqVObVUyZv0E+BvvszdJubo1cAM0\n" + + "SUImVT1t2wZpJKg=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Dimitrios Zacharopoulos, GIVENNAME=Dimitrios, SURNAME=Zacharopoulos, + // OU=Class B - Private Key created and stored in software CSP, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=HARICA Code Signing ECC SubCA R2, O=Hellenic Academic and Research Institutions Cert. Authority, + // L=Athens, C=GR + // Serial number: 11a187e3b5b0eabea4ba4987e76cd09d + // Valid from: Fri Jul 31 02:11:08 PDT 2020 until: Sun Jul 31 02:11:08 PDT 2022 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIENTCCA7ugAwIBAgIQEaGH47Ww6r6kukmH52zQnTAKBggqhkjOPQQDAzCBjzEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcMBkF0aGVuczFEMEIGA1UECgw7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxKTAnBgNVBAMMIEhBUklDQSBDb2RlIFNpZ25pbmcgRUNDIFN1YkNBIFIyMB4X\n" + + "DTIwMDczMTA5MTEwOFoXDTIyMDczMTA5MTEwOFowgfUxCzAJBgNVBAYTAkdSMQ8w\n" + + "DQYDVQQHDAZBdGhlbnMxRDBCBgNVBAoMO0hlbGxlbmljIEFjYWRlbWljIGFuZCBS\n" + + "ZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUEwPwYDVQQLDDhD\n" + + "bGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQgc3RvcmVkIGluIHNvZnR3\n" + + "YXJlIENTUDEWMBQGA1UEBAwNWmFjaGFyb3BvdWxvczESMBAGA1UEKgwJRGltaXRy\n" + + "aW9zMSAwHgYDVQQDDBdEaW1pdHJpb3MgWmFjaGFyb3BvdWxvczBZMBMGByqGSM49\n" + + "AgEGCCqGSM49AwEHA0IABOzRSqoI9HoxXjWerBBw8Croi1bJlUzoFXGjdszJIThf\n" + + "UG3YOiR1whG7wY5H5v8v4IIB5pJanArJk4CzxBLKob6jggGPMIIBizAfBgNVHSME\n" + + "GDAWgBTHYAPEqSYcmyk2U51uF7tzVkSmXjB6BggrBgEFBQcBAQRuMGwwRwYIKwYB\n" + + "BQUHMAKGO2h0dHA6Ly9yZXBvLmhhcmljYS5nci9jZXJ0cy9IYXJpY2FFQ0NDb2Rl\n" + + "U2lnbmluZ1N1YkNBUjIuY3J0MCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5oYXJp\n" + + "Y2EuZ3IwYQYDVR0gBFowWDAIBgZngQwBBAEwCAYGBACPegEBMEIGDCsGAQQBgc8R\n" + + "AQMCATAyMDAGCCsGAQUFBwIBFiRodHRwczovL3JlcG8uaGFyaWNhLmdyL2RvY3Vt\n" + + "ZW50cy9DUFMwEwYDVR0lBAwwCgYIKwYBBQUHAwMwRQYDVR0fBD4wPDA6oDigNoY0\n" + + "aHR0cDovL2NybC5oYXJpY2EuZ3IvSGFyaWNhRUNDQ29kZVNpZ25pbmdTdWJDQVIy\n" + + "LmNybDAdBgNVHQ4EFgQUpNjChUi9LGgwz7E18N1EwXooEFcwDgYDVR0PAQH/BAQD\n" + + "AgeAMAoGCCqGSM49BAMDA2gAMGUCMQCDvQIjqgssTRHqp+gu7l21XmAQ4EMqr4+B\n" + + "05iU/edLxxV+z5roTswxnPnr43+EbvkCMHq4aFW1u1+RvPBQJNRnYmdXCnj0lUw4\n" + + "Ug7JnsEYMffLakDudzgsNv5ByJf9SO84Lw==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class B - Private Key created and stored in software CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=HARICA Code Signing ECC SubCA R2, O=Hellenic Academic and Research Institutions Cert. Authority, + // L=Athens, C=GR + // Serial number: 4b14719c7195c96de8a5663724454205 + // Valid from: Mon Feb 17 01:48:32 PST 2020 until: Mon Feb 15 16:00:00 PST 2021 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIEDjCCA5SgAwIBAgIQSxRxnHGVyW3opWY3JEVCBTAKBggqhkjOPQQDAzCBjzEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcMBkF0aGVuczFEMEIGA1UECgw7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxKTAnBgNVBAMMIEhBUklDQSBDb2RlIFNpZ25pbmcgRUNDIFN1YkNBIFIyMB4X\n" + + "DTIwMDIxNzA5NDgzMloXDTIxMDIxNjAwMDAwMFowgc0xCzAJBgNVBAYTAkdSMQ8w\n" + + "DQYDVQQHDAZBdGhlbnMxIzAhBgNVBAoMGkdyZWVrIFVuaXZlcnNpdGllcyBOZXR3\n" + + "b3JrMUEwPwYDVQQLDDhDbGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQg\n" + + "c3RvcmVkIGluIHNvZnR3YXJlIENTUDEYMBYGA1UEBRMPVkFUR1ItMDk5MDI4MjIw\n" + + "MSswKQYDVQQDDCJHcmVlayBVbml2ZXJzaXRpZXMgTmV0d29yayAoR1VuZXQpMFkw\n" + + "EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAECC+lD6hphUDLSGs/Vw4Tvj8RAuCQAyi+\n" + + "MUiXXXzGSp5e6ksBVlRlawluNR+BUtY93BRCjjNr3OuvSVALyrH7HKOCAZAwggGM\n" + + "MB8GA1UdIwQYMBaAFMdgA8SpJhybKTZTnW4Xu3NWRKZeMHoGCCsGAQUFBwEBBG4w\n" + + "bDBHBggrBgEFBQcwAoY7aHR0cDovL3JlcG8uaGFyaWNhLmdyL2NlcnRzL0hhcmlj\n" + + "YUVDQ0NvZGVTaWduaW5nU3ViQ0FSMi5jcnQwIQYIKwYBBQUHMAGGFWh0dHA6Ly9v\n" + + "Y3NwLmhhcmljYS5ncjBiBgNVHSAEWzBZMAgGBmeBDAEEATAIBgYEAI96AQEwQwYN\n" + + "KwYBBAGBzxEBAQMBATAyMDAGCCsGAQUFBwIBFiRodHRwczovL3JlcG8uaGFyaWNh\n" + + "LmdyL2RvY3VtZW50cy9DUFMwEwYDVR0lBAwwCgYIKwYBBQUHAwMwRQYDVR0fBD4w\n" + + "PDA6oDigNoY0aHR0cDovL2NybC5oYXJpY2EuZ3IvSGFyaWNhRUNDQ29kZVNpZ25p\n" + + "bmdTdWJDQVIyLmNybDAdBgNVHQ4EFgQUT4+WfQu125tLqla60vhK7ijBBWkwDgYD\n" + + "VR0PAQH/BAQDAgeAMAoGCCqGSM49BAMDA2gAMGUCMQDADGDAxKpUkyEKBLzpX+88\n" + + "ONLYDgFSie5W2ULWk02sDRO/k5xcSSjTf0FFa4+l6E8CME/b27e7NUGHPVYTLTWL\n" + + "5yPiboyNsT8QpV+hZiWh/Qqiw1E/bR2SPIGEwYUrOV61fA==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Feb 17 02:00:57 PST 2020", System.out); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java index 63ba5e1bbab..469501c70c2 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8232019 + * @bug 8232019 8256895 * @summary Interoperability tests with LuxTrust Global Root 2 CA * @build ValidatePathWithParams * @run main/othervm -Djava.security.debug=certpath LuxTrustCA OCSP @@ -173,6 +173,7 @@ public class LuxTrustCA { public static void main(String[] args) throws Exception { + System.setProperty("jdk.security.certpath.ocspNonce", "true"); ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java index 1d31833398b..dd0b982f58b 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8243320 + * @bug 8243320 8256895 * @summary Interoperability tests with SSL.com's RSA, EV RSA, and ECC CA * @build ValidatePathWithParams * @run main/othervm -Djava.security.debug=certpath SSLCA OCSP @@ -47,6 +47,7 @@ public class SSLCA { public static void main(String[] args) throws Exception { + System.setProperty("jdk.security.certpath.ocspNonce", "true"); ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); boolean ocspEnabled = false; diff --git a/test/jdk/sun/java2d/marlin/ClipShapeTest.java b/test/jdk/sun/java2d/marlin/ClipShapeTest.java index 061fd1cfbb0..65de6e750c9 100644 --- a/test/jdk/sun/java2d/marlin/ClipShapeTest.java +++ b/test/jdk/sun/java2d/marlin/ClipShapeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,10 +61,6 @@ * for paths made of either 9 lines, 4 quads, 2 cubics (random) * Note: Use the argument -slow to run more intensive tests (too much time) * - * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine ClipShapeTest -poly - * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine ClipShapeTest -poly -doDash - * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine ClipShapeTest -cubic - * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine ClipShapeTest -cubic -doDash * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.DMarlinRenderingEngine ClipShapeTest -poly * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.DMarlinRenderingEngine ClipShapeTest -poly -doDash * @run main/othervm/timeout=300 -Dsun.java2d.renderer=sun.java2d.marlin.DMarlinRenderingEngine ClipShapeTest -cubic @@ -133,7 +129,6 @@ static enum ShapeMode { static final File OUTPUT_DIR = new File("."); static final AtomicBoolean isMarlin = new AtomicBoolean(); - static final AtomicBoolean isMarlinFloat = new AtomicBoolean(); static final AtomicBoolean isClipRuntime = new AtomicBoolean(); static { @@ -150,8 +145,7 @@ public void publish(LogRecord record) { if (msg != null) { // last space to avoid matching other settings: if (msg.startsWith("sun.java2d.renderer ")) { - isMarlin.set(msg.contains("MarlinRenderingEngine")); - isMarlinFloat.set(!msg.contains("DMarlinRenderingEngine")); + isMarlin.set(msg.contains("DMarlinRenderingEngine")); } if (msg.startsWith("sun.java2d.renderer.clip.runtime.enable")) { isClipRuntime.set(msg.contains("true")); @@ -294,10 +288,7 @@ public static void main(String[] args) { // Define uncertainty for lines: // float variant have higher uncertainty THRESHOLD_DELTA = 2; - THRESHOLD_NBPIX = (USE_DASHES) ? - // float variant have higher uncertainty - ((isMarlinFloat.get()) ? 30 : 6) // low for double - : (isMarlinFloat.get()) ? 10 : 0; + THRESHOLD_NBPIX = (USE_DASHES) ? 6 : 0; } // Visual inspection (low threshold): diff --git a/test/jdk/sun/java2d/marlin/StrokedLinePerf.java b/test/jdk/sun/java2d/marlin/StrokedLinePerf.java new file mode 100644 index 00000000000..ec304f9db8c --- /dev/null +++ b/test/jdk/sun/java2d/marlin/StrokedLinePerf.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BasicStroke; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.image.BufferedImage; + +import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; + +/** + * @test + * @bug 7018932 + * @summary fix LoopPipe.getStrokedSpans() performance (clipping enabled by Marlin renderer) + * @run main/othervm/timeout=10 -Dsun.java2d.renderer=sun.java2d.marlin.DMarlinRenderingEngine StrokedLinePerf + */ +public class StrokedLinePerf { + + public static void main(String[] unused) { + BufferedImage bi = new BufferedImage(400, 400, TYPE_INT_ARGB_PRE); + test(bi, true); + test(bi, false); + } + + private static void test(BufferedImage bi, boolean useAA) { + final long start = System.nanoTime(); + + final Graphics2D g2d = bi.createGraphics(); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + (useAA) ? RenderingHints.VALUE_ANTIALIAS_ON + : RenderingHints.VALUE_ANTIALIAS_OFF); + + Stroke stroke = new BasicStroke(2.0f, 1, 0, 1.0f, new float[]{0.0f, 4.0f}, 0.0f); + g2d.setStroke(stroke); + + //Large values to trigger crash / infinite loop. + g2d.draw(new Line2D.Double(4.0, 1.794369841E9, 567.0, -2.147483648E9)); + + System.out.println("StrokedLinePerf(" + useAA + "): Test duration= " + (1e-6 * (System.nanoTime() - start)) + " ms."); + g2d.dispose(); + } +} diff --git a/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/KeepAliveStreamCleanerTestDriver.java b/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/KeepAliveStreamCleanerTestDriver.java new file mode 100644 index 00000000000..5f66aff365e --- /dev/null +++ b/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/KeepAliveStreamCleanerTestDriver.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8255124 + * @summary Tests that KeepAliveStreamCleaner run does not throw an IllegalMonitorState Exception. + * @modules java.base/sun.net.www.http + * @run testng java.base/sun.net.www.http.KeepAliveStreamCleanerTest + */ diff --git a/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/java.base/sun/net/www/http/KeepAliveStreamCleanerTest.java b/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/java.base/sun/net/www/http/KeepAliveStreamCleanerTest.java new file mode 100644 index 00000000000..b4bc638099d --- /dev/null +++ b/test/jdk/sun/net/www/http/KeepAliveStreamCleaner/java.base/sun/net/www/http/KeepAliveStreamCleanerTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.net.www.http; + +import org.testng.annotations.Test; + +@Test +public class KeepAliveStreamCleanerTest { + + /* + Tests that KeepAliveStreamCleaner run does not throw an + IllegalMonitorState Exception. + */ + @Test + public void keepAliveStreamCleanerTest() { + KeepAliveStreamCleaner kase = new KeepAliveStreamCleaner(); + kase.run(); + } +} diff --git a/test/jdk/sun/net/www/protocol/http/DigestTest.java b/test/jdk/sun/net/www/protocol/http/DigestTest.java index fe8249c1f98..b699c3ff476 100644 --- a/test/jdk/sun/net/www/protocol/http/DigestTest.java +++ b/test/jdk/sun/net/www/protocol/http/DigestTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -172,11 +172,6 @@ private String computeDigest( return finalHash; } - private final static char charArray[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - private String encode(String src, char[] passwd, MessageDigest md) { md.update(src.getBytes()); if (passwd != null) { @@ -187,15 +182,7 @@ private String encode(String src, char[] passwd, MessageDigest md) { Arrays.fill(passwdBytes, (byte)0x00); } byte[] digest = md.digest(); - - StringBuffer res = new StringBuffer(digest.length * 2); - for (int i = 0; i < digest.length; i++) { - int hashchar = ((digest[i] >>> 4) & 0xf); - res.append(charArray[hashchar]); - hashchar = (digest[i] & 0xf); - res.append(charArray[hashchar]); - } - return res.toString(); + return HexFormat.of().formatHex(digest); } } diff --git a/test/jdk/sun/net/www/protocol/jar/B4756443.java b/test/jdk/sun/net/www/protocol/jar/B4756443.java index f305d5f06c6..888adcfeebe 100644 --- a/test/jdk/sun/net/www/protocol/jar/B4756443.java +++ b/test/jdk/sun/net/www/protocol/jar/B4756443.java @@ -26,8 +26,11 @@ * @bug 4756443 * @summary REGRESSION: NPE in JarURLConnection.getLastModified after setUseCache(false) */ -import java.io.*; -import java.net.*; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; public class B4756443 { diff --git a/test/jdk/sun/net/www/protocol/jar/B5105410.java b/test/jdk/sun/net/www/protocol/jar/B5105410.java index 7401e4ef766..d9994e9bd13 100644 --- a/test/jdk/sun/net/www/protocol/jar/B5105410.java +++ b/test/jdk/sun/net/www/protocol/jar/B5105410.java @@ -35,6 +35,7 @@ import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; + import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; public class B5105410 { diff --git a/test/jdk/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java b/test/jdk/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java index 433a72cc55b..ab230421c36 100644 --- a/test/jdk/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java +++ b/test/jdk/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java @@ -28,10 +28,13 @@ * @run main/othervm JarURLConnectionUseCaches */ -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.net.JarURLConnection; import java.net.URL; -import java.util.jar.*; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; public class JarURLConnectionUseCaches { public static void main( String[] args ) throws IOException { diff --git a/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java b/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java index de90ec77752..078d72648f7 100644 --- a/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java +++ b/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java @@ -30,7 +30,7 @@ * jdk.httpserver * jdk.jartool * @build CreateMultiReleaseTestJars - * SimpleHttpServer + * jdk.test.lib.net.SimpleHttpServer * jdk.test.lib.util.JarBuilder * jdk.test.lib.compiler.Compiler * @run testng MultiReleaseJarURLConnection @@ -42,6 +42,7 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URI; @@ -54,8 +55,8 @@ import java.util.Enumeration; import java.util.jar.JarFile; +import jdk.test.lib.net.SimpleHttpServer; import jdk.test.lib.net.URIBuilder; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -63,10 +64,11 @@ import org.testng.annotations.Test; public class MultiReleaseJarURLConnection { - String userdir = System.getProperty("user.dir","."); + String userdir = System.getProperty("user.dir", "."); String unversioned = userdir + "/unversioned.jar"; String unsigned = userdir + "/multi-release.jar"; String signed = userdir + "/signed-multi-release.jar"; + static final String TESTCONTEXT = "/multi-release.jar"; SimpleHttpServer server; @BeforeClass @@ -76,10 +78,8 @@ public void initialize() throws Exception { creator.buildUnversionedJar(); creator.buildMultiReleaseJar(); creator.buildSignedMultiReleaseJar(); - - server = new SimpleHttpServer(InetAddress.getLoopbackAddress()); + server = new SimpleHttpServer(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), TESTCONTEXT, System.getProperty("user.dir", ".")); server.start(); - } @AfterClass @@ -134,12 +134,12 @@ public void testCachedJars(String style, String file) throws Exception { String urlFile = "jar:file:" + file + "!/"; URL rootUrl = new URL(urlFile); - JarURLConnection juc = (JarURLConnection)rootUrl.openConnection(); + JarURLConnection juc = (JarURLConnection) rootUrl.openConnection(); JarFile rootJar = juc.getJarFile(); Runtime.Version root = rootJar.getVersion(); URL runtimeUrl = new URL(urlFile + "#runtime"); - juc = (JarURLConnection)runtimeUrl.openConnection(); + juc = (JarURLConnection) runtimeUrl.openConnection(); JarFile runtimeJar = juc.getJarFile(); Runtime.Version runtime = runtimeJar.getVersion(); if (style.equals("unversioned")) { @@ -148,12 +148,12 @@ public void testCachedJars(String style, String file) throws Exception { Assert.assertNotEquals(root, runtime); } - juc = (JarURLConnection)rootUrl.openConnection(); + juc = (JarURLConnection) rootUrl.openConnection(); JarFile jar = juc.getJarFile(); Assert.assertEquals(jar.getVersion(), root); Assert.assertEquals(jar, rootJar); - juc = (JarURLConnection)runtimeUrl.openConnection(); + juc = (JarURLConnection) runtimeUrl.openConnection(); jar = juc.getJarFile(); Assert.assertEquals(jar.getVersion(), runtime); Assert.assertEquals(jar, runtimeJar); @@ -184,7 +184,7 @@ public Object[][] createResourceData() throws Exception { @Test(dataProvider = "resourcedata") public void testResources(String style, URL url) throws Throwable { - //System.out.println(" testing " + style + " url: " + url); + // System.out.println(" testing " + style + " url: " + url); URL[] urls = {url}; URLClassLoader cldr = new URLClassLoader(urls); Class vcls = cldr.loadClass("version.Version"); @@ -251,7 +251,7 @@ private boolean readAndCompare(URL url, String match) throws Exception { result = (new String(bytes)).contains(match); } if (conn instanceof JarURLConnection) { - ((JarURLConnection)conn).getJarFile().close(); + ((JarURLConnection) conn).getJarFile().close(); } return result; } diff --git a/test/jdk/sun/net/www/protocol/jar/jarbug/TestDriver.java b/test/jdk/sun/net/www/protocol/jar/jarbug/TestDriver.java index c6798aa1fbf..cb27c554686 100644 --- a/test/jdk/sun/net/www/protocol/jar/jarbug/TestDriver.java +++ b/test/jdk/sun/net/www/protocol/jar/jarbug/TestDriver.java @@ -39,16 +39,16 @@ * @run main/othervm TestDriver */ -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.compiler.CompilerUtils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.util.JarUtils; - import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; + import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.JarUtils; public class TestDriver { public static void main(String[] args) throws Throwable { diff --git a/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/GetResource.java b/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/GetResource.java index ffc00df984d..874597d2eb7 100644 --- a/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/GetResource.java +++ b/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/GetResource.java @@ -23,8 +23,7 @@ package jar1; -import java.io.*; -import java.util.*; +import java.io.InputStream; public class GetResource { diff --git a/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/LoadResourceBundle.java b/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/LoadResourceBundle.java index dd9e5df2fc4..33122f0f767 100644 --- a/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/LoadResourceBundle.java +++ b/test/jdk/sun/net/www/protocol/jar/jarbug/src/jar1/LoadResourceBundle.java @@ -23,8 +23,9 @@ package jar1; -import java.io.*; -import java.util.*; +import java.io.InputStream; +import java.util.Locale; +import java.util.ResourceBundle; public class LoadResourceBundle { diff --git a/test/jdk/sun/net/www/protocol/jar/jarbug/src/test/JarTest.java b/test/jdk/sun/net/www/protocol/jar/jarbug/src/test/JarTest.java index 4ddae0b085e..ab8e3d0cf82 100644 --- a/test/jdk/sun/net/www/protocol/jar/jarbug/src/test/JarTest.java +++ b/test/jdk/sun/net/www/protocol/jar/jarbug/src/test/JarTest.java @@ -21,102 +21,105 @@ * questions. */ -import java.io.*; -import java.net.*; -import java.util.jar.*; - -public abstract class JarTest -{ - static String tmpdir = System.getProperty("java.io.tmpdir"); - static String javaCmd = System.getProperty("java.home") + File.separator + - "bin" + File.separator + "java"; - - /** - * Reads an input stream into a byte array. - */ - protected byte[] readFully(InputStream in) throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buffer = new byte[32]; - int count; - - while ((count = in.read(buffer)) >= 0) { - out.write(buffer, 0, count); - } - - return out.toByteArray(); +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; + +public abstract class JarTest { + static String tmpdir = System.getProperty("java.io.tmpdir"); + static String javaCmd = System.getProperty("java.home") + File.separator + + "bin" + File.separator + "java"; + + /** + * Reads an input stream into a byte array. + */ + protected byte[] readFully(InputStream in) throws Exception { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[32]; + int count; + + while ((count = in.read(buffer)) >= 0) { + out.write(buffer, 0, count); } - /** - * Copies the named resource into the directory specified. - */ - protected File copyResource(File dir, String resName) throws Exception { - BufferedOutputStream buffOut = null; - FileOutputStream fileOut; - InputStream in = null; - File file = null; - byte[] buffer; - int count; - - file = new File(dir, resName); + return out.toByteArray(); + } + + /** + * Copies the named resource into the directory specified. + */ + protected File copyResource(File dir, String resName) throws Exception { + BufferedOutputStream buffOut = null; + FileOutputStream fileOut; + InputStream in = null; + File file = null; + byte[] buffer; + int count; + + file = new File(dir, resName); + try { + fileOut = new FileOutputStream(file); + buffOut = new BufferedOutputStream(fileOut); + in = getClass().getResourceAsStream(resName); + buffer = new byte[1024]; + + while ((count = in.read(buffer)) >= 0) { + buffOut.write(buffer, 0, count); + } + buffOut.flush(); + } finally { + if (buffOut != null) { try { - fileOut = new FileOutputStream(file); - buffOut = new BufferedOutputStream(fileOut); - in = getClass().getResourceAsStream(resName); - buffer = new byte[1024]; - - while ((count = in.read(buffer)) >= 0) { - buffOut.write(buffer, 0, count); - } - buffOut.flush(); - } finally { - if (buffOut != null) { - try { - buffOut.close(); - } catch (IOException e) { - } - } - if (in != null) { - try { - in.close(); - } catch (IOException e) { - } - } + buffOut.close(); + } catch (IOException e) { } - - return file; + } + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } } - /** - * Utility to create a temp dir. - */ - protected File createTempDir() throws Exception { - File result = new File(tmpdir + File.separator + getClass().getName()); - result.delete(); - result.mkdirs(); + return file; + } - return result; - } + /** + * Utility to create a temp dir. + */ + protected File createTempDir() throws Exception { + File result = new File(tmpdir + File.separator + getClass().getName()); + result.delete(); + result.mkdirs(); - /** - * Utility to recursively delete a directory. - */ - protected boolean deleteRecursively(File file) { - File[] children; - boolean result = true; - - children = file.listFiles(); - if (children != null) { - for (int i=0; i>4]; - h[2*i+1] = hexConst[hash[i]&0xf]; - } - return new String(h); - } - // return size of dfl file, excluding the null hash ones private static int csize(int p) throws Exception { try (SeekableByteChannel chan = Files.newByteChannel( diff --git a/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java b/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java deleted file mode 100644 index c8dd06427b9..00000000000 --- a/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 7184246 - * @summary Simplify Config.get() of krb5 - * @modules java.security.jgss/sun.security.krb5:+open - */ -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Hashtable; -import java.util.Vector; -import sun.security.krb5.Config; -import sun.security.krb5.SCDynamicStoreConfig; - -public class SCDynamicConfigTest { - - static Vector>hosts() { - Vector > result = new Vector<>(); - Hashtable pair = new Hashtable<>(); - pair.put("host", "127.0.0.1"); - result.add(pair); - pair = new Hashtable<>(); - pair.put("host", "127.0.0.2"); - result.add(pair); - return result; - } - - public static void main(String[] args) throws Exception { - // Reconstruct a typical SCDynamicConfig.getKerberosConfig() output - Hashtable conf = new Hashtable<>(); - - Hashtable libdefaults = new Hashtable<>(); - libdefaults.put("default_realm", "REALM.COM"); - conf.put("libdefaults", libdefaults); - - Hashtable realms = new Hashtable<>(); - Hashtable thisRealm = new Hashtable<>(); - realms.put("REALM.COM", thisRealm); - thisRealm.put("kpasswd", hosts()); - thisRealm.put("kadmin", hosts()); - thisRealm.put("kdc", hosts()); - conf.put("realms", realms); - - Hashtable domain_realm = new Hashtable<>(); - domain_realm.put(".realm.com", "REALM.COM"); - domain_realm.put("realm.com", "REALM.COM"); - conf.put("domain_realm", domain_realm); - - System.out.println("SCDynamicConfig:\n"); - System.out.println(conf); - - // Simulate SCDynamicConfig.getConfig() output - Method m = SCDynamicStoreConfig.class.getDeclaredMethod( - "convertNativeConfig", Hashtable.class); - m.setAccessible(true); - conf = (Hashtable)m.invoke(null, conf); - - System.out.println("\nkrb5.conf:\n"); - System.out.println(conf); - - // Feed it into a Config object - System.setProperty("java.security.krb5.conf", "not-a-file"); - Config cf = Config.getInstance(); - Field f = Config.class.getDeclaredField("stanzaTable"); - f.setAccessible(true); - f.set(cf, conf); - - System.out.println("\nConfig:\n"); - System.out.println(cf); - - if (!cf.getDefaultRealm().equals("REALM.COM")) { - throw new Exception(); - } - if (!cf.getKDCList("REALM.COM").equals("127.0.0.1 127.0.0.2")) { - throw new Exception(); - } - if (!cf.get("domain_realm", ".realm.com").equals("REALM.COM")) { - throw new Exception(); - } - } -} diff --git a/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java new file mode 100644 index 00000000000..19500899878 --- /dev/null +++ b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8257860 + * @summary SCDynamicStoreConfig works + * @modules java.security.jgss/sun.security.krb5 + * @library /test/lib + * @run main/manual/native TestDynamicStore + * @requires (os.family == "mac") + */ + +import jdk.test.lib.Asserts; +import sun.security.krb5.Config; + +public class TestDynamicStore { + + native static int actionInternal(char what, char whom); + + // what: 'a' for add, 'r' for remove + // whom: 'a' for all, 'r' for realm, 'm' for mapping + static int action(char what, char whom) throws Exception { + int out = actionInternal(what, whom); + System.out.println("Run " + what + whom + " " + out); + Thread.sleep(1000); // wait for callback called + return out; + } + + public static void main(String[] args) throws Exception { + + System.loadLibrary("TestDynamicStore"); + + Config cfg = Config.getInstance(); + if (cfg.exists("libdefaults") || cfg.exists("realms")) { + System.out.println("Already have krb5 config. Will not touch"); + return; + } + + try { + System.out.println("Fill in dynamic store"); + action('a', 'a'); + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM")); + Asserts.assertTrue(Config.getInstance().exists("domain_realm")); + + System.out.println("Remove mapping"); + action('r', 'm'); + Asserts.assertTrue(!Config.getInstance().exists("domain_realm")); + + System.out.println("Re-add mapping"); + action('a', 'm'); + Asserts.assertTrue(Config.getInstance().exists("domain_realm")); + + System.out.println("Remove realm info"); + action('r', 'r'); + // Realm info is not watched, so no change detected + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM")); + + System.out.println("Remove mapping"); + action('r', 'm'); + // But mapping is watched, so realm info is not re-read + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("B.COM")); + } finally { + System.out.println("Remove everything"); + action('r', 'a'); + Asserts.assertTrue(!Config.getInstance().exists("libdefault")); + } + } +} diff --git a/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m new file mode 100644 index 00000000000..30ed2eb113f --- /dev/null +++ b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#import +#import +#import + +#define KERBEROS_DEFAULT_REALMS @"Kerberos-Default-Realms" +#define KERBEROS_DEFAULT_REALM_MAPPINGS @"Kerberos-Domain-Realm-Mappings" +#define KERBEROS_REALM_INFO @"Kerberos:%@" + +int removeAll(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS)); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"])); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"B.COM"])); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS)); + return 1; +} + +int removeRealm(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"])); + return 1; +} + +int removeMapping(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS)); + return 1; +} + +int addMapping(SCDynamicStoreRef store) { + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + @"a", @"A", + @"b", @"B", + @"c", @"C", + @"d", @"D", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS, [NSArray arrayWithObjects: dict, nil])); + return 1; +} + +int addAll(SCDynamicStoreRef store) { + NSArray *keys = [NSArray arrayWithObjects:@"A.COM", @"B.COM", nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys)); + + NSDictionary *k1 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc1.a.com", @"host", nil]; + NSDictionary *k2 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc2.a.com", @"host", nil]; + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObjects: k1, k2, nil], @"kdc", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"], dict)); + + k1 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc1.b.com", @"host", nil]; + k2 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc2.b.com", @"host", nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObjects: k1, k2, nil], @"kdc", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"B.COM"], dict)); + addMapping(store); + return 1; +} + +JNIEXPORT jint JNICALL Java_TestDynamicStore_actionInternal(JNIEnv *env, jclass clazz, jchar what, jchar whom) { + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL); + fprintf(stderr, ">>> action: %c %c\n", what, whom); + @try { + switch (what) { + case 'a': + switch (whom) { + case 'a': return addAll(store); + case 'm': return addMapping(store); + } + break; + case 'r': + switch (whom) { + case 'a': return removeAll(store); + case 'r': return removeRealm(store); + case 'm': return removeMapping(store); + } + break; + } + return 0; + } @finally { + CFRelease(store); + } +} diff --git a/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java b/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java index c738e063e02..f7feefadf31 100644 --- a/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java +++ b/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import javax.crypto.Cipher; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.HexFormat; import sun.security.krb5.internal.crypto.dk.AesSha2DkCrypto; import jdk.test.lib.hexdump.HexPrinter; @@ -190,11 +191,7 @@ private static byte[] checksum(AesSha2DkCrypto dk, byte[] baseKey, byte[] text) private static byte[] hex(String var) { var = var.replaceAll("\\s", ""); - byte[] data = new byte[var.length()/2]; - for (int i=0; i blacklisted = new HashSet<>(); + Set blocked = new HashSet<>(); // Assumes the full src is available - File blacklist = new File(System.getProperty("test.src"), - "../../../../../make/data/blacklistedcertsconverter/blacklisted.certs.pem"); + File blockedCertsFile = new File(System.getProperty("test.src"), + "../../../../../make/data/blockedcertsconverter/blocked.certs.pem"); CertificateFactory cf = CertificateFactory.getInstance("X.509"); - try (FileInputStream fis = new FileInputStream(blacklist)) { + try (FileInputStream fis = new FileInputStream(blockedCertsFile)) { Collection certs = cf.generateCertificates(fis); System.out.println(certs.size()); for (Certificate c: certs) { - blacklisted.add(c); + blocked.add(c); X509Certificate cert = ((X509Certificate)c); if (!UntrustedCertificates.isUntrusted(cert)) { - System.out.println(cert.getSubjectDN() + " is trusted"); + System.out.println(cert.getSubjectX500Principal() + + " is trusted"); failed = true; } } } - // Check the blacklisted.certs file itself - file = new File(home, "lib/security/blacklisted.certs"); + // Check the blocked.certs file itself + file = new File(home, "lib/security/blocked.certs"); System.out.print("Check for " + file + ": "); try (BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(file)))) { @@ -100,11 +101,11 @@ public static void main(String[] args) throws Exception { failed = true; } // There are two unique fingerprints for each RSA certificate - if (ccount != blacklisted.size() * 2 - && !blacklisted.isEmpty()) { - System.out.println("Wrong blacklisted.certs size: " + if (ccount != blocked.size() * 2 + && !blocked.isEmpty()) { + System.out.println("Wrong blocked.certs size: " + ccount + " fingerprints, " - + blacklisted.size() + " certs"); + + blocked.size() + " certs"); failed = true; } } diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index eb89310dc81..328c4a972bc 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779 * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 - * 8243559 + * 8243559 8225072 8258630 8259312 8256421 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -44,6 +44,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; +import java.util.HexFormat; import java.util.Map; public class VerifyCACerts { @@ -53,12 +54,15 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 90; + private static final int COUNT = 92; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "50:97:53:06:1B:40:32:71:D6:CD:3B:29:89:7C:BF:BF:41:6F:56:B1:0D:E9:B8:2A:8C:7C:C2:CD:CD:9F:10:EF"; + = "02:AE:2C:37:34:B1:B1:3D:74:CB:99:8B:31:4F:C9:BB:23:51:BB:B3:90:59:47:72:C1:4A:36:DA:97:98:06:01"; + + // Hex formatter to upper case with ":" delimiter + private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); // map of cert alias to SHA-256 fingerprint @SuppressWarnings("serial") @@ -244,6 +248,10 @@ public class VerifyCACerts { "2E:7B:F1:6C:C2:24:85:A7:BB:E2:AA:86:96:75:07:61:B0:AE:39:BE:3B:2F:E9:D0:CC:6D:4E:F7:34:91:42:5C"); put("sslrooteccca [jdk]", "34:17:BB:06:CC:60:07:DA:1B:96:1C:92:0B:8A:B4:CE:3F:AD:82:0E:4A:A3:0B:9A:CB:C4:A7:4E:BD:CE:BC:65"); + put("haricarootca2015 [jdk]", + "A0:40:92:9A:02:CE:53:B4:AC:F4:F2:FF:C6:98:1C:E4:49:6F:75:5E:6D:45:FE:0B:2A:69:2B:CD:52:52:3F:36"); + put("haricaeccrootca2015 [jdk]", + "44:B5:45:AA:8A:25:E6:5A:73:CA:15:DC:27:FC:36:D2:4C:1C:B9:95:3A:06:65:39:B1:15:82:DC:48:7B:48:33"); } }; @@ -258,6 +266,12 @@ public class VerifyCACerts { add("addtrustexternalca [jdk]"); // Valid until: Sat May 30 10:44:50 GMT 2020 add("addtrustqualifiedca [jdk]"); + // Valid until: Wed Mar 17 02:51:37 PDT 2021 + add("luxtrustglobalrootca [jdk]"); + // Valid until: Wed Mar 17 11:33:33 PDT 2021 + add("quovadisrootca [jdk]"); + // Valid until: Tue Apr 06 00:29:40 PDT 2021 + add("soneraclass2ca [jdk]"); } }; @@ -273,7 +287,7 @@ public static void main(String[] args) throws Exception { md = MessageDigest.getInstance("SHA-256"); byte[] data = Files.readAllBytes(Path.of(CACERTS)); - String checksum = toHexString(md.digest(data)); + String checksum = HEX.formatHex(md.digest(data)); if (!checksum.equals(CHECKSUM)) { atLeastOneFailed = true; System.err.println("ERROR: wrong checksum\n" + checksum); @@ -362,18 +376,7 @@ private static boolean checkFingerprint(String alias, Certificate cert) } System.out.println("Checking fingerprint of " + alias); byte[] digest = md.digest(cert.getEncoded()); - return fingerprint.equals(toHexString(digest)); + return fingerprint.equals(HEX.formatHex(digest)); } - private static String toHexString(byte[] block) { - StringBuilder buf = new StringBuilder(); - int len = block.length; - for (int i = 0; i < len; i++) { - buf.append(String.format("%02X", block[i])); - if (i < len - 1) { - buf.append(":"); - } - } - return buf.toString(); - } } diff --git a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java index b86ab9dceb3..fbe09e5e307 100644 --- a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java +++ b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,10 @@ import java.io.IOException; import java.math.BigInteger; import java.util.Arrays; +import java.util.HexFormat; -import jdk.test.lib.Utils; +import jdk.test.lib.hexdump.ASN1Formatter; +import jdk.test.lib.hexdump.HexPrinter; import org.testng.Assert; import org.testng.annotations.Test; import sun.security.pkcs.PKCS8Key; @@ -52,7 +54,7 @@ public class PKCS8Test { "\tp: 02\n\tq: 03\n\tg: 04\n"; static final String ALGORITHM = "DSA"; - static final byte[] EXPECTED = Utils.toByteArray( + static final byte[] EXPECTED = HexFormat.of().parseHex( "301e" + // SEQUENCE "020100" + // Version int 0 "3014" + // PrivateKeyAlgorithmIdentifier @@ -70,7 +72,9 @@ public void test() throws IOException { BigInteger.valueOf(4)).getEncoded(); Assert.assertTrue(Arrays.equals(encodedKey, EXPECTED), - Utils.toHexString(encodedKey)); + HexPrinter.simple() + .formatter(ASN1Formatter.formatter()) + .toString(encodedKey)); PKCS8Key decodedKey = (PKCS8Key)PKCS8Key.parseKey( new DerValue(encodedKey)); @@ -82,7 +86,9 @@ public void test() throws IOException { byte[] encodedOutput = decodedKey.getEncoded(); Assert.assertTrue(Arrays.equals(encodedOutput, EXPECTED), - Utils.toHexString(encodedOutput)); + HexPrinter.simple() + .formatter(ASN1Formatter.formatter()) + .toString(encodedOutput)); // Test additional fields enlarge(0, "8000"); // attributes @@ -106,7 +112,7 @@ static void enlarge(int newVersion, String... fields) throws IOException { byte[] original = EXPECTED.clone(); int length = original.length; for (String field : fields) { // append fields - byte[] add = Utils.toByteArray(field); + byte[] add = HexFormat.of().parseHex(field); original = Arrays.copyOf(original, length + add.length); System.arraycopy(add, 0, original, length, add.length); length += add.length; diff --git a/test/jdk/sun/security/pkcs11/Cipher/CancelMultipart.java b/test/jdk/sun/security/pkcs11/Cipher/CancelMultipart.java new file mode 100644 index 00000000000..28f3699050c --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Cipher/CancelMultipart.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8258833 + * @library /test/lib .. + * @modules jdk.crypto.cryptoki/sun.security.pkcs11:open + * @run main/othervm CancelMultipart + */ + +import java.lang.reflect.Field; +import java.nio.ByteBuffer; +import java.security.Key; +import java.security.Provider; +import java.security.ProviderException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.spec.SecretKeySpec; + +public class CancelMultipart extends PKCS11Test { + + private static Provider provider; + private static Key key; + + static { + key = new SecretKeySpec(new byte[16], "AES"); + } + + private static class SessionLeaker { + private LeakOperation op; + private LeakInputType type; + + SessionLeaker(LeakOperation op, LeakInputType type) { + this.op = op; + this.type = type; + } + + private void leakAndTry() throws Exception { + Cipher cipher = op.getCipher(); + try { + type.doOperation(cipher, + (op instanceof LeakDecrypt ? + LeakInputType.DECRYPT_MODE : + null)); + throw new Exception("PKCS11Exception expected, invalid block" + + "size"); + } catch (ProviderException | IllegalBlockSizeException e) { + // Exception expected - session returned to the SessionManager + // should be cancelled. That's what will be tested now. + } + + tryCipherInit(); + } + } + + private static interface LeakOperation { + Cipher getCipher() throws Exception; + } + + private static interface LeakInputType { + static int DECRYPT_MODE = 1; + void doOperation(Cipher cipher, int mode) throws Exception; + } + + private static class LeakDecrypt implements LeakOperation { + public Cipher getCipher() throws Exception { + Cipher cipher = Cipher.getInstance( + "AES/ECB/PKCS5Padding", provider); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher; + } + } + + private static class LeakByteBuffer implements LeakInputType { + public void doOperation(Cipher cipher, int mode) throws Exception { + if (mode == DECRYPT_MODE) { + cipher.update(ByteBuffer.allocate(1), ByteBuffer.allocate(1)); + cipher.doFinal(ByteBuffer.allocate(0), ByteBuffer.allocate(1)); + } + } + } + + private static class LeakByteArray implements LeakInputType { + public void doOperation(Cipher cipher, int mode) throws Exception { + if (mode == DECRYPT_MODE) { + cipher.update(new byte[1]); + cipher.doFinal(new byte[1], 0, 0); + } + } + } + + public static void main(String[] args) throws Exception { + main(new CancelMultipart(), args); + } + + @Override + public void main(Provider p) throws Exception { + init(p); + + // Try multiple paths: + + executeTest(new SessionLeaker(new LeakDecrypt(), new LeakByteArray()), + "P11Cipher::implDoFinal(byte[], int, int)"); + + executeTest(new SessionLeaker(new LeakDecrypt(), new LeakByteBuffer()), + "P11Cipher::implDoFinal(ByteBuffer)"); + + System.out.println("TEST PASS - OK"); + } + + private static void executeTest(SessionLeaker sl, String testName) + throws Exception { + try { + sl.leakAndTry(); + System.out.println(testName + ": OK"); + } catch (Exception e) { + System.out.println(testName + ": FAILED"); + throw e; + } + } + + private static void init(Provider p) throws Exception { + provider = p; + + // The max number of sessions is 2 because, in addition to the + // operation (i.e. PKCS11::getNativeKeyInfo), a session to hold + // the P11Key object is needed. + setMaxSessions(2); + } + + /* + * This method is intended to generate pression on the number of sessions + * to be used from the NSS Software Token, so sessions with (potentially) + * active operations are reused. + */ + private static void setMaxSessions(int maxSessions) throws Exception { + Field tokenField = Class.forName("sun.security.pkcs11.SunPKCS11") + .getDeclaredField("token"); + tokenField.setAccessible(true); + Field sessionManagerField = Class.forName("sun.security.pkcs11.Token") + .getDeclaredField("sessionManager"); + sessionManagerField.setAccessible(true); + Field maxSessionsField = Class.forName("sun.security.pkcs11.SessionManager") + .getDeclaredField("maxSessions"); + maxSessionsField.setAccessible(true); + Object sessionManagerObj = sessionManagerField.get( + tokenField.get(provider)); + maxSessionsField.setInt(sessionManagerObj, maxSessions); + } + + private static void tryCipherInit() throws Exception { + Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding", provider); + + // A CKR_OPERATION_ACTIVE error may be thrown if a session was + // returned to the Session Manager with an active operation, and + // we try to initialize the Cipher using it. + // + // Given that the maximum number of sessions was forced to 2, we know + // that the session to be used here was already used in a previous + // (failed) operation. Thus, the test asserts that the operation was + // properly cancelled. + cipher.init(Cipher.ENCRYPT_MODE, key); + + // If initialization passes, finish gracefully so other paths can + // be tested under the current maximum number of sessions. + cipher.doFinal(new byte[16], 0, 0); + } +} diff --git a/test/jdk/sun/security/pkcs11/KeyAgreement/IllegalPackageAccess.java b/test/jdk/sun/security/pkcs11/KeyAgreement/IllegalPackageAccess.java new file mode 100644 index 00000000000..f8448dd0713 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/KeyAgreement/IllegalPackageAccess.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.security.AllPermission; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.security.Provider; +import java.security.Security; +import java.security.spec.X509EncodedKeySpec; + +/* + * @test + * @bug 8259319 + * @library /test/lib .. + * @run main/othervm IllegalPackageAccess + */ + +public class IllegalPackageAccess extends PKCS11Test { + + private static Policy policy = Policy.getPolicy(); + private static RuntimePermission accessPerm = + new RuntimePermission("accessClassInPackage.com.sun.crypto.provider"); + + private static class MyPolicy extends Policy { + @Override + public PermissionCollection getPermissions(ProtectionDomain domain) { + PermissionCollection perms = new Permissions(); + perms.add(new AllPermission()); + return perms; + } + + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + if (permission.equals(accessPerm)) { + return policy.implies(domain, permission); + } + return super.implies(domain, permission); + } + } + + public static void main(String[] args) throws Exception { + main(new IllegalPackageAccess(), args); + System.out.println("TEST PASS - OK"); + } + + @Override + public void main(Provider p) throws Exception { + Policy.setPolicy(new MyPolicy()); + System.setSecurityManager(new SecurityManager()); + + // Remove all security providers so a fallback scheme + // that creates class instances is forced. + for (Provider provider : Security.getProviders()) { + Security.removeProvider(provider.getName()); + } + + KeyPair kp = KeyPairGenerator.getInstance("DH", p) + .generateKeyPair(); + byte[] encPubKey = kp.getPublic().getEncoded(); + KeyFactory kf = KeyFactory.getInstance("DH", p); + + // Requires access to a SunJCE class that parses + // the encoded key. + kf.generatePublic(new X509EncodedKeySpec(encPubKey)); + + System.setSecurityManager(null); + Policy.setPolicy(policy); + } + +} diff --git a/test/jdk/sun/security/pkcs11/KeyGenerator/HmacDefKeySizeTest.java b/test/jdk/sun/security/pkcs11/KeyGenerator/HmacDefKeySizeTest.java new file mode 100644 index 00000000000..d6707028d96 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/KeyGenerator/HmacDefKeySizeTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8242332 + * @summary Check that PKCS11 Hamc KeyGenerator picks appropriate default size + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @run main/othervm HmacDefKeySizeTest + * @run main/othervm HmacDefKeySizeTest sm + */ + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.util.List; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; + +public class HmacDefKeySizeTest extends PKCS11Test { + + /** + * Request a KeyGenerator object from PKCS11 provider for Hmac algorithm, + * and generate the SecretKey. + * + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception { + main(new HmacDefKeySizeTest(), args); + } + + @Override + public void main(Provider p) { + List algorithms = getSupportedAlgorithms("KeyGenerator", + "Hmac", p); + boolean success = true; + + for (String alg : algorithms) { + System.out.println("Testing " + alg); + try { + KeyGenerator kg = KeyGenerator.getInstance(alg, p); + SecretKey k1 = kg.generateKey(); + int keysize = k1.getEncoded().length << 3; + System.out.println("=> default key size = " + keysize); + kg.init(keysize); + SecretKey k2 = kg.generateKey(); + if ((k2.getEncoded().length << 3) != keysize) { + success = false; + System.out.println("keysize check failed"); + } + } catch (Exception e) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(); + success = false; + } + } + + if (!success) { + throw new RuntimeException("One or more tests failed"); + } + } +} diff --git a/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java b/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java index 2f63ca4b201..ae0e01e1ad5 100644 --- a/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java +++ b/test/jdk/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4917233 6461727 6490213 6720456 + * @bug 4917233 6461727 6490213 6720456 8242332 * @summary test the KeyGenerator * @author Andreas Sterbenz * @library /test/lib .. @@ -127,6 +127,18 @@ public void main(Provider p) throws Exception { test("ARCFOUR", 40, p, TestResult.PASS); test("ARCFOUR", 128, p, TestResult.PASS); + String[] HMAC_ALGS = { + "HmacSHA1", "HmacSHA224", "HmacSHA256", "HmacSHA384", "HmacSHA512", + "HmacSHA512/224", "HmacSHA512/256", "HmacSHA3-224", "HmacSHA3-256", + "HmacSHA3-384", "HmacSHA3-512", + }; + + for (String hmacAlg : HMAC_ALGS) { + test(hmacAlg, 0, p, TestResult.FAIL); + test(hmacAlg, 128, p, TestResult.PASS); + test(hmacAlg, 224, p, TestResult.PASS); + } + if (p.getName().equals("SunPKCS11-NSS")) { test("ARCFOUR", 1024, p, TestResult.PASS); test("ARCFOUR", 2048, p, TestResult.PASS); diff --git a/test/jdk/sun/security/pkcs11/Mac/MacSameTest.java b/test/jdk/sun/security/pkcs11/Mac/MacSameTest.java index 8638b5048f2..b44b2f4a5b9 100644 --- a/test/jdk/sun/security/pkcs11/Mac/MacSameTest.java +++ b/test/jdk/sun/security/pkcs11/Mac/MacSameTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8048603 + * @bug 8048603 8242332 * @summary Check if doFinal and update operation result in same Mac * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin * @library /test/lib .. @@ -40,13 +40,15 @@ import java.security.SecureRandom; import java.util.List; import javax.crypto.Mac; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class MacSameTest extends PKCS11Test { private static final int MESSAGE_SIZE = 25; private static final int OFFSET = 5; - private static final int KEY_SIZE = 70; + private static final int KEY_SIZE = 128; /** * Initialize a message, instantiate a Mac object, @@ -67,9 +69,30 @@ public static void main(String[] args) throws Exception { public void main(Provider p) { List algorithms = getSupportedAlgorithms("Mac", "Hmac", p); boolean success = true; + SecureRandom srdm = new SecureRandom(); + for (String alg : algorithms) { + // first try w/ java secret key object + byte[] keyVal = new byte[KEY_SIZE]; + srdm.nextBytes(keyVal); + SecretKey skey = new SecretKeySpec(keyVal, alg); + + try { + doTest(alg, skey, p); + } catch (Exception e) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(); + success = false; + } + try { - doTest(alg, p); + KeyGenerator kg = KeyGenerator.getInstance(alg, p); + kg.init(KEY_SIZE); + skey = kg.generateKey(); + doTest(alg, skey, p); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("Skip test using native key for " + alg); + continue; } catch (Exception e) { System.out.println("Unexpected exception: " + e); e.printStackTrace(); @@ -82,7 +105,7 @@ public void main(Provider p) { } } - private void doTest(String algo, Provider provider) + private void doTest(String algo, SecretKey key, Provider provider) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { System.out.println("Test " + algo); @@ -96,12 +119,7 @@ private void doTest(String algo, Provider provider) byte[] tail = new byte[plain.length - OFFSET]; System.arraycopy(plain, OFFSET, tail, 0, tail.length); - SecureRandom srdm = new SecureRandom(); - byte[] keyVal = new byte[KEY_SIZE]; - srdm.nextBytes(keyVal); - SecretKeySpec keySpec = new SecretKeySpec(keyVal, "HMAC"); - - mac.init(keySpec); + mac.init(key); byte[] result1 = mac.doFinal(plain); mac.reset(); diff --git a/test/jdk/sun/security/pkcs11/Mac/ReinitMac.java b/test/jdk/sun/security/pkcs11/Mac/ReinitMac.java index 5cad8859840..7e045232e3a 100644 --- a/test/jdk/sun/security/pkcs11/Mac/ReinitMac.java +++ b/test/jdk/sun/security/pkcs11/Mac/ReinitMac.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4856966 + * @bug 4856966 8242332 * @summary * @author Andreas Sterbenz * @library /test/lib .. @@ -35,6 +35,7 @@ import java.security.Provider; import java.util.Random; +import java.util.List; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -46,32 +47,49 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { - if (p.getService("Mac", "HmacMD5") == null) { - System.out.println(p + " does not support HmacMD5, skipping"); - return; - } + List algorithms = getSupportedAlgorithms("Mac", "Hmac", p); Random random = new Random(); - byte[] data1 = new byte[10 * 1024]; - random.nextBytes(data1); - byte[] keyData = new byte[16]; - random.nextBytes(keyData); - SecretKeySpec key = new SecretKeySpec(keyData, "Hmac"); - Mac mac = Mac.getInstance("HmacMD5", p); + byte[] data = new byte[10 * 1024]; + random.nextBytes(data); + byte[] keyVal = new byte[16]; + random.nextBytes(keyVal); + + boolean success = true; + for (String alg : algorithms) { + try { + doTest(alg, p, keyVal, data); + } catch (Exception e) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(); + success = false; + } + } + + if (!success) { + throw new RuntimeException("Test failed"); + } else { + System.out.println("All tests passed"); + } + } + + private void doTest(String alg, Provider p, byte[] keyVal, byte[] data) + throws Exception { + System.out.println("Testing " + alg); + SecretKeySpec key = new SecretKeySpec(keyVal, alg); + Mac mac = Mac.getInstance(alg, p); mac.init(key); mac.init(key); - mac.update(data1); + mac.update(data); mac.init(key); mac.doFinal(); mac.doFinal(); - mac.update(data1); + mac.update(data); mac.doFinal(); mac.reset(); mac.reset(); mac.init(key); mac.reset(); - mac.update(data1); + mac.update(data); mac.reset(); - - System.out.println("All tests passed"); } } diff --git a/test/jdk/sun/security/pkcs11/MessageDigest/ByteBuffers.java b/test/jdk/sun/security/pkcs11/MessageDigest/ByteBuffers.java index 7ced00630cc..a7a72e8ea3d 100644 --- a/test/jdk/sun/security/pkcs11/MessageDigest/ByteBuffers.java +++ b/test/jdk/sun/security/pkcs11/MessageDigest/ByteBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4856966 8080462 + * @bug 4856966 8080462 8242332 * @summary Test the MessageDigest.update(ByteBuffer) method * @author Andreas Sterbenz * @library /test/lib .. @@ -36,13 +36,10 @@ import java.security.*; import java.util.Arrays; import java.util.Random; +import java.util.List; public class ByteBuffers extends PKCS11Test { - static final String[] ALGS = { - "SHA-224", "SHA-256", "SHA-384", "SHA-512", "SHA-512/224", "SHA-512/256" - }; - private static Random random = new Random(); public static void main(String[] args) throws Exception { @@ -51,6 +48,9 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { + List ALGS = getSupportedAlgorithms("MessageDigest", + "SHA", p); + int n = 10 * 1024; byte[] t = new byte[n]; random.nextBytes(t); @@ -62,13 +62,7 @@ public void main(Provider p) throws Exception { private void runTest(Provider p, String alg, byte[] data) throws Exception { System.out.println("Test against " + p.getName() + " and " + alg); - MessageDigest md; - try { - md = MessageDigest.getInstance(alg, p); - } catch (NoSuchAlgorithmException e) { - System.out.println("Skip " + alg + " due to no support"); - return; - } + MessageDigest md = MessageDigest.getInstance(alg, p); byte[] d1 = md.digest(data); diff --git a/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java b/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java index ea7909bc397..268f698276b 100644 --- a/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java +++ b/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4856966 + * @bug 4856966 8242332 * @summary * @author Andreas Sterbenz * @library /test/lib .. @@ -37,6 +37,7 @@ import java.security.Provider; import java.util.Arrays; import java.util.Random; +import java.util.List; public class ReinitDigest extends PKCS11Test { @@ -46,19 +47,37 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { - if (p.getService("MessageDigest", "MD5") == null) { - System.out.println("Provider does not support MD5, skipping"); - return; - } + List ALGS = getSupportedAlgorithms("MessageDigest", + "SHA", p); Random r = new Random(); byte[] data1 = new byte[10 * 1024]; byte[] data2 = new byte[10 * 1024]; r.nextBytes(data1); r.nextBytes(data2); - MessageDigest md; - md = MessageDigest.getInstance("MD5", "SUN"); + + boolean success = true; + for (String alg : ALGS) { + try { + doTest(alg, p, data1, data2); + } catch (Exception e) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(); + success = false; + } + } + + if (!success) { + throw new RuntimeException("Test failed"); + } + System.out.println("All tests passed"); + } + + private void doTest(String alg, Provider p, byte[] data1, byte[] data2) + throws Exception { + System.out.println("Testing " + alg); + MessageDigest md = MessageDigest.getInstance(alg, "SUN"); byte[] d1 = md.digest(data1); - md = MessageDigest.getInstance("MD5", p); + md = MessageDigest.getInstance(alg, p); byte[] d2 = md.digest(data1); check(d1, d2); byte[] d3 = md.digest(data1); @@ -68,7 +87,6 @@ public void main(Provider p) throws Exception { md.reset(); byte[] d4 = md.digest(data1); check(d1, d4); - System.out.println("All tests passed"); } private static void check(byte[] d1, byte[] d2) throws Exception { diff --git a/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java b/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java index b931c8564b2..ace601c7233 100644 --- a/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java +++ b/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6414899 + * @bug 6414899 8242332 * @summary Ensure the cloning functionality works. * @author Valerie Peng * @library /test/lib .. @@ -37,13 +37,10 @@ import java.security.Provider; import java.util.Arrays; import java.util.Random; +import java.util.List; public class TestCloning extends PKCS11Test { - private static final String[] ALGOS = { - "MD2", "MD5", "SHA1", "SHA-224", "SHA-256", "SHA-384", "SHA-512" - }; - public static void main(String[] args) throws Exception { main(new TestCloning(), args); } @@ -51,44 +48,28 @@ public static void main(String[] args) throws Exception { private static final byte[] data1 = new byte[10]; private static final byte[] data2 = new byte[10*1024]; - @Override public void main(Provider p) throws Exception { + List ALGS = getSupportedAlgorithms("MessageDigest", "SHA", p); Random r = new Random(); byte[] data1 = new byte[10]; byte[] data2 = new byte[2*1024]; r.nextBytes(data1); r.nextBytes(data2); System.out.println("Testing against provider " + p.getName()); - for (int i = 0; i < ALGOS.length; i++) { - if (p.getService("MessageDigest", ALGOS[i]) == null) { - System.out.println(ALGOS[i] + " is not supported, skipping"); - continue; - } else { - System.out.println("Testing " + ALGOS[i] + " of " + p.getName()); - MessageDigest md = MessageDigest.getInstance(ALGOS[i], p); - try { - md = testCloning(md, p); - // repeat the test again after generating digest once - for (int j = 0; j < 10; j++) { - md = testCloning(md, p); - } - } catch (Exception ex) { - if (ALGOS[i] == "MD2" && - p.getName().equalsIgnoreCase("SunPKCS11-NSS")) { - // known bug in NSS; ignore for now - System.out.println("Ignore Known bug in MD2 of NSS"); - continue; - } - throw ex; - } + for (String alg : ALGS) { + System.out.println("Testing " + alg); + MessageDigest md = MessageDigest.getInstance(alg, p); + md = testCloning(md, p); + // repeat the test again after generating digest once + for (int j = 0; j < 10; j++) { + md = testCloning(md, p); } } } private static MessageDigest testCloning(MessageDigest mdObj, Provider p) - throws Exception { - + throws Exception { // copy#0: clone at state BLANK w/o any data MessageDigest mdCopy0 = (MessageDigest) mdObj.clone(); diff --git a/test/jdk/sun/security/pkcs11/Provider/CheckRegistration.java b/test/jdk/sun/security/pkcs11/Provider/CheckRegistration.java new file mode 100644 index 00000000000..cb631b750e2 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Provider/CheckRegistration.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8258851 + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @run main CheckRegistration + * @summary Ensure SunPKCS11 provider service registration matches the actual + * impl class + */ + +import java.security.Provider; +import java.util.Set; + +public class CheckRegistration extends PKCS11Test { + + public static void main(String[] args) throws Exception { + main(new CheckRegistration(), args); + } + + @Override + public void main(Provider p) throws Exception { + Set services = p.getServices(); + + for (Provider.Service s : services) { + String key = s.getType() + "." + s.getAlgorithm(); + Object val = p.get(key); + System.out.println("Checking " + key + " : " + s.getClassName()); + if (val == null) { + throw new RuntimeException("Missing mapping"); + } + if (!s.getClassName().equals(val)) { + System.out.println("Mapping value: " + val); + throw new RuntimeException("Mapping mismatches"); + } + Object o = s.newInstance(null); + if (!s.getClassName().equals(o.getClass().getName())) { + System.out.println("Actual impl: " + o.getClass().getName()); + throw new RuntimeException("Impl class mismatches"); + } + } + System.out.println("Test Passed"); + } +} diff --git a/test/jdk/sun/security/pkcs11/Signature/ByteBuffers.java b/test/jdk/sun/security/pkcs11/Signature/ByteBuffers.java index 0a6e1a11fd1..5416b04debf 100644 --- a/test/jdk/sun/security/pkcs11/Signature/ByteBuffers.java +++ b/test/jdk/sun/security/pkcs11/Signature/ByteBuffers.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4856966 + * @bug 4856966 8242332 * @summary Test the Signature.update(ByteBuffer) method * @author Andreas Sterbenz * @library /test/lib .. @@ -55,10 +55,10 @@ public void main(Provider p) throws Exception { random.nextBytes(t); KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); - kpg.initialize(512); + kpg.initialize(2048); KeyPair kp = kpg.generateKeyPair(); - Signature sig = Signature.getInstance("MD5withRSA", p); + Signature sig = Signature.getInstance("SHA256withRSA", p); sig.initSign(kp.getPrivate()); sig.update(t); byte[] signature = sig.sign(); diff --git a/test/jdk/sun/security/pkcs11/Signature/InitAgainPSS.java b/test/jdk/sun/security/pkcs11/Signature/InitAgainPSS.java index ccd66599fb0..a2fa7294977 100644 --- a/test/jdk/sun/security/pkcs11/Signature/InitAgainPSS.java +++ b/test/jdk/sun/security/pkcs11/Signature/InitAgainPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /** * @test - * @bug 8080462 + * @bug 8080462 8242332 * @summary Make sure old state is cleared when init is called again * @library /test/lib .. * @modules jdk.crypto.cryptoki @@ -38,18 +38,22 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { + test("RSASSA-PSS", p); + } + + private void test(String sigAlg, Provider p) throws Exception { Signature s1; try { - s1 = Signature.getInstance("RSASSA-PSS", p); + s1 = Signature.getInstance(sigAlg, p); } catch (NoSuchAlgorithmException e) { - System.out.println("Skip testing RSASSA-PSS" + + System.out.println("Skip testing " + sigAlg + " due to no support"); return; } byte[] msg = "hello".getBytes(); - Signature s2 = Signature.getInstance("RSASSA-PSS", p); + Signature s2 = Signature.getInstance(sigAlg, p); PSSParameterSpec params = new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, diff --git a/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java b/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java index 2e4fedbf1d5..f1c0492b5fc 100644 --- a/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java +++ b/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ /** * @test - * @bug 8080462 8226651 + * @bug 8080462 8226651 8242332 * @summary Ensure that PSS key and params check are implemented properly * regardless of call sequence * @library /test/lib .. @@ -55,6 +55,7 @@ public void main(Provider p) throws Exception { " due to no support"); return; } + // NOTE: key length >= (digest length + 2) in bytes // otherwise, even salt length = 0 would not work runTest(p, 1024, "SHA-256", "SHA-256"); @@ -66,10 +67,30 @@ public void main(Provider p) throws Exception { runTest(p, 1040, "SHA-512", "SHA-256"); runTest(p, 1040, "SHA-512", "SHA-384"); runTest(p, 1040, "SHA-512", "SHA-512"); + runTest(p, 1024, "SHA3-256", "SHA3-256"); + runTest(p, 1024, "SHA3-256", "SHA3-384"); + runTest(p, 1024, "SHA3-256", "SHA3-512"); + runTest(p, 1024, "SHA3-384", "SHA3-256"); + runTest(p, 1024, "SHA3-384", "SHA3-384"); + runTest(p, 1024, "SHA3-384", "SHA3-512"); + runTest(p, 1040, "SHA3-512", "SHA3-256"); + runTest(p, 1040, "SHA3-512", "SHA3-384"); + runTest(p, 1040, "SHA3-512", "SHA3-512"); } private void runTest(Provider p, int keySize, String hashAlg, String mgfHashAlg) throws Exception { + + // skip further test if this provider does not support hashAlg or + // mgfHashAlg + try { + MessageDigest.getInstance(hashAlg, p); + MessageDigest.getInstance(mgfHashAlg, p); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("No support for " + hashAlg + ", skip"); + return; + } + System.out.println("Testing [" + keySize + " " + hashAlg + "]"); // create a key pair with the supplied size @@ -95,6 +116,7 @@ private void runTest(Provider p, int keySize, String hashAlg, } catch (InvalidKeyException ike) { System.out.println("test#1: got expected IKE"); } + sig.setParameter(paramsGood); sig.initSign(priv); System.out.println("test#1: pass"); @@ -108,8 +130,10 @@ private void runTest(Provider p, int keySize, String hashAlg, } catch (InvalidKeyException ike) { System.out.println("test#2: got expected IKE"); } + sig.setParameter(paramsGood); sig.initVerify(pub); + System.out.println("test#2: pass"); // test#3 - initSign, then setParameter @@ -121,6 +145,7 @@ private void runTest(Provider p, int keySize, String hashAlg, } catch (InvalidAlgorithmParameterException iape) { System.out.println("test#3: got expected IAPE"); } + sig.setParameter(paramsGood); System.out.println("test#3: pass"); @@ -133,6 +158,7 @@ private void runTest(Provider p, int keySize, String hashAlg, } catch (InvalidAlgorithmParameterException iape) { System.out.println("test#4: got expected IAPE"); } + sig.setParameter(paramsGood); System.out.println("test#4: pass"); } diff --git a/test/jdk/sun/security/pkcs11/Signature/ReinitSignature.java b/test/jdk/sun/security/pkcs11/Signature/ReinitSignature.java index 1c61aceb5ad..4eef23559b8 100644 --- a/test/jdk/sun/security/pkcs11/Signature/ReinitSignature.java +++ b/test/jdk/sun/security/pkcs11/Signature/ReinitSignature.java @@ -23,312 +23,13 @@ /* * @test - * @bug 4856966 + * @bug 4856966 8242332 * @summary test that reinitializing Signatures works correctly * @author Andreas Sterbenz * @library /test/lib .. * @key randomness * @modules jdk.crypto.cryptoki * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature - * @run main ReinitSignature */ import java.security.KeyPair; @@ -348,11 +49,11 @@ public static void main(String[] args) throws Exception { public void main(Provider p) throws Exception { KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); - kpg.initialize(512); + kpg.initialize(2048); KeyPair kp = kpg.generateKeyPair(); PrivateKey privateKey = kp.getPrivate(); PublicKey publicKey = kp.getPublic(); - Signature sig = Signature.getInstance("MD5withRSA", p); + Signature sig = Signature.getInstance("SHA256withRSA", p); byte[] data = new byte[10 * 1024]; new Random().nextBytes(data); sig.initSign(privateKey); diff --git a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java index 3c3edb5aa6a..11147022771 100644 --- a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java +++ b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ /* * @test - * @bug 8080462 8226651 + * @bug 8080462 8226651 8242332 * @summary testing interoperability of PSS signatures of PKCS11 provider * against SunRsaSign provider * @library /test/lib .. diff --git a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java new file mode 100644 index 00000000000..b8ea9863327 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.security.*; +import java.security.spec.*; +import java.security.interfaces.*; + +/* + * @test + * @bug 8080462 8226651 8242332 + * @summary testing interoperability of PSS signatures of PKCS11 provider + * against SunRsaSign provider + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @run main/othervm SigInteropPSS2 + */ +public class SigInteropPSS2 extends PKCS11Test { + + private static final byte[] MSG = + "Interoperability test between SunRsaSign and SunPKCS11".getBytes(); + + private static final String[] DIGESTS = { + "SHA224", "SHA256", "SHA384", "SHA512", + "SHA3-224", "SHA3-256", "SHA3-384", "SHA3-512" + }; + + public static void main(String[] args) throws Exception { + main(new SigInteropPSS2(), args); + } + + @Override + public void main(Provider p) throws Exception { + + Signature sigPkcs11; + Signature sigSunRsaSign = + Signature.getInstance("RSASSA-PSS", "SunRsaSign"); + + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); + kpg.initialize(3072); + KeyPair kp = kpg.generateKeyPair(); + + for (String digest : DIGESTS) { + try { + sigPkcs11 = Signature.getInstance(digest + "withRSASSA-PSS", p); + } catch (NoSuchAlgorithmException e) { + System.out.println("Skip testing " + digest + "withRSASSA-PSS" + + " due to no support"); + continue; + } + + runTest(sigPkcs11, sigSunRsaSign, kp); + } + System.out.println("Test passed"); + } + + static void runTest(Signature signer, Signature verifier, KeyPair kp) + throws Exception { + System.out.println("\tSign: " + signer.getProvider().getName()); + System.out.println("\tVerify: " + verifier.getProvider().getName()); + + signer.initSign(kp.getPrivate()); + signer.update(MSG); + byte[] sigBytes = signer.sign(); + + AlgorithmParameters signParams = signer.getParameters(); + verifier.setParameter(signParams.getParameterSpec + (PSSParameterSpec.class)); + verifier.initVerify(kp.getPublic()); + + verifier.update(MSG); + boolean isValid = verifier.verify(sigBytes); + if (isValid) { + System.out.println("\tPSS Signature verified"); + } else { + throw new RuntimeException("ERROR verifying PSS Signature"); + } + } +} diff --git a/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java index 3a6dbe345e9..4c1f7284bbc 100644 --- a/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java +++ b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ /** * @test - * @bug 8080462 8226651 + * @bug 8080462 8226651 8242332 * @summary Generate a RSASSA-PSS signature and verify it using PKCS11 provider * @library /test/lib .. * @modules jdk.crypto.cryptoki @@ -40,8 +40,10 @@ public class SignatureTestPSS extends PKCS11Test { private static final String SIGALG = "RSASSA-PSS"; private static final int[] KEYSIZES = { 2048, 3072 }; - private static final String[] DIGESTS = { "SHA-224", "SHA-256", - "SHA-384" , "SHA-512" }; + private static final String[] DIGESTS = { + "SHA-224", "SHA-256", "SHA-384" , "SHA-512", + "SHA3-224", "SHA3-256", "SHA3-384" , "SHA3-512", + }; private Provider prov; /** @@ -115,7 +117,22 @@ private void checkSignature(byte[] data, PublicKey pub, throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, NoSuchProviderException, InvalidAlgorithmParameterException { - System.out.println("Testing against " + hash + " and MGF1_" + mgfHash); + + String testName = hash + " and MGF1_" + mgfHash; + // only test RSASSA-PSS signature against the supplied hash/mgfHash + // if they are supported; otherwise PKCS11 library will throw + // CKR_MECHANISM_PARAM_INVALID at Signature.initXXX calls + try { + MessageDigest md = MessageDigest.getInstance(hash, prov); + if (!hash.equalsIgnoreCase(mgfHash)) { + md = MessageDigest.getInstance(mgfHash, prov); + } + } catch (NoSuchAlgorithmException nsae) { + System.out.println("Skip testing " + hash + "/" + mgfHash); + return; + } + + System.out.println("Testing against " + testName); Signature sig = Signature.getInstance(SIGALG, prov); AlgorithmParameterSpec params = new PSSParameterSpec( hash, "MGF1", new MGF1ParameterSpec(mgfHash), 0, 1); diff --git a/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS2.java b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS2.java new file mode 100644 index 00000000000..516b17972e5 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS2.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.security.*; +import java.security.interfaces.*; +import java.security.spec.*; +import java.util.stream.IntStream; + +/** + * @test + * @bug 8244154 8242332 + * @summary Generate a withRSASSA-PSS signature and verify it using + * PKCS11 provider + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @run main SignatureTestPSS2 + */ +public class SignatureTestPSS2 extends PKCS11Test { + + // PKCS11 does not support RSASSA-PSS keys yet + private static final String KEYALG = "RSA"; + private static final String[] SIGALGS = { + "SHA224withRSASSA-PSS", "SHA256withRSASSA-PSS", + "SHA384withRSASSA-PSS", "SHA512withRSASSA-PSS", + "SHA3-224withRSASSA-PSS", "SHA3-256withRSASSA-PSS", + "SHA3-384withRSASSA-PSS", "SHA3-512withRSASSA-PSS" + }; + + private static final int[] KEYSIZES = { 2048, 3072 }; + + /** + * How much times signature updated. + */ + private static final int UPDATE_TIMES = 2; + + public static void main(String[] args) throws Exception { + main(new SignatureTestPSS2(), args); + } + + @Override + public void main(Provider p) throws Exception { + for (String sa : SIGALGS) { + Signature sig; + try { + sig = Signature.getInstance(sa, p); + } catch (NoSuchAlgorithmException e) { + System.out.println("Skip testing " + sa + + " due to no support"); + return; + } + for (int i : KEYSIZES) { + runTest(sig, i); + } + } + } + + private static void runTest(Signature s, int keySize) throws Exception { + byte[] data = new byte[100]; + IntStream.range(0, data.length).forEach(j -> { + data[j] = (byte) j; + }); + System.out.println("[KEYSIZE = " + keySize + "]"); + + // create a key pair + KeyPair kpair = generateKeys(KEYALG, keySize, s.getProvider()); + test(s, kpair.getPrivate(), kpair.getPublic(), data); + } + + private static void test(Signature sig, PrivateKey privKey, + PublicKey pubKey, byte[] data) throws RuntimeException { + // For signature algorithm, create and verify a signature + try { + checkSignature(sig, privKey, pubKey, data); + } catch (NoSuchAlgorithmException | InvalidKeyException | + SignatureException | NoSuchProviderException ex) { + throw new RuntimeException(ex); + } catch (InvalidAlgorithmParameterException ex2) { + System.out.println("Skip test due to " + ex2); + } + } + + private static KeyPair generateKeys(String keyalg, int size, Provider p) + throws NoSuchAlgorithmException { + KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyalg, p); + kpg.initialize(size); + return kpg.generateKeyPair(); + } + + private static void checkSignature(Signature sig, PrivateKey priv, + PublicKey pub, byte[] data) throws NoSuchAlgorithmException, + InvalidKeyException, SignatureException, NoSuchProviderException, + InvalidAlgorithmParameterException { + System.out.println("Testing against " + sig.getAlgorithm()); + sig.initSign(priv); + for (int i = 0; i < UPDATE_TIMES; i++) { + sig.update(data); + } + byte[] signedData = sig.sign(); + + // Make sure signature verifies with original data + // do we need to call sig.setParameter(params) again? + sig.initVerify(pub); + for (int i = 0; i < UPDATE_TIMES; i++) { + sig.update(data); + } + if (!sig.verify(signedData)) { + throw new RuntimeException("Failed to verify signature"); + } + + // Make sure signature does NOT verify when the original data + // has changed + sig.initVerify(pub); + for (int i = 0; i < UPDATE_TIMES + 1; i++) { + sig.update(data); + } + + if (sig.verify(signedData)) { + throw new RuntimeException("Failed to detect bad signature"); + } + } +} diff --git a/test/jdk/sun/security/pkcs11/Signature/TestDSA2.java b/test/jdk/sun/security/pkcs11/Signature/TestDSA2.java index 222f8a2a5ed..3161de6fc50 100644 --- a/test/jdk/sun/security/pkcs11/Signature/TestDSA2.java +++ b/test/jdk/sun/security/pkcs11/Signature/TestDSA2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* * @test - * @bug 8080462 + * @bug 8080462 8242332 * @library /test/lib .. * @modules jdk.crypto.cryptoki * @run main/othervm/timeout=250 TestDSA2 @@ -40,8 +40,12 @@ public class TestDSA2 extends PKCS11Test { private static final String[] SIG_ALGOS = { "SHA224withDSA", "SHA256withDSA", - //"SHA384withDSA", - //"SHA512withDSA", + "SHA3-224withDSA", + "SHA3-256withDSA", + "SHA384withDSA", + "SHA512withDSA", + "SHA3-384withDSA", + "SHA3-512withDSA", }; private static final int KEYSIZE = 2048; @@ -59,25 +63,33 @@ public void main(Provider p) throws Exception { kp = kpg.generateKeyPair(); } catch (Exception ex) { System.out.println("Skip due to no 2048-bit DSA support: " + ex); - ex.printStackTrace(); return; } + boolean allPass = true; for (String sigAlg : SIG_ALGOS) { - test(sigAlg, kp, p); + System.out.println("Testing " + sigAlg); + try { + Signature sig = Signature.getInstance(sigAlg, p); + test(sig, kp, p); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("=>Skip due to no support"); + } catch (Exception ex) { + System.out.println("Unexpected exception when testing " + + sigAlg); + ex.printStackTrace(); + allPass = false; + } + } + if (allPass) { + System.out.println("Tests Passed"); + } else { + throw new RuntimeException("One or more tests failed"); } } - private static void test(String sigAlg, KeyPair kp, Provider p) + private static void test(Signature sig, KeyPair kp, Provider p) throws Exception { - Signature sig; - try { - sig = Signature.getInstance(sigAlg, p); - } catch (Exception ex) { - System.out.println("Skip due to no support: " + sigAlg); - ex.printStackTrace(); - return; - } byte[] data = "anything will do".getBytes(); @@ -85,9 +97,10 @@ private static void test(String sigAlg, KeyPair kp, Provider p) sig.update(data); byte[] signature = sig.sign(); - sig.initVerify(kp.getPublic()); - sig.update(data); - boolean verifies = sig.verify(signature); - System.out.println(sigAlg + ": Passed"); + Signature sigV = Signature.getInstance(sig.getAlgorithm() , p); + sigV.initVerify(kp.getPublic()); + sigV.update(data); + boolean verifies = sigV.verify(signature); + System.out.println("=> Passed"); } } diff --git a/test/jdk/sun/security/pkcs11/Signature/TestRSAKeyLength.java b/test/jdk/sun/security/pkcs11/Signature/TestRSAKeyLength.java index f553dcbe6db..004cb99d601 100644 --- a/test/jdk/sun/security/pkcs11/Signature/TestRSAKeyLength.java +++ b/test/jdk/sun/security/pkcs11/Signature/TestRSAKeyLength.java @@ -22,8 +22,8 @@ */ /* - * @test %W% %E% - * @bug 6695485 + * @test + * @bug 6695485 8242332 * @summary Make sure initSign/initVerify() check RSA key lengths * @author Yu-Ching Valerie Peng * @library /test/lib .. @@ -50,9 +50,14 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { - boolean isValidKeyLength[] = { true, true, true, false, false }; - String algos[] = { "SHA1withRSA", "SHA224withRSA", "SHA256withRSA", - "SHA384withRSA", "SHA512withRSA" }; + boolean isValidKeyLength[] = { + true, true, true, false, false, true, true, false, false + }; + String algos[] = { + "SHA1withRSA", "SHA224withRSA", "SHA256withRSA", + "SHA384withRSA", "SHA512withRSA", "SHA3-224withRSA", + "SHA3-256withRSA", "SHA3-384withRSA", "SHA3-512withRSA" + }; KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); kpg.initialize(512); KeyPair kp = kpg.generateKeyPair(); diff --git a/test/jdk/sun/security/pkcs11/nss/p11-nss.txt b/test/jdk/sun/security/pkcs11/nss/p11-nss.txt index 49778ea954c..576b1dc4d69 100644 --- a/test/jdk/sun/security/pkcs11/nss/p11-nss.txt +++ b/test/jdk/sun/security/pkcs11/nss/p11-nss.txt @@ -11,12 +11,23 @@ library = ${pkcs11test.nss.lib} nssArgs = "configdir='${pkcs11test.nss.db}' certPrefix='' keyPrefix='' secmod='secmod.db' flags=readOnly" -# HMAC_SHA256/384/512 broken until NSS 3.10.2 -# see https://bugzilla.mozilla.org/show_bug.cgi?id=291858 disabledMechanisms = { - CKM_SHA256_HMAC - CKM_SHA384_HMAC - CKM_SHA512_HMAC + CKM_DSA_SHA224 + CKM_DSA_SHA256 + CKM_DSA_SHA384 + CKM_DSA_SHA512 + CKM_DSA_SHA3_224 + CKM_DSA_SHA3_256 + CKM_DSA_SHA3_384 + CKM_DSA_SHA3_512 + CKM_ECDSA_SHA224 + CKM_ECDSA_SHA256 + CKM_ECDSA_SHA384 + CKM_ECDSA_SHA512 + CKM_ECDSA_SHA3_224 + CKM_ECDSA_SHA3_256 + CKM_ECDSA_SHA3_384 + CKM_ECDSA_SHA3_512 } attributes = compatibility diff --git a/test/jdk/sun/security/pkcs11/rsa/TestKeyFactory.java b/test/jdk/sun/security/pkcs11/rsa/TestKeyFactory.java index 2b26a52b0c8..065f22e7181 100644 --- a/test/jdk/sun/security/pkcs11/rsa/TestKeyFactory.java +++ b/test/jdk/sun/security/pkcs11/rsa/TestKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4856966 + * @bug 4856966 8023980 * @summary Test KeyFactory of the new RSA provider * @author Andreas Sterbenz * @library /test/lib .. @@ -42,6 +42,84 @@ public class TestKeyFactory extends PKCS11Test { private static final char[] password = "test12".toCharArray(); + private static final String PKCS1_PRIV_STR = + // the BASE64 string between -----BEGIN RSA PRIVATE KEY----- + // and -----END RSA PRIVATE KEY----- + "MIIEowIBAAKCAQEA0OIArlYES4X1XMTLDordtN/XIWFE1wvhl40RsHWM2n99+Stp" + + "CCJCcUb5FJ2/kefj/XRwB6p5IMpIZrHZqC8XXzlX5fpiFaSu2xnk17oWUKoErW27" + + "Stm098pU2RoUxWPKVl+42a8iVp8tijNElBNFALCGi0zXOhcTxMh0q1Wk0UhMJqam" + + "v5YnCKmT4THwwGYn/KeK3M7Qa+o5MoVBHLbeT9LJgEmSluVzIh44Lh6weX0bw72P" + + "8X2praOhbzg2B343MqS/rMLw6On+0i7ccEgp23vX9G5w85q4A5FSIrk4S/pyv5sO" + + "rwjCQKBW1TS0/2iB9zNkFMj5/+h7l2oqTT7sSQIDAQABAoIBADn6sXOynoiUC1IP" + + "sck8lGOTSjSSujfyrVCSsJlJV6qCfuX9va6rS8QDjjnBu531PtxoSHxoPizy2Pvg" + + "W+kKATPGR/am9DjLuFlKq7GRjoYfWyMEdVtGaKvq9ng4fBF6LHyjHz0VFrPyhQJ6" + + "TovHeXzCguYBkzAlnbAeb/vqzs/kABbOuSHVi7DsaixCoEX9zOptFYQw/l8rh68+" + + "UF2bpNNH3jOC1uN3vZtuSwCupqtN+2Mpkx2h04Rk75vWIhrnPeMgmcd3yP4LNZMR" + + "mfaynb63RRzVkNis7+NVk016SQ1oL79mrBvy5rBg3HeCeArwvqZAmOaWsLSWHzCy" + + "zlVlMTECgYEA6JlnMpC956Qi8HX5ye4Hu2ovBdbNGtH/TMkZmColJz9P7CvNkNIb" + + "Od6mvLMydbPHkhdBUDWD4rhiCKHrf5zKju1i24YqWcvuSGotWj4/KQ3+87mLZM+7" + + "daBsJBmSEVB80sgA9ItqSgOyNoNFpiDgFnlszAfb0n9XXEzB/pwSw1UCgYEA5eXI" + + "d+eKugugP+n6CluQfyxfN6WWCzfqWToCTTxPn2i12AiEssXy+kyLjupJVLWSivdo" + + "83wD5LuxFRGc9P+aKQERPhb0AFaxf1llUCXla65/x2So5xjMvtuzgQ0OktPJqJXq" + + "hYGunctsr5rje33+7vlx4xWkrL2PrQWzJabn7SUCgYEAqw3FesY/Ik7u8u+P1xSZ" + + "0xXvptek1oiAu7NYgzLbR9WjrQc5kbsyEojPDg6qmSyxI5q+iYIRj3YRgk+xpJNl" + + "0154SQCNvKPghJiw6aDFSifkytA01tp9/a8QWCwF433RjiFPsoekjvHQ6Y34dofO" + + "xDhf7lwJKPBFCrfYIqocklECgYAIPI9OHHGP8NKw94UJ0fX/WGug5sHVbQ9sWvOy" + + "KLMBlxLMxqFadlUaOpvVZvdxnX++ktajwpGxJDhX9OWWsYGobm1buB7N1E1Prrg+" + + "gt0RWpMhZa3Xeb/8Jorr2Lfo8sWK0LQyTE8hQCSIthfoWL9FeJJn/GKF/dSj8kxU" + + "0QIGMQKBgG/8U/zZ87DzfXS81P1p+CmH474wmou4KD2/zXp/lDR9+dlIUeijlIbU" + + "P6Y5xJvT33Y40giW9irShgDHjZgw0ap11K3b2HzLImdPEaBiENo735rpLs8WLK9H" + + "+yeRbiP2y9To7sTihm9Jrkctzp6sqFtKyye1+S21X1tMz8NGfXen"; + + private static final String PKCS1_PUB_STR = + // the BASE64 string between -----BEGIN RSA PUBLIC KEY----- + // and -----END RSA PUBLIC KEY----- + "MIIBCgKCAQEA0OIArlYES4X1XMTLDordtN/XIWFE1wvhl40RsHWM2n99+StpCCJC" + + "cUb5FJ2/kefj/XRwB6p5IMpIZrHZqC8XXzlX5fpiFaSu2xnk17oWUKoErW27Stm0" + + "98pU2RoUxWPKVl+42a8iVp8tijNElBNFALCGi0zXOhcTxMh0q1Wk0UhMJqamv5Yn" + + "CKmT4THwwGYn/KeK3M7Qa+o5MoVBHLbeT9LJgEmSluVzIh44Lh6weX0bw72P8X2p" + + "raOhbzg2B343MqS/rMLw6On+0i7ccEgp23vX9G5w85q4A5FSIrk4S/pyv5sOrwjC" + + "QKBW1TS0/2iB9zNkFMj5/+h7l2oqTT7sSQIDAQAB"; + + + private static final PrivateKey CUSTOM_PRIV; + private static final PublicKey CUSTOM_PUB; + + static { + byte[] encodedPriv = Base64.getDecoder().decode(PKCS1_PRIV_STR); + CUSTOM_PRIV = new PrivateKey() { + @Override + public String getAlgorithm() { + return "RSA"; + } + @Override + public String getFormat() { + return "PKCS#1"; + } + @Override + public byte[] getEncoded() { + // skip cloning for testing key. + return encodedPriv; + } + }; + byte[] encodedPub = Base64.getDecoder().decode(PKCS1_PUB_STR); + CUSTOM_PUB = new PublicKey() { + @Override + public String getAlgorithm() { + return "RSA"; + } + @Override + public String getFormat() { + return "PKCS#1"; + } + @Override + public byte[] getEncoded() { + // skip cloning for testing key. + return encodedPub; + } + }; + } + static KeyStore getKeyStore() throws Exception { KeyStore ks; try (InputStream in = new FileInputStream(new File(BASE, "rsakeys.ks"))) { @@ -68,44 +146,64 @@ private static void testKey(Key key1, Key key2) throws Exception { throw new Exception("Format not PKCS#8"); } } - if (key1.equals(key2) == false) { - throw new Exception("Keys not equal"); + // skip equals check when key1 is custom key + if (key1 != CUSTOM_PRIV && key1 != CUSTOM_PUB) { + if (!key1.equals(key2)) { + throw new Exception("Keys not equal"); + } } - if (Arrays.equals(key1.getEncoded(), key2.getEncoded()) == false) { + // only compare encodings if keys are of the same format + if (key1.getFormat().equals(key2.getFormat()) && + !Arrays.equals(key1.getEncoded(), key2.getEncoded())) { throw new Exception("Encodings not equal"); } } - private static void testPublic(KeyFactory kf, PublicKey key) throws Exception { - System.out.println("Testing public key..."); + private static void testPublic(KeyFactory kf, PublicKey key) + throws Exception { + System.out.println("Testing " + (key == CUSTOM_PUB? "PKCS#1" : "") + + " public key..."); PublicKey key2 = (PublicKey)kf.translateKey(key); KeySpec rsaSpec = kf.getKeySpec(key, RSAPublicKeySpec.class); PublicKey key3 = kf.generatePublic(rsaSpec); KeySpec x509Spec = kf.getKeySpec(key, X509EncodedKeySpec.class); PublicKey key4 = kf.generatePublic(x509Spec); - KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded()); - PublicKey key5 = kf.generatePublic(x509Spec2); - testKey(key, key); + if (key != CUSTOM_PUB) { + testKey(key, key); + } testKey(key, key2); testKey(key, key3); testKey(key, key4); - testKey(key, key5); + + if (key.getFormat().equalsIgnoreCase("X.509")) { + KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded()); + PublicKey key5 = kf.generatePublic(x509Spec2); + testKey(key, key5); + } + } - private static void testPrivate(KeyFactory kf, PrivateKey key) throws Exception { - System.out.println("Testing private key..."); + private static void testPrivate(KeyFactory kf, PrivateKey key) + throws Exception { + System.out.println("Testing " + (key == CUSTOM_PRIV? "PKCS#1" : "") + + " private key..."); PrivateKey key2 = (PrivateKey)kf.translateKey(key); KeySpec rsaSpec = kf.getKeySpec(key, RSAPrivateCrtKeySpec.class); PrivateKey key3 = kf.generatePrivate(rsaSpec); KeySpec pkcs8Spec = kf.getKeySpec(key, PKCS8EncodedKeySpec.class); PrivateKey key4 = kf.generatePrivate(pkcs8Spec); - KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded()); - PrivateKey key5 = kf.generatePrivate(pkcs8Spec2); - testKey(key, key); + if (key != CUSTOM_PRIV) { + testKey(key, key); + } testKey(key, key2); testKey(key, key3); testKey(key, key4); - testKey(key, key5); + + if (key.getFormat().equalsIgnoreCase("PKCS#8")) { + KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded()); + PrivateKey key5 = kf.generatePrivate(pkcs8Spec2); + testKey(key, key5); + } // XXX PKCS#11 providers may not support non-CRT keys (e.g. NSS) // KeySpec rsaSpec2 = kf.getKeySpec(key, RSAPrivateKeySpec.class); @@ -145,6 +243,10 @@ public void main(Provider p) throws Exception { test(kf, ks.getCertificate(alias).getPublicKey()); } } + // repeat the test w/ PKCS#1 RSA Private Key + test(kf, CUSTOM_PRIV); + test(kf, CUSTOM_PUB); + long stop = System.currentTimeMillis(); System.out.println("All tests passed (" + (stop - start) + " ms)."); } diff --git a/test/jdk/sun/security/pkcs11/tls/TestLeadingZeroesP11.java b/test/jdk/sun/security/pkcs11/tls/TestLeadingZeroesP11.java index beae7253df3..b594b3e066e 100644 --- a/test/jdk/sun/security/pkcs11/tls/TestLeadingZeroesP11.java +++ b/test/jdk/sun/security/pkcs11/tls/TestLeadingZeroesP11.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ import java.security.PublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; +import java.util.HexFormat; import javax.crypto.KeyAgreement; /** @@ -51,6 +52,9 @@ public class TestLeadingZeroesP11 extends PKCS11Test { + // Hex formatter to upper case with ":" delimiter + private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); + public static void main(String[] args) throws Exception { main(new TestLeadingZeroesP11(), args); } @@ -74,7 +78,7 @@ public void main(Provider p) throws Exception { aliceKeyAgree.init(alicePrivKey); aliceKeyAgree.doPhase(bobPubKey, true); byte[] sharedSecret = aliceKeyAgree.generateSecret(); - System.out.println("shared secret:\n" + toHexString(sharedSecret)); + System.out.println("shared secret:\n" + HEX.formatHex(sharedSecret)); // verify that leading zero is present if (sharedSecret.length != 128) { @@ -90,7 +94,7 @@ public void main(Provider p) throws Exception { byte[] tlsPremasterSecret = aliceKeyAgree.generateSecret("TlsPremasterSecret").getEncoded(); System.out.println( - "tls premaster secret:\n" + toHexString(tlsPremasterSecret)); + "tls premaster secret:\n" + HEX.formatHex(tlsPremasterSecret)); // check that leading zero has been stripped if (tlsPremasterSecret.length != 127) { @@ -107,35 +111,6 @@ public void main(Provider p) throws Exception { } - /* - * Converts a byte to hex digit and writes to the supplied buffer - */ - private void byte2hex(byte b, StringBuffer buf) { - char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', - '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - int high = ((b & 0xf0) >> 4); - int low = (b & 0x0f); - buf.append(hexChars[high]); - buf.append(hexChars[low]); - } - - /* - * Converts a byte array to hex string - */ - private String toHexString(byte[] block) { - StringBuffer buf = new StringBuffer(); - - int len = block.length; - - for (int i = 0; i < len; i++) { - byte2hex(block[i], buf); - if (i < len-1) { - buf.append(":"); - } - } - return buf.toString(); - } - private static final byte alicePubKeyEnc[] = { (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x24, (byte)0x30, (byte)0x81, (byte)0x99, (byte)0x06, diff --git a/test/jdk/sun/security/provider/DSA/TestDSA.java b/test/jdk/sun/security/provider/DSA/TestDSA.java index d730b69f6cb..5d3228949f5 100644 --- a/test/jdk/sun/security/provider/DSA/TestDSA.java +++ b/test/jdk/sun/security/provider/DSA/TestDSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,17 +71,22 @@ public class TestDSA { private final static BigInteger y = new BigInteger(ys, 16); // data for test 1, original and SHA-1 hashed - private final static byte[] data1Raw = b("0102030405060708090a0b0c0d0e0f10111213"); - private final static byte[] data1SHA = b("00:e2:5f:c9:1c:8f:d6:8c:6a:dc:c6:bd:f0:46:60:5e:a2:cd:8d:ad"); + private final static byte[] data1Raw = HexFormat.of() + .parseHex("0102030405060708090a0b0c0d0e0f10111213"); + private final static byte[] data1SHA = HexFormat.ofDelimiter(":") + .parseHex("00:e2:5f:c9:1c:8f:d6:8c:6a:dc:c6:bd:f0:46:60:5e:a2:cd:8d:ad"); // valid signatures of data1. sig1b uses incorrect ASN.1 encoding, // which we want to accept anyway for compatibility - private final static byte[] sig1a = b("30:2d:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:15:00:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13"); - private final static byte[] sig1b = b("30:2c:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:14:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13"); + private final static byte[] sig1a = HexFormat.ofDelimiter(":") + .parseHex("30:2d:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:15:00:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13"); + private final static byte[] sig1b = HexFormat.ofDelimiter(":") + .parseHex("30:2c:02:14:53:06:3f:7d:ec:48:3c:99:17:9a:2c:a9:4d:e8:00:da:70:fb:35:d7:02:14:92:6a:39:6b:15:63:2f:e7:32:90:35:bf:af:47:55:e7:ff:33:a5:13"); // data for test 2 (invalid signatures) private final static byte[] data2Raw = {}; - private final static byte[] data2SHA = b("da:39:a3:ee:5e:6b:4b:0d:32:55:bf:ef:95:60:18:90:af:d8:07:09"); + private final static byte[] data2SHA = HexFormat.ofDelimiter(":") + .parseHex("da:39:a3:ee:5e:6b:4b:0d:32:55:bf:ef:95:60:18:90:af:d8:07:09"); private static void verify(Provider provider, String alg, PublicKey key, byte[] data, byte[] sig, boolean result) throws Exception { Signature s = Signature.getInstance(alg, provider); @@ -182,62 +187,4 @@ public static void main(String[] args) throws Exception { long stop = System.currentTimeMillis(); System.out.println("All tests passed (" + (stop - start) + " ms)."); } - - private final static char[] hexDigits = "0123456789abcdef".toCharArray(); - - public static String toString(byte[] b) { - StringBuffer sb = new StringBuffer(b.length * 3); - for (int i = 0; i < b.length; i++) { - int k = b[i] & 0xff; - if (i != 0) { - sb.append(':'); - } - sb.append(hexDigits[k >>> 4]); - sb.append(hexDigits[k & 0xf]); - } - return sb.toString(); - } - - public static byte[] parse(String s) { - try { - int n = s.length(); - ByteArrayOutputStream out = new ByteArrayOutputStream(n / 3); - StringReader r = new StringReader(s); - while (true) { - int b1 = nextNibble(r); - if (b1 < 0) { - break; - } - int b2 = nextNibble(r); - if (b2 < 0) { - throw new RuntimeException("Invalid string " + s); - } - int b = (b1 << 4) | b2; - out.write(b); - } - return out.toByteArray(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static byte[] b(String s) { - return parse(s); - } - - private static int nextNibble(StringReader r) throws IOException { - while (true) { - int ch = r.read(); - if (ch == -1) { - return -1; - } else if ((ch >= '0') && (ch <= '9')) { - return ch - '0'; - } else if ((ch >= 'a') && (ch <= 'f')) { - return ch - 'a' + 10; - } else if ((ch >= 'A') && (ch <= 'F')) { - return ch - 'A' + 10; - } - } - } - } diff --git a/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java b/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java index eba1f59c4d7..1f797330c48 100644 --- a/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java +++ b/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,62 +36,7 @@ public class DigestKAT { - private final static char[] hexDigits = "0123456789abcdef".toCharArray(); - - public static String toString(byte[] b) { - StringBuffer sb = new StringBuffer(b.length * 3); - for (int i = 0; i < b.length; i++) { - int k = b[i] & 0xff; - if (i != 0) { - sb.append(':'); - } - sb.append(hexDigits[k >>> 4]); - sb.append(hexDigits[k & 0xf]); - } - return sb.toString(); - } - - public static byte[] parse(String s) { - try { - int n = s.length(); - ByteArrayOutputStream out = new ByteArrayOutputStream(n / 3); - StringReader r = new StringReader(s); - while (true) { - int b1 = nextNibble(r); - if (b1 < 0) { - break; - } - int b2 = nextNibble(r); - if (b2 < 0) { - throw new RuntimeException("Invalid string " + s); - } - int b = (b1 << 4) | b2; - out.write(b); - } - return out.toByteArray(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static byte[] b(String s) { - return parse(s); - } - - private static int nextNibble(StringReader r) throws IOException { - while (true) { - int ch = r.read(); - if (ch == -1) { - return -1; - } else if ((ch >= '0') && (ch <= '9')) { - return ch - '0'; - } else if ((ch >= 'a') && (ch <= 'f')) { - return ch - 'a' + 10; - } else if ((ch >= 'A') && (ch <= 'F')) { - return ch - 'A' + 10; - } - } - } + private static final HexFormat HEX = HexFormat.ofDelimiter(":"); static abstract class Test { abstract void run(Provider p) throws Exception; @@ -118,10 +63,10 @@ void run(Provider p) throws Exception { if (Arrays.equals(digest, myDigest) == false) { System.out.println("Digest test for " + alg + " failed:"); if (data.length < 256) { - System.out.println("data: " + DigestKAT.toString(data)); + System.out.println("data: " + HEX.formatHex(data)); } - System.out.println("dig: " + DigestKAT.toString(digest)); - System.out.println("out: " + DigestKAT.toString(myDigest)); + System.out.println("dig: " + HEX.formatHex(digest)); + System.out.println("out: " + HEX.formatHex(myDigest)); throw new Exception("Digest test for " + alg + " failed"); } // System.out.println("Passed " + alg); @@ -137,7 +82,8 @@ private static byte[] s(String s) { } private static Test t(String alg, byte[] data, String digest) { - return new DigestTest(alg, data, parse(digest)); + HexFormat hex = (digest.indexOf(':') < 0) ? HexFormat.of() : HexFormat.ofDelimiter(":"); + return new DigestTest(alg, data, hex.parseHex(digest)); } private final static byte[] ALONG, BLONG; diff --git a/test/jdk/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java b/test/jdk/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java index b3561b4e8dd..19a4e98eb2a 100644 --- a/test/jdk/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java +++ b/test/jdk/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8046321 + * @bug 8046321 8256895 * @summary Unit tests for OCSPNonceExtension objects * @modules java.base/sun.security.provider.certpath * java.base/sun.security.util @@ -192,6 +192,12 @@ public Map.Entry runTest() { throw new RuntimeException("Accepted a zero length nonce"); } catch (IllegalArgumentException iae) { } + // Length of the nonce exceeds the maximum 32 bytes + try { + Extension bigLenNonce = new OCSPNonceExtension(33); + throw new RuntimeException("Accepted a larger than 32 bytes of nonce"); + } catch (IllegalArgumentException iae) { } + // Valid input to constructor Extension nonceByLen = new OCSPNonceExtension(32); diff --git a/test/jdk/sun/security/rsa/SigRecord.java b/test/jdk/sun/security/rsa/SigRecord.java index 5fc9326cfdf..be5747ad458 100644 --- a/test/jdk/sun/security/rsa/SigRecord.java +++ b/test/jdk/sun/security/rsa/SigRecord.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,36 +30,13 @@ import java.security.*; import java.security.spec.*; import java.util.ArrayList; +import java.util.HexFormat; import java.util.List; public final class SigRecord { static final String TEST_SRC = System.getProperty("test.src", "."); - // utility method for converting byte array to hex string - static String toHexString(byte[] array) { - StringBuilder sb = new StringBuilder(array.length * 2); - for (byte b : array) { - // The single digits 0123456789abcdef get a leading 0 - if ((b >= 0x00) && (b < 0x10)) { - sb.append('0'); - } - sb.append(Integer.toHexString(b & 0xff)); - } - return sb.toString(); - } - - // utility method for converting hex string to byte array - static byte[] toByteArray(String s) { - byte[] bytes = new byte[s.length() / 2]; - for (int i = 0; i < bytes.length; i++) { - int index = i * 2; - int v = Integer.parseInt(s.substring(index, index + 2), 16); - bytes[i] = (byte) v; - } - return bytes; - } - public static final class SigVector { // digest algorithm to use final String mdAlg; @@ -115,9 +92,9 @@ public String toString() { throw new IllegalArgumentException("One or more test vectors must be specified"); } - BigInteger n = new BigInteger(1, toByteArray(mod)); - BigInteger e = new BigInteger(1, toByteArray(pubExp)); - BigInteger d = new BigInteger(1, toByteArray(privExp)); + BigInteger n = new BigInteger(1, HexFormat.of().parseHex(mod)); + BigInteger e = new BigInteger(1, HexFormat.of().parseHex(pubExp)); + BigInteger d = new BigInteger(1, HexFormat.of().parseHex(privExp)); this.id = ("n=" + mod + ", e=" + pubExp); this.pubKeySpec = new RSAPublicKeySpec(n, e); this.privKeySpec = new RSAPrivateKeySpec(n, d); diff --git a/test/jdk/sun/security/rsa/TestKeyFactory.java b/test/jdk/sun/security/rsa/TestKeyFactory.java index 548d1bf4a6f..4ab13e81767 100644 --- a/test/jdk/sun/security/rsa/TestKeyFactory.java +++ b/test/jdk/sun/security/rsa/TestKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 4853305 + * @bug 4853305 8023980 * @summary Test KeyFactory of the new RSA provider * @author Andreas Sterbenz */ @@ -41,6 +41,84 @@ public class TestKeyFactory { private static final char[] password = "test12".toCharArray(); + private static final String PKCS1_PRIV_STR = + // the BASE64 string between -----BEGIN RSA PRIVATE KEY----- + // and -----END RSA PRIVATE KEY----- + "MIIEowIBAAKCAQEA0OIArlYES4X1XMTLDordtN/XIWFE1wvhl40RsHWM2n99+Stp" + + "CCJCcUb5FJ2/kefj/XRwB6p5IMpIZrHZqC8XXzlX5fpiFaSu2xnk17oWUKoErW27" + + "Stm098pU2RoUxWPKVl+42a8iVp8tijNElBNFALCGi0zXOhcTxMh0q1Wk0UhMJqam" + + "v5YnCKmT4THwwGYn/KeK3M7Qa+o5MoVBHLbeT9LJgEmSluVzIh44Lh6weX0bw72P" + + "8X2praOhbzg2B343MqS/rMLw6On+0i7ccEgp23vX9G5w85q4A5FSIrk4S/pyv5sO" + + "rwjCQKBW1TS0/2iB9zNkFMj5/+h7l2oqTT7sSQIDAQABAoIBADn6sXOynoiUC1IP" + + "sck8lGOTSjSSujfyrVCSsJlJV6qCfuX9va6rS8QDjjnBu531PtxoSHxoPizy2Pvg" + + "W+kKATPGR/am9DjLuFlKq7GRjoYfWyMEdVtGaKvq9ng4fBF6LHyjHz0VFrPyhQJ6" + + "TovHeXzCguYBkzAlnbAeb/vqzs/kABbOuSHVi7DsaixCoEX9zOptFYQw/l8rh68+" + + "UF2bpNNH3jOC1uN3vZtuSwCupqtN+2Mpkx2h04Rk75vWIhrnPeMgmcd3yP4LNZMR" + + "mfaynb63RRzVkNis7+NVk016SQ1oL79mrBvy5rBg3HeCeArwvqZAmOaWsLSWHzCy" + + "zlVlMTECgYEA6JlnMpC956Qi8HX5ye4Hu2ovBdbNGtH/TMkZmColJz9P7CvNkNIb" + + "Od6mvLMydbPHkhdBUDWD4rhiCKHrf5zKju1i24YqWcvuSGotWj4/KQ3+87mLZM+7" + + "daBsJBmSEVB80sgA9ItqSgOyNoNFpiDgFnlszAfb0n9XXEzB/pwSw1UCgYEA5eXI" + + "d+eKugugP+n6CluQfyxfN6WWCzfqWToCTTxPn2i12AiEssXy+kyLjupJVLWSivdo" + + "83wD5LuxFRGc9P+aKQERPhb0AFaxf1llUCXla65/x2So5xjMvtuzgQ0OktPJqJXq" + + "hYGunctsr5rje33+7vlx4xWkrL2PrQWzJabn7SUCgYEAqw3FesY/Ik7u8u+P1xSZ" + + "0xXvptek1oiAu7NYgzLbR9WjrQc5kbsyEojPDg6qmSyxI5q+iYIRj3YRgk+xpJNl" + + "0154SQCNvKPghJiw6aDFSifkytA01tp9/a8QWCwF433RjiFPsoekjvHQ6Y34dofO" + + "xDhf7lwJKPBFCrfYIqocklECgYAIPI9OHHGP8NKw94UJ0fX/WGug5sHVbQ9sWvOy" + + "KLMBlxLMxqFadlUaOpvVZvdxnX++ktajwpGxJDhX9OWWsYGobm1buB7N1E1Prrg+" + + "gt0RWpMhZa3Xeb/8Jorr2Lfo8sWK0LQyTE8hQCSIthfoWL9FeJJn/GKF/dSj8kxU" + + "0QIGMQKBgG/8U/zZ87DzfXS81P1p+CmH474wmou4KD2/zXp/lDR9+dlIUeijlIbU" + + "P6Y5xJvT33Y40giW9irShgDHjZgw0ap11K3b2HzLImdPEaBiENo735rpLs8WLK9H" + + "+yeRbiP2y9To7sTihm9Jrkctzp6sqFtKyye1+S21X1tMz8NGfXen"; + + private static final String PKCS1_PUB_STR = + // the BASE64 string between -----BEGIN RSA PUBLIC KEY----- + // and -----END RSA PUBLIC KEY----- + "MIIBCgKCAQEA0OIArlYES4X1XMTLDordtN/XIWFE1wvhl40RsHWM2n99+StpCCJC" + + "cUb5FJ2/kefj/XRwB6p5IMpIZrHZqC8XXzlX5fpiFaSu2xnk17oWUKoErW27Stm0" + + "98pU2RoUxWPKVl+42a8iVp8tijNElBNFALCGi0zXOhcTxMh0q1Wk0UhMJqamv5Yn" + + "CKmT4THwwGYn/KeK3M7Qa+o5MoVBHLbeT9LJgEmSluVzIh44Lh6weX0bw72P8X2p" + + "raOhbzg2B343MqS/rMLw6On+0i7ccEgp23vX9G5w85q4A5FSIrk4S/pyv5sOrwjC" + + "QKBW1TS0/2iB9zNkFMj5/+h7l2oqTT7sSQIDAQAB"; + + + private static final PrivateKey P1_PRIV; + private static final PublicKey P1_PUB; + + static { + byte[] encodedPriv = Base64.getDecoder().decode(PKCS1_PRIV_STR); + P1_PRIV = new PrivateKey() { + @Override + public String getAlgorithm() { + return "RSA"; + } + @Override + public String getFormat() { + return "PKCS#1"; + } + @Override + public byte[] getEncoded() { + // skip cloning for testing key. + return encodedPriv; + } + }; + byte[] encodedPub = Base64.getDecoder().decode(PKCS1_PUB_STR); + P1_PUB = new PublicKey() { + @Override + public String getAlgorithm() { + return "RSA"; + } + @Override + public String getFormat() { + return "PKCS#1"; + } + @Override + public byte[] getEncoded() { + // skip cloning for testing key. + return encodedPub; + } + }; + } + static KeyStore getKeyStore() throws Exception { InputStream in = new FileInputStream(new File(BASE, "rsakeys.ks")); KeyStore ks = KeyStore.getInstance("JKS"); @@ -63,55 +141,78 @@ private static void testKey(Key key1, Key key2) throws Exception { } } else if (key1 instanceof PrivateKey) { if (key2.getFormat().equals("PKCS#8") == false) { - throw new Exception("Format not PKCS#8"); + throw new Exception("Format not PKCS#8: " + key2.getFormat()); } } - if (key1.equals(key2) == false) { - throw new Exception("Keys not equal"); + // skip equals check when key1 is custom key + if (key1 != P1_PRIV && key1 != P1_PUB) { + if (!key1.equals(key2)) { + throw new Exception("Keys not equal"); + } } - if (Arrays.equals(key1.getEncoded(), key2.getEncoded()) == false) { + + // only compare encodings if keys are of the same format + if (key1.getFormat().equals(key2.getFormat()) && + !Arrays.equals(key1.getEncoded(), key2.getEncoded())) { throw new Exception("Encodings not equal"); } } - private static void testPublic(KeyFactory kf, PublicKey key) throws Exception { - System.out.println("Testing public key..."); + private static void testPublic(KeyFactory kf, PublicKey key) + throws Exception { + System.out.println("Testing " + (key == P1_PUB? "PKCS#1" : "") + + " public key..."); + PublicKey key2 = (PublicKey)kf.translateKey(key); KeySpec rsaSpec = kf.getKeySpec(key, RSAPublicKeySpec.class); PublicKey key3 = kf.generatePublic(rsaSpec); KeySpec x509Spec = kf.getKeySpec(key, X509EncodedKeySpec.class); PublicKey key4 = kf.generatePublic(x509Spec); - KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded()); - PublicKey key5 = kf.generatePublic(x509Spec2); - testKey(key, key); + if (key != P1_PUB) { + testKey(key, key); + } testKey(key, key2); testKey(key, key3); testKey(key, key4); - testKey(key, key5); + + if (key.getFormat().equalsIgnoreCase("X.509")) { + KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded()); + PublicKey key5 = kf.generatePublic(x509Spec2); + testKey(key, key5); + } } - private static void testPrivate(KeyFactory kf, PrivateKey key) throws Exception { - System.out.println("Testing private key..."); + private static void testPrivate(KeyFactory kf, PrivateKey key) + throws Exception { + System.out.println("Testing " + (key == P1_PRIV? "PKCS#1" : "") + + " private key..."); PrivateKey key2 = (PrivateKey)kf.translateKey(key); KeySpec rsaSpec = kf.getKeySpec(key, RSAPrivateCrtKeySpec.class); PrivateKey key3 = kf.generatePrivate(rsaSpec); KeySpec pkcs8Spec = kf.getKeySpec(key, PKCS8EncodedKeySpec.class); PrivateKey key4 = kf.generatePrivate(pkcs8Spec); - KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded()); - PrivateKey key5 = kf.generatePrivate(pkcs8Spec2); - testKey(key, key); + if (key != P1_PRIV) { + testKey(key, key); + } testKey(key, key2); testKey(key, key3); testKey(key, key4); - testKey(key, key5); + if (key.getFormat().equalsIgnoreCase("PKCS#8")) { + KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded()); + PrivateKey key5 = kf.generatePrivate(pkcs8Spec2); + testKey(key, key5); + } KeySpec rsaSpec2 = kf.getKeySpec(key, RSAPrivateKeySpec.class); PrivateKey key6 = kf.generatePrivate(rsaSpec2); - RSAPrivateKey rsaKey = (RSAPrivateKey)key; - KeySpec rsaSpec3 = new RSAPrivateKeySpec(rsaKey.getModulus(), rsaKey.getPrivateExponent()); - PrivateKey key7 = kf.generatePrivate(rsaSpec3); testKey(key6, key6); - testKey(key6, key7); + if (key instanceof RSAPrivateKey) { + KeySpec rsaSpec3 = + new RSAPrivateKeySpec(((RSAPrivateKey)key).getModulus(), + ((RSAPrivateKey)key).getPrivateExponent()); + PrivateKey key7 = kf.generatePrivate(rsaSpec3); + testKey(key6, key7); + } } private static void test(KeyFactory kf, Key key) throws Exception { @@ -137,6 +238,10 @@ public static void main(String[] args) throws Exception { test(kf, ks.getCertificate(alias).getPublicKey()); } } + // repeat the test w/ PKCS#1 RSA Private Key + test(kf, P1_PRIV); + test(kf, P1_PUB); + long stop = System.currentTimeMillis(); System.out.println("All tests passed (" + (stop - start) + " ms)."); } diff --git a/test/jdk/sun/security/rsa/TestSigGen15.java b/test/jdk/sun/security/rsa/TestSigGen15.java index 08ce334b89e..12cc028b072 100644 --- a/test/jdk/sun/security/rsa/TestSigGen15.java +++ b/test/jdk/sun/security/rsa/TestSigGen15.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.security.spec.*; import java.security.interfaces.*; import java.util.ArrayList; +import java.util.HexFormat; import java.util.List; /* @@ -100,8 +101,8 @@ static boolean check(PrivateKey privKey, PublicKey pubKey, " due to no support"); continue; } - byte[] msgBytes = SigRecord.toByteArray(v.msg); - byte[] expSigBytes = SigRecord.toByteArray(v.sig); + byte[] msgBytes = HexFormat.of().parseHex(v.msg); + byte[] expSigBytes = HexFormat.of().parseHex(v.sig); sig.initSign(privKey); sig.update(msgBytes); @@ -114,7 +115,7 @@ static boolean check(PrivateKey privKey, PublicKey pubKey, System.out.println("\tSHAALG = " + v.mdAlg); System.out.println("\tMsg = " + v.msg); System.out.println("\tExpected Sig = " + v.sig); - System.out.println("\tActual Sig = " + SigRecord.toHexString(actualSigBytes)); + System.out.println("\tActual Sig = " + HexFormat.of().formatHex(actualSigBytes)); } else { System.out.println("\t" + v.mdAlg + " Test Vector Passed"); } diff --git a/test/jdk/sun/security/rsa/pss/SigRecord.java b/test/jdk/sun/security/rsa/pss/SigRecord.java index fbea8c9634f..faf3142d0a8 100644 --- a/test/jdk/sun/security/rsa/pss/SigRecord.java +++ b/test/jdk/sun/security/rsa/pss/SigRecord.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,36 +30,13 @@ import java.security.*; import java.security.spec.*; import java.util.ArrayList; +import java.util.HexFormat; import java.util.List; public final class SigRecord { static final String TEST_SRC = System.getProperty("test.src", "."); - // utility method for converting byte array to hex string - static String toHexString(byte[] array) { - StringBuilder sb = new StringBuilder(array.length * 2); - for (byte b : array) { - // The single digits 0123456789abcdef get a leading 0 - if ((b >= 0x00) && (b < 0x10)) { - sb.append('0'); - } - sb.append(Integer.toHexString(b & 0xff)); - } - return sb.toString(); - } - - // utility method for converting hex string to byte array - static byte[] toByteArray(String s) { - byte[] bytes = new byte[s.length() / 2]; - for (int i = 0; i < bytes.length; i++) { - int index = i * 2; - int v = Integer.parseInt(s.substring(index, index + 2), 16); - bytes[i] = (byte) v; - } - return bytes; - } - public static final class SigVector { // digest algorithm to use final String mdAlg; @@ -120,9 +97,9 @@ public String toString() { throw new IllegalArgumentException("One or more test vectors must be specified"); } - BigInteger n = new BigInteger(1, toByteArray(mod)); - BigInteger e = new BigInteger(1, toByteArray(pubExp)); - BigInteger d = new BigInteger(1, toByteArray(privExp)); + BigInteger n = new BigInteger(1, HexFormat.of().parseHex(mod)); + BigInteger e = new BigInteger(1, HexFormat.of().parseHex(pubExp)); + BigInteger d = new BigInteger(1, HexFormat.of().parseHex(privExp)); this.id = ("n=" + mod + ", e=" + pubExp); this.pubKeySpec = new RSAPublicKeySpec(n, e); this.privKeySpec = new RSAPrivateKeySpec(n, d); diff --git a/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java b/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java index 50a608ef271..dfadef03f04 100644 --- a/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java +++ b/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,15 +21,10 @@ * questions. */ -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStreamReader; import java.security.*; import java.security.spec.*; -import java.security.interfaces.*; -import java.util.ArrayList; +import java.util.HexFormat; import java.util.List; /* @@ -50,7 +45,7 @@ static final class MyKnownRandomSrc extends SecureRandom { int numBytes; MyKnownRandomSrc(String srcString) { - this.srcBytes = SigRecord.toByteArray(srcString); + this.srcBytes = HexFormat.of().parseHex(srcString); this.numBytes = this.srcBytes.length; } @Override @@ -120,8 +115,8 @@ static boolean check(Signature sig, PrivateKey privKey, PublicKey pubKey, boolean success = true; for (SigRecord.SigVector v : vectors) { System.out.println("\tAgainst " + v.mdAlg); - byte[] msgBytes = SigRecord.toByteArray(v.msg); - byte[] expSigBytes = SigRecord.toByteArray(v.sig); + byte[] msgBytes = HexFormat.of().parseHex(v.msg); + byte[] expSigBytes = HexFormat.of().parseHex(v.sig); MyKnownRandomSrc saltSrc = new MyKnownRandomSrc(v.salt); sig.initSign(privKey, saltSrc); @@ -145,7 +140,7 @@ static boolean check(Signature sig, PrivateKey privKey, PublicKey pubKey, System.out.println("\tMsg = " + v.msg); System.out.println("\tSalt = " + v.salt); System.out.println("\tExpected Sig = " + v.sig); - System.out.println("\tActual Sig = " + SigRecord.toHexString(actualSigBytes)); + System.out.println("\tActual Sig = " + HexFormat.of().formatHex(actualSigBytes)); } else { System.out.println("\t" + v.mdAlg + " Test Vector Passed"); } diff --git a/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java new file mode 100644 index 00000000000..d3c656043a2 --- /dev/null +++ b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 8254631 + * @summary Better support ALPN byte wire values in SunJSSE + * @library /javax/net/ssl/templates + * @run main/othervm AlpnGreaseTest + */ +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.HandshakeStatus; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; + +/** + * A SSLEngine usage example which simplifies the presentation + * by removing the I/O and multi-threading concerns. + * + * The test creates two SSLEngines, simulating a client and server. + * The "transport" layer consists two byte buffers: think of them + * as directly connected pipes. + * + * Note, this is a *very* simple example: real code will be much more + * involved. For example, different threading and I/O models could be + * used, transport mechanisms could close unexpectedly, and so on. + * + * When this application runs, notice that several messages + * (wrap/unwrap) pass before any application data is consumed or + * produced. + */ +public class AlpnGreaseTest implements SSLContextTemplate { + + private final SSLEngine clientEngine; // client Engine + private final ByteBuffer clientOut; // write side of clientEngine + private final ByteBuffer clientIn; // read side of clientEngine + + private final SSLEngine serverEngine; // server Engine + private final ByteBuffer serverOut; // write side of serverEngine + private final ByteBuffer serverIn; // read side of serverEngine + + // For data transport, this example uses local ByteBuffers. This + // isn't really useful, but the purpose of this example is to show + // SSLEngine concepts, not how to do network transport. + private final ByteBuffer cTOs; // "reliable" transport client->server + private final ByteBuffer sTOc; // "reliable" transport server->client + + // These are the various 8-bit char values that could be sent as GREASE + // values. We'll just make one big String here to make it easy to check + // that the right values are being output. + private static final byte[] greaseBytes = new byte[] { + (byte) 0x0A, (byte) 0x1A, (byte) 0x2A, (byte) 0x3A, + (byte) 0x4A, (byte) 0x5A, (byte) 0x6A, (byte) 0x7A, + (byte) 0x8A, (byte) 0x9A, (byte) 0xAA, (byte) 0xBA, + (byte) 0xCA, (byte) 0xDA, (byte) 0xEA, (byte) 0xFA + }; + + private static final String greaseString = + new String(greaseBytes, StandardCharsets.ISO_8859_1); + + private static void findGreaseInClientHello(byte[] bytes) throws Exception { + for (int i = 0; i < bytes.length - greaseBytes.length; i++) { + if (Arrays.equals(bytes, i, i + greaseBytes.length, + greaseBytes, 0, greaseBytes.length)) { + System.out.println("Found greaseBytes in ClientHello at: " + i); + return; + } + } + throw new Exception("Couldn't find greaseBytes"); + } + + private AlpnGreaseTest() throws Exception { + serverEngine = configureServerEngine( + createServerSSLContext().createSSLEngine()); + + clientEngine = configureClientEngine( + createClientSSLContext().createSSLEngine()); + + // We'll assume the buffer sizes are the same + // between client and server. + SSLSession session = clientEngine.getSession(); + int appBufferMax = session.getApplicationBufferSize(); + int netBufferMax = session.getPacketBufferSize(); + + // We'll make the input buffers a bit bigger than the max needed + // size, so that unwrap()s following a successful data transfer + // won't generate BUFFER_OVERFLOWS. + // + // We'll use a mix of direct and indirect ByteBuffers for + // tutorial purposes only. In reality, only use direct + // ByteBuffers when they give a clear performance enhancement. + clientIn = ByteBuffer.allocate(appBufferMax + 50); + serverIn = ByteBuffer.allocate(appBufferMax + 50); + + cTOs = ByteBuffer.allocateDirect(netBufferMax); + sTOc = ByteBuffer.allocateDirect(netBufferMax); + + clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); + serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes()); + } + + // + // Protected methods could be used to customize the test case. + // + + /* + * Configure the client side engine. + */ + protected SSLEngine configureClientEngine(SSLEngine clientEngine) { + clientEngine.setUseClientMode(true); + + // Get/set parameters if needed + SSLParameters paramsClient = clientEngine.getSSLParameters(); + paramsClient.setApplicationProtocols(new String[] { greaseString }); + + clientEngine.setSSLParameters(paramsClient); + + return clientEngine; + } + + /* + * Configure the server side engine. + */ + protected SSLEngine configureServerEngine(SSLEngine serverEngine) { + serverEngine.setUseClientMode(false); + serverEngine.setNeedClientAuth(true); + + // Get/set parameters if needed + // + SSLParameters paramsServer = serverEngine.getSSLParameters(); + paramsServer.setApplicationProtocols(new String[] { greaseString }); + serverEngine.setSSLParameters(paramsServer); + + return serverEngine; + } + + public static void main(String[] args) throws Exception { + new AlpnGreaseTest().runTest(); + } + + // + // Private methods that used to build the common part of the test. + // + + private void runTest() throws Exception { + SSLEngineResult clientResult; + SSLEngineResult serverResult; + + boolean dataDone = false; + boolean firstClientWrap = true; + while (isOpen(clientEngine) || isOpen(serverEngine)) { + log("================="); + + // client wrap + log("---Client Wrap---"); + clientResult = clientEngine.wrap(clientOut, cTOs); + logEngineStatus(clientEngine, clientResult); + runDelegatedTasks(clientEngine); + + if (firstClientWrap) { + firstClientWrap = false; + byte[] bytes = new byte[cTOs.position()]; + cTOs.duplicate().flip().get(bytes); + findGreaseInClientHello(bytes); + } + + // server wrap + log("---Server Wrap---"); + serverResult = serverEngine.wrap(serverOut, sTOc); + logEngineStatus(serverEngine, serverResult); + runDelegatedTasks(serverEngine); + + cTOs.flip(); + sTOc.flip(); + + // client unwrap + log("---Client Unwrap---"); + clientResult = clientEngine.unwrap(sTOc, clientIn); + logEngineStatus(clientEngine, clientResult); + runDelegatedTasks(clientEngine); + + // server unwrap + log("---Server Unwrap---"); + serverResult = serverEngine.unwrap(cTOs, serverIn); + logEngineStatus(serverEngine, serverResult); + runDelegatedTasks(serverEngine); + + cTOs.compact(); + sTOc.compact(); + + // After we've transferred all application data between the client + // and server, we close the clientEngine's outbound stream. + // This generates a close_notify handshake message, which the + // server engine receives and responds by closing itself. + if (!dataDone && (clientOut.limit() == serverIn.position()) && + (serverOut.limit() == clientIn.position())) { + + // Check ALPN Value + String alpnServerValue = serverEngine.getApplicationProtocol(); + String alpnClientValue = clientEngine.getApplicationProtocol(); + + if (!alpnServerValue.equals(greaseString) + || !alpnClientValue.equals(greaseString)) { + throw new Exception("greaseString didn't match"); + } + + // A sanity check to ensure we got what was sent. + checkTransfer(serverOut, clientIn); + checkTransfer(clientOut, serverIn); + + log("\tClosing clientEngine's *OUTBOUND*..."); + clientEngine.closeOutbound(); + logEngineStatus(clientEngine); + + dataDone = true; + log("\tClosing serverEngine's *OUTBOUND*..."); + serverEngine.closeOutbound(); + logEngineStatus(serverEngine); + } + } + } + + private static boolean isOpen(SSLEngine engine) { + return (!engine.isOutboundDone() || !engine.isInboundDone()); + } + + private static void logEngineStatus(SSLEngine engine) { + log("\tCurrent HS State: " + engine.getHandshakeStatus()); + log("\tisInboundDone() : " + engine.isInboundDone()); + log("\tisOutboundDone(): " + engine.isOutboundDone()); + } + + private static void logEngineStatus( + SSLEngine engine, SSLEngineResult result) { + log("\tResult Status : " + result.getStatus()); + log("\tResult HS Status : " + result.getHandshakeStatus()); + log("\tEngine HS Status : " + engine.getHandshakeStatus()); + log("\tisInboundDone() : " + engine.isInboundDone()); + log("\tisOutboundDone() : " + engine.isOutboundDone()); + log("\tMore Result : " + result); + } + + private static void log(String message) { + System.err.println(message); + } + + // If the result indicates that we have outstanding tasks to do, + // go ahead and run them in this thread. + private static void runDelegatedTasks(SSLEngine engine) throws Exception { + if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = engine.getDelegatedTask()) != null) { + log(" running delegated task..."); + runnable.run(); + } + HandshakeStatus hsStatus = engine.getHandshakeStatus(); + if (hsStatus == HandshakeStatus.NEED_TASK) { + throw new Exception( + "handshake shouldn't need additional tasks"); + } + logEngineStatus(engine); + } + } + + // Simple check to make sure everything came across as expected. + private static void checkTransfer(ByteBuffer a, ByteBuffer b) + throws Exception { + a.flip(); + b.flip(); + + if (!a.equals(b)) { + throw new Exception("Data didn't transfer cleanly"); + } else { + log("\tData transferred cleanly"); + } + + a.position(a.limit()); + b.position(b.limit()); + a.limit(a.capacity()); + b.limit(b.capacity()); + } +} diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/DisableExtensions.java b/test/jdk/sun/security/ssl/SSLSocketImpl/DisableExtensions.java new file mode 100644 index 00000000000..ccff01fe5b1 --- /dev/null +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/DisableExtensions.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8217633 + * @library /javax/net/ssl/templates + * @summary Configurable extensions with system properties + * @run main/othervm DisableExtensions supported_versions TLSv1.3 fail + * @run main/othervm DisableExtensions supported_versions TLSv1.2 + */ + +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLException; + +public class DisableExtensions extends SSLSocketTemplate { + + private final String[] protocols; + + public DisableExtensions(String[] protocols) { + this.protocols = protocols; + } + + @Override + protected void configureClientSocket(SSLSocket socket) { + socket.setEnabledProtocols(protocols); + } + + // Run the test case. + // + // Check that the extension could be disabled, and the impact may be + // different for different protocols. + public static void main(String[] args) throws Exception { + System.setProperty("jdk.tls.client.disableExtensions", args[0]); + + boolean shouldSuccess = (args.length != 3); + + try { + (new DisableExtensions(new String[] {args[1]})).run(); + } catch (SSLException | IllegalStateException ssle) { + if (shouldSuccess) { + throw new RuntimeException( + "The extension " + args[0] + " is disabled"); + } + + return; + } + + if (!shouldSuccess) { + throw new RuntimeException( + "The extension " + args[0] + + " should be disabled and the connection should fail"); + } + } +} diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java index af8e5f9bfa7..f74c1fe7666 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,10 @@ /* * @test - * @bug 8184328 + * @bug 8184328 8253368 * @summary JDK8u131-b34-socketRead0 hang at SSL read * @run main/othervm SSLSocketCloseHang + * @run main/othervm SSLSocketCloseHang shutdownInputTest */ import java.io.*; @@ -72,6 +73,8 @@ public class SSLSocketCloseHang { */ static boolean debug = false; + static boolean shutdownInputTest = false; + /* * If the client or server is doing some kind of object creation * that the other side depends on, and that thread prematurely @@ -145,7 +148,26 @@ void doClientSide() throws Exception { Thread.sleep(500); System.err.println("Client closing: " + System.nanoTime()); - sslSocket.close(); + if (shutdownInputTest) { + try { + sslSocket.shutdownInput(); + } catch (SSLException e) { + if (!e.getMessage().contains + ("closing inbound before receiving peer's close_notify")) { + throw new RuntimeException("expected different exception message. " + + e.getMessage()); + } + } + if (!sslSocket.getSession().isValid()) { + throw new RuntimeException("expected session to remain valid"); + } + + } else { + sslSocket.close(); + } + + + clientClosed = true; System.err.println("Client closed: " + System.nanoTime()); } @@ -179,6 +201,8 @@ public static void main(String[] args) throws Exception { if (debug) System.setProperty("javax.net.debug", "all"); + shutdownInputTest = args.length > 0 ? true : false; + /* * Start the tests. */ diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java new file mode 100644 index 00000000000..d43d4d3bacc --- /dev/null +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocketFactory; + +import jdk.test.lib.Platform; +import jdk.test.lib.util.FileUtils; + +/* + * @test + * @bug 8256818 8257670 8257884 8257997 + * @summary Test that creating and closing SSL Sockets without bind/connect + * will not leave leaking socket file descriptors + * @library /test/lib + * @run main/othervm SSLSocketLeak + */ +public class SSLSocketLeak { + + // number of sockets to open/close + private static final int NUM_TEST_SOCK = 500; + + // percentage of accepted growth of open handles + private static final int OPEN_HANDLE_GROWTH_THRESHOLD_PERCENTAGE = Platform.isWindows() ? 25 : 10; + + public static void main(String[] args) throws IOException { + long fds_start = FileUtils.getProcessHandleCount(); + System.out.println("FDs at the beginning: " + fds_start); + + SocketFactory f = SSLSocketFactory.getDefault(); + for (int i = 0; i < NUM_TEST_SOCK; i++) { + f.createSocket().close(); + } + + long fds_end = FileUtils.getProcessHandleCount(); + System.out.println("FDs in the end: " + fds_end); + + if ((fds_end - fds_start) > ((NUM_TEST_SOCK * OPEN_HANDLE_GROWTH_THRESHOLD_PERCENTAGE)) / 100) { + throw new RuntimeException("Too many open file descriptors. Looks leaky."); + } + } +} diff --git a/test/jdk/sun/security/tools/jarsigner/CheckSignerCertChain.java b/test/jdk/sun/security/tools/jarsigner/CheckSignerCertChain.java new file mode 100644 index 00000000000..157abb4b5f3 --- /dev/null +++ b/test/jdk/sun/security/tools/jarsigner/CheckSignerCertChain.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8259401 + * @summary Check certificates in signer's cert chain to see if warning emitted + * @library /test/lib + */ + +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.util.JarUtils; + +import java.nio.file.Path; + +public class CheckSignerCertChain { + + static OutputAnalyzer kt(String cmd, String ks) throws Exception { + return SecurityTools.keytool("-storepass changeit " + cmd + + " -keystore " + ks); + } + + static void gencert(String owner, String cmd) throws Exception { + kt("-certreq -alias " + owner + " -file tmp.req", "ks"); + kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd, "ks"); + kt("-importcert -alias " + owner + " -file tmp.cert", "ks"); + } + + public static void main(String[] args) throws Exception { + + // root certificate using SHA1withRSA and 1024-bit key + System.out.println("Generating a root cert using SHA1withRSA and 1024-bit key"); + kt("-genkeypair -keyalg rsa -alias ca -dname CN=CA -ext bc:c " + + "-keysize 1024 -sigalg SHA1withRSA", "ks"); + kt("-genkeypair -keyalg rsa -alias ca1 -dname CN=CA1", "ks"); + kt("-genkeypair -keyalg rsa -alias e1 -dname CN=E1", "ks"); + + // intermediate certificate using SHA1withRSA and 2048-bit key + System.out.println("Generating an intermediate cert using SHA1withRSA and 2048-bit key"); + gencert("ca1", "-alias ca -ext san=dns:ca1 -ext bc:c " + + "-sigalg SHA1withRSA "); + + // end entity certificate using SHA256withRSA and 2048-bit key + System.out.println("Generating an end entity cert using SHA256withRSA and 2048-bit key"); + gencert("e1", "-alias ca1 -ext san=dns:e1 "); + + JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("ks")); + + SecurityTools.jarsigner("-keystore ks -storepass changeit " + + "-signedjar signeda.jar " + + "-sigalg SHA256withRSA " + + "-verbose" + + " a.jar e1") + .shouldContain("Signature algorithm: SHA1withRSA (weak), 2048-bit key") + // For trusted cert, warning should be generated for its weak 1024-bit + // key, but not for its SHA1withRSA algorithm. + .shouldContain("Signature algorithm: SHA1withRSA, 1024-bit key (weak)") + .shouldHaveExitValue(0); + + kt("-exportcert -alias ca -rfc -file cacert", "ks"); + kt("-importcert -noprompt -file cacert", "caks"); + + SecurityTools.jarsigner("-verify -certs signeda.jar " + + "-keystore caks -storepass changeit -verbose -debug") + .shouldContain("Signature algorithm: SHA1withRSA (weak), 2048-bit key") + // For trusted cert, warning should be generated for its weak 1024-bit + // key, but not for its SHA1withRSA algorithm. + .shouldContain("Signature algorithm: SHA1withRSA, 1024-bit key (weak)") + .shouldHaveExitValue(0); + } +} diff --git a/test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java b/test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java index 4e9509736e9..4d5b28533f5 100644 --- a/test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java +++ b/test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8217375 + * @bug 8217375 8260286 * @summary This test is used to verify the compatibility of jarsigner across * different JDK releases. It also can be used to check jar signing (w/ * and w/o TSA) and to verify some specific signing and digest algorithms. @@ -720,6 +720,7 @@ private static void verifying(SignItem signItem, VerifyItem verifyItem) expectedKeySize() + "-bit key" + ")|(" + " Digest algorithm: " + signItem.expectedDigestAlg() + + (isWeakAlg(signItem.expectedDigestAlg()) ? " \\(weak\\)" : "") + (signItem.tsaIndex < 0 ? "" : ")|(" + "Timestamped by \".+\" on .*" @@ -805,7 +806,12 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem boolean warning = false; for (String line : outputAnalyzer.getOutput().lines() .toArray(String[]::new)) { - if (line.isBlank()) continue; + if (line.isBlank()) { + // If line is blank and warning flag is true, it is the end of warnings section + // This is needed when some info is added after warnings, such as timestamp expiration date + if (warning) warning = false; + continue; + } if (Test.JAR_VERIFIED.equals(line)) continue; if (line.matches(Test.ERROR + " ?") && expectedExitCode == 0) { System.out.println("verifyingStatus: error: line.matches(" + Test.ERROR + "\" ?\"): " + line); @@ -835,6 +841,9 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem + "not be able to validate this jar after the signer " + "certificate's expiration date \\([^\\)]+\\) or after " + "any future revocation date[.]") && !tsa) continue; + + if (isWeakAlg(signItem.expectedDigestAlg()) + && line.contains(Test.WEAK_ALGORITHM_WARNING)) continue; if (Test.CERTIFICATE_SELF_SIGNED.equals(line)) continue; if (Test.HAS_EXPIRED_CERT_VERIFYING_WARNING.equals(line) && signItem.certInfo.expired) continue; @@ -844,6 +853,10 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem return warning ? Status.WARNING : Status.NORMAL; } + private static boolean isWeakAlg(String alg) { + return SHA1.equals(alg); + } + // Using specified jarsigner to sign the pre-created jar with specified // algorithms. private static OutputAnalyzer signJar(String jarsignerPath, String sigalg, diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/Test.java b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java index 414caf22570..c0a9c4a521b 100644 --- a/test/jdk/sun/security/tools/jarsigner/warnings/Test.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -144,6 +144,10 @@ public abstract class Test { = "This jar contains entries " + "whose signer certificate is not yet valid."; + static final String WEAK_ALGORITHM_WARNING + = "algorithm is considered a security risk. " + + "This algorithm will be disabled in a future update."; + static final String JAR_SIGNED = "jar signed."; static final String JAR_VERIFIED = "jar verified."; diff --git a/test/jdk/sun/security/tools/keytool/console.sh b/test/jdk/sun/security/tools/keytool/console.sh deleted file mode 100644 index 5c6c349e391..00000000000 --- a/test/jdk/sun/security/tools/keytool/console.sh +++ /dev/null @@ -1,128 +0,0 @@ -# -# Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 6418647 8005527 -# @summary Doc bug 5035358 shows sun.security.util.Password.readPassword() is buggy. -# @author Weijun Wang -# @run shell/manual console.sh - -if [ "$ALT_PASS" = "" ]; then - PASSW=äöäöäö -else - PASSW=$ALT_PASS -fi - -KS=/tmp/kkk.$$ - -cat <<____ - -ATTENTION -=============================================================== - -This test is about non-ASCII password input compatibility between -JDK 5.0 and later versions. Before running the test, make sure that -- - - \$J5 points to a JDK 5.0 installation - \$JM points to the current installation - -The password string used in this test is $PASSW. If you find difficulty -entering it in in your system, feel free to change it to something else -by providing \$ALT_PASS. It should be no less than 6 characters and include -some non-ASCII characters. - -For each test, type into the characters as described in the test header. - means the RETURN (or ENTER key). Please wait for a little while -after is pressed each time. - -\$J5 is now $J5 -\$JM is now $JM - -____ - - -if [ "$J5" = "" -o "$JM" = "" ]; then - echo "Define \$J5 and \$JM first" - exit 1 -fi - -echo "Press ENTER to start the test, or Ctrl-C to stop it" -read x - -echo -echo "==========================================" -echo "Test #1: 5->6, non-prompt. Please type " -echo "==========================================" -echo -rm $KS 2> /dev/null -$J5/bin/keytool -keystore $KS -genkey -keyalg DSA -dname CN=olala -storepass $PASSW || exit 1 -$JM/bin/keytool -keystore $KS -list -storepass $PASSW || exit 2 - -echo "==========================================" -echo "Test #2: 6->5, non-prompt. Please type " -echo "==========================================" -echo - -rm $KS 2> /dev/null -$JM/bin/keytool -keystore $KS -genkey -keyalg DSA -dname CN=olala -storepass $PASSW || exit 3 -$J5/bin/keytool -keystore $KS -list -storepass $PASSW || exit 4 - -echo "============================================================" -echo "Test #3: 5->6, prompt. Please type $PASSW $PASSW " -echo "============================================================" -echo - -rm $KS 2> /dev/null -$J5/bin/keytool -keystore $KS -genkey -keyalg DSA -dname CN=olala || exit 5 -$JM/bin/keytool -keystore $KS -list || exit 6 -echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 7 -echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 8 - -echo "=======================================================================" -echo "Test #4: 6->5, prompt. Please type $PASSW $PASSW $PASSW " -echo "=======================================================================" -echo - -rm $KS 2> /dev/null -$JM/bin/keytool -keystore $KS -genkey -keyalg DSA -dname CN=olala || exit 9 -$J5/bin/keytool -keystore $KS -list || exit 10 -echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 11 -echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 12 - -echo "===========================================" -echo "Test #5: 5->6, pipe. Please type $PASSW " -echo "===========================================" -echo - -rm $KS 2> /dev/null -echo $PASSW| $J5/bin/keytool -keystore $KS -genkey -keyalg DSA -dname CN=olala || exit 13 -$JM/bin/keytool -keystore $KS -list || exit 14 -echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 15 -echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 16 - -rm $KS 2> /dev/null - -echo -echo "Success" - -exit 0 diff --git a/test/jdk/sun/security/util/math/TestIntegerModuloP.java b/test/jdk/sun/security/util/math/TestIntegerModuloP.java index a887e8ef1ac..75a3d2dbc22 100644 --- a/test/jdk/sun/security/util/math/TestIntegerModuloP.java +++ b/test/jdk/sun/security/util/math/TestIntegerModuloP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -195,23 +195,13 @@ void applyAndCheckArray(BiFunction func, byte[] baselineResult = func.apply(baseline, right.baseline); if (!Arrays.equals(testResult, baselineResult)) { throw new RuntimeException("Array values do not match: " - + byteArrayToHexString(testResult) + " != " - + byteArrayToHexString(baselineResult)); + + HexFormat.of().withUpperCase().formatHex(testResult) + " != " + + HexFormat.of().withUpperCase().formatHex(baselineResult)); } } } - static String byteArrayToHexString(byte[] arr) { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < arr.length; ++i) { - byte curVal = arr[i]; - result.append(Character.forDigit(curVal >> 4 & 0xF, 16)); - result.append(Character.forDigit(curVal & 0xF, 16)); - } - return result.toString(); - } - static TestPair applyAndCheck(ElemFunction func, TestPair left, TestPair right) { diff --git a/test/jdk/sun/security/x509/X500Name/DerValueConstructor.java b/test/jdk/sun/security/x509/X500Name/DerValueConstructor.java index 0a9f8351944..463d21db726 100644 --- a/test/jdk/sun/security/x509/X500Name/DerValueConstructor.java +++ b/test/jdk/sun/security/x509/X500Name/DerValueConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,15 +23,23 @@ /* @test * @bug 4228833 + * @library /test/lib * @summary Make sure constructor that takes DerValue argument works * @modules java.base/sun.security.util * java.base/sun.security.x509 */ +import jdk.test.lib.hexdump.ASN1Formatter; +import jdk.test.lib.hexdump.HexPrinter; import sun.security.util.*; import sun.security.x509.*; +import java.util.HexFormat; + public class DerValueConstructor { + // Hex formatter to upper case with ":" delimiter + private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); + public static void main(String[] args) throws Exception { String name = "CN=anne test"; @@ -50,7 +58,10 @@ public static void main(String[] args) throws Exception { dn.encode(debugDER); ba = debugDER.toByteArray(); System.err.print("DEBUG: encoded X500Name bytes: "); - System.out.println(toHexString(ba)); + System.out.println(HEX.formatHex(ba)); + System.out.println(HexPrinter.simple() + .formatter(ASN1Formatter.formatter()) + .toString(ba)); System.err.println(); // decode @@ -76,7 +87,10 @@ public static void main(String[] args) throws Exception { gn.encode(debugDER); ba = debugDER.toByteArray(); System.err.print("DEBUG: encoded GeneralName bytes: "); - System.out.println(toHexString(ba)); + System.out.println(HEX.formatHex(ba)); + System.out.println(HexPrinter.simple() + .formatter(ASN1Formatter.formatter()) + .toString(ba)); System.err.println(); // decode @@ -96,39 +110,13 @@ public static void main(String[] args) throws Exception { subTree.encode(debugDER); ba = debugDER.toByteArray(); System.err.print("DEBUG: encoded GeneralSubtree bytes: "); - System.out.println(toHexString(ba)); + System.out.println(HEX.formatHex(ba)); + System.out.println(HexPrinter.simple() + .formatter(ASN1Formatter.formatter()) + .toString(ba)); System.err.println(); // decode GeneralSubtree debugSubtree = new GeneralSubtree(new DerValue(ba)); } - - /* - * Converts a byte to hex digit and writes to the supplied buffer - */ - private static void byte2hex(byte b, StringBuffer buf) { - char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', - '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - int high = ((b & 0xf0) >> 4); - int low = (b & 0x0f); - buf.append(hexChars[high]); - buf.append(hexChars[low]); - } - - /* - * Converts a byte array to hex string - */ - private static String toHexString(byte[] block) { - StringBuffer buf = new StringBuffer(); - - int len = block.length; - - for (int i = 0; i < len; i++) { - byte2hex(block[i], buf); - if (i < len-1) { - buf.append(":"); - } - } - return buf.toString(); - } } diff --git a/test/jdk/sun/tools/jmap/BasicJMapTest.java b/test/jdk/sun/tools/jmap/BasicJMapTest.java index 00e8a4548ce..c6ad5405343 100644 --- a/test/jdk/sun/tools/jmap/BasicJMapTest.java +++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java @@ -22,10 +22,13 @@ */ import static jdk.test.lib.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertFalse; import static jdk.test.lib.Asserts.fail; import java.io.File; +import java.nio.file.Files; import java.util.Arrays; +import java.util.List; import jdk.test.lib.JDKToolLauncher; import jdk.test.lib.Utils; @@ -114,6 +117,7 @@ public static void main(String[] args) throws Exception { testDump(); testDumpLive(); testDumpAll(); + testDumpCompressed(); } private static void testHisto() throws Exception { @@ -211,20 +215,25 @@ private static void testClstats() throws Exception { } private static void testDump() throws Exception { - dump(false, false); + dump(false, false, false); } private static void testDumpLive() throws Exception { - dump(true, false); + dump(true, false, false); } private static void testDumpAll() throws Exception { - dump(false, true); + dump(false, true, false); } - private static void dump(boolean live, boolean explicitAll) throws Exception { + private static void testDumpCompressed() throws Exception { + dump(true, false, true); + } + + private static void dump(boolean live, boolean explicitAll, boolean compressed) throws Exception { String liveArg = ""; String fileArg = ""; + String compressArg = ""; String allArgs = "-dump:"; if (live && explicitAll) { @@ -237,14 +246,20 @@ private static void dump(boolean live, boolean explicitAll) throws Exception { liveArg = "all,"; } - File file = new File("jmap.dump" + System.currentTimeMillis() + ".hprof"); + String filePath = "jmap.dump" + System.currentTimeMillis() + ".hprof"; + if (compressed) { + compressArg = "gz=1,"; + filePath = filePath + ".gz"; + } + + File file = new File(filePath); if (file.exists()) { file.delete(); } fileArg = "file=" + file.getName(); OutputAnalyzer output; - allArgs = allArgs + liveArg + "format=b," + fileArg; + allArgs = allArgs + liveArg + compressArg + "format=b," + fileArg; output = jmap(allArgs); output.shouldHaveExitValue(0); output.shouldContain("Heap dump file created"); @@ -255,7 +270,18 @@ private static void dump(boolean live, boolean explicitAll) throws Exception { private static void verifyDumpFile(File dump) { assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath()); try { - HprofParser.parse(dump); + File out = HprofParser.parse(dump); + + assertTrue(out != null && out.exists() && out.isFile(), + "Could not find hprof parser output file"); + List lines = Files.readAllLines(out.toPath()); + assertTrue(lines.size() > 0, "hprof parser output file is empty"); + for (String line : lines) { + assertFalse(line.matches(".*WARNING(?!.*Failed to resolve " + + "object.*constantPoolOop.*).*")); + } + + out.delete(); } catch (Exception e) { e.printStackTrace(); fail("Could not parse dump file " + dump.getAbsolutePath()); diff --git a/test/jdk/tools/jlink/plugins/CompressorPluginTest.java b/test/jdk/tools/jlink/plugins/CompressorPluginTest.java index dbed1a726bf..d434940303c 100644 --- a/test/jdk/tools/jlink/plugins/CompressorPluginTest.java +++ b/test/jdk/tools/jlink/plugins/CompressorPluginTest.java @@ -95,17 +95,19 @@ public void test() throws Exception { // compress level 0 == no compression Properties options0 = new Properties(); - options0.setProperty(DefaultCompressPlugin.NAME, - "0"); - checkCompress(classes, new DefaultCompressPlugin(), + DefaultCompressPlugin compressPlugin = new DefaultCompressPlugin(); + options0.setProperty(compressPlugin.getName(), + DefaultCompressPlugin.LEVEL_0); + checkCompress(classes, compressPlugin, options0, new ResourceDecompressorFactory[]{ }); // compress level 1 == String sharing Properties options1 = new Properties(); - options1.setProperty(DefaultCompressPlugin.NAME, "1"); - checkCompress(classes, new DefaultCompressPlugin(), + compressPlugin = new DefaultCompressPlugin(); + options1.setProperty(compressPlugin.getName(), DefaultCompressPlugin.LEVEL_1); + checkCompress(classes, compressPlugin, options1, new ResourceDecompressorFactory[]{ new StringSharingDecompressorFactory() @@ -114,8 +116,9 @@ public void test() throws Exception { // compress level 1 == String sharing + filter options1.setProperty(DefaultCompressPlugin.FILTER, "**Exception.class"); - options1.setProperty(DefaultCompressPlugin.NAME, "1"); - checkCompress(classes, new DefaultCompressPlugin(), + compressPlugin = new DefaultCompressPlugin(); + options1.setProperty(compressPlugin.getName(), DefaultCompressPlugin.LEVEL_1); + checkCompress(classes, compressPlugin, options1, new ResourceDecompressorFactory[]{ new StringSharingDecompressorFactory() @@ -125,8 +128,9 @@ public void test() throws Exception { Properties options2 = new Properties(); options2.setProperty(DefaultCompressPlugin.FILTER, "**Exception.class"); - options2.setProperty(DefaultCompressPlugin.NAME, "2"); - checkCompress(classes, new DefaultCompressPlugin(), + compressPlugin = new DefaultCompressPlugin(); + options2.setProperty(compressPlugin.getName(), DefaultCompressPlugin.LEVEL_2); + checkCompress(classes, compressPlugin, options2, new ResourceDecompressorFactory[]{ new ZipDecompressorFactory() @@ -135,8 +139,9 @@ public void test() throws Exception { // compress level 2 == ZIP + filter options2.setProperty(DefaultCompressPlugin.FILTER, "**Exception.class"); - options2.setProperty(DefaultCompressPlugin.NAME, "2"); - checkCompress(classes, new DefaultCompressPlugin(), + compressPlugin = new DefaultCompressPlugin(); + options2.setProperty(compressPlugin.getName(), DefaultCompressPlugin.LEVEL_2); + checkCompress(classes, compressPlugin, options2, new ResourceDecompressorFactory[]{ new ZipDecompressorFactory(), diff --git a/test/jdk/tools/jpackage/apps/image/Hello.java b/test/jdk/tools/jpackage/apps/image/Hello.java index 881403a7d3a..dd6f114a421 100644 --- a/test/jdk/tools/jpackage/apps/image/Hello.java +++ b/test/jdk/tools/jpackage/apps/image/Hello.java @@ -154,6 +154,12 @@ private static Hello createInstance() { trace("Environment supports a display"); + if (!Desktop.isDesktopSupported()) { + return null; + } + + trace("Environment supports a desktop"); + try { // Disable JAB. // Needed to suppress error: diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java index f10e01fc52e..d4d251e70d8 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.Functional.ThrowingSupplier; import jdk.jpackage.test.PackageTest.PackageHandlers; +import jdk.jpackage.internal.RetryExecutor; import org.xml.sax.SAXException; import org.w3c.dom.NodeList; @@ -66,11 +67,36 @@ public static void withExplodedDmg(JPackageCommand cmd, cmd.outputBundle(), dmgImage)); ThrowingConsumer.toConsumer(consumer).accept(dmgImage); } finally { - // detach might not work right away due to resource busy error, so - // repeat detach several times or fail. Try 10 times with 3 seconds - // delay. - Executor.of("/usr/bin/hdiutil", "detach").addArgument(mountPoint). - executeAndRepeatUntilExitCode(0, 10, 3); + String cmdline[] = { + "/usr/bin/hdiutil", + "detach", + "-verbose", + mountPoint.toAbsolutePath().toString()}; + // "hdiutil detach" might not work right away due to resource busy error, so + // repeat detach several times. + RetryExecutor retryExecutor = new RetryExecutor(); + // Image can get detach even if we got resource busy error, so stop + // trying to detach it if it is no longer attached. + retryExecutor.setExecutorInitializer(exec -> { + if (!Files.exists(mountPoint)) { + retryExecutor.abort(); + } + }); + try { + // 10 times with 6 second delays. + retryExecutor.setMaxAttemptsCount(10) + .setAttemptTimeoutMillis(6000) + .execute(cmdline); + } catch (IOException ex) { + if (!retryExecutor.isAborted()) { + // Now force to detach if it still attached + if (Files.exists(mountPoint)) { + Executor.of("/usr/bin/hdiutil", "detach", + "-force", "-verbose") + .addArgument(mountPoint).execute(); + } + } + } } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index 458fd0d7d45..528973bea22 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -63,7 +63,7 @@ private static Path getInstallationSubDirectory(JPackageCommand cmd) { private static void runMsiexecWithRetries(Executor misexec) { Executor.Result result = null; - for (int attempt = 0; attempt != 3; ++attempt) { + for (int attempt = 0; attempt < 8; ++attempt) { result = misexec.executeWithoutExitCodeCheck(); // The given Executor may either be of an msiexe command or an @@ -72,7 +72,8 @@ private static void runMsiexecWithRetries(Executor misexec) { if ((result.exitCode == 1618) || (result.exitCode == 1603)) { // Another installation is already in progress. // Wait a little and try again. - ThrowingRunnable.toRunnable(() -> Thread.sleep(3000)).run(); + Long timeout = 1000L * (attempt + 3); // from 3 to 10 seconds + ThrowingRunnable.toRunnable(() -> Thread.sleep(timeout)).run(); continue; } break; @@ -113,14 +114,18 @@ static PackageHandlers createMsiPackageHandlers() { } static PackageHandlers createExePackageHandlers() { - PackageHandlers exe = new PackageHandlers(); - // can't have install handler without also having uninstall handler - // so following is commented out for now - // exe.installHandler = cmd -> { - // cmd.verifyIsOfType(PackageType.WIN_EXE); - // new Executor().setExecutable(cmd.outputBundle()).execute(); - // }; + BiConsumer installExe = (cmd, install) -> { + cmd.verifyIsOfType(PackageType.WIN_EXE); + Executor exec = new Executor().setExecutable(cmd.outputBundle()); + if (!install) { + exec.addArgument("uninstall"); + } + runMsiexecWithRetries(exec); + }; + PackageHandlers exe = new PackageHandlers(); + exe.installHandler = cmd -> installExe.accept(cmd, true); + exe.uninstallHandler = cmd -> installExe.accept(cmd, false); return exe; } diff --git a/test/jdk/tools/jpackage/macosx/base/SigningBase.java b/test/jdk/tools/jpackage/macosx/base/SigningBase.java index 68a4c01ae11..9c7f7f21851 100644 --- a/test/jdk/tools/jpackage/macosx/base/SigningBase.java +++ b/test/jdk/tools/jpackage/macosx/base/SigningBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ private static void checkString(List result, String lookupString) { private static List codesignResult(Path target, boolean signed) { int exitCode = signed ? 0 : 1; List result = new Executor() - .setExecutable("codesign") + .setExecutable("/usr/bin/codesign") .addArguments("--verify", "--deep", "--strict", "--verbose=2", target.toString()) .saveOutput() diff --git a/test/jdk/tools/jpackage/macosx/base/SigningCheck.java b/test/jdk/tools/jpackage/macosx/base/SigningCheck.java index 3d0b4a44e34..9647f439411 100644 --- a/test/jdk/tools/jpackage/macosx/base/SigningCheck.java +++ b/test/jdk/tools/jpackage/macosx/base/SigningCheck.java @@ -47,7 +47,7 @@ public static void checkCertificates() { private static List findCertificate(String name, String keyChain) { List result = new Executor() - .setExecutable("security") + .setExecutable("/usr/bin/security") .addArguments("find-certificate", "-c", name, "-a", keyChain) .executeAndGetOutput(); @@ -89,7 +89,7 @@ private static void validateCertificateTrust(String name) { // will not be listed as trusted by dump-trust-settings if (SigningBase.DEV_NAME.equals("jpackage.openjdk.java.net")) { List result = new Executor() - .setExecutable("security") + .setExecutable("/usr/bin/security") .addArguments("dump-trust-settings") .executeWithoutExitCodeCheckAndGetOutput(); result.stream().forEachOrdered(TKit::trace); diff --git a/test/jdk/tools/jpackage/share/RuntimePackageTest.java b/test/jdk/tools/jpackage/share/RuntimePackageTest.java index 9c4c24e3dcb..9f7f61eeb15 100644 --- a/test/jdk/tools/jpackage/share/RuntimePackageTest.java +++ b/test/jdk/tools/jpackage/share/RuntimePackageTest.java @@ -126,7 +126,11 @@ private static PackageTest init(Set types) { private static Set listFiles(Path root) throws IOException { try (var files = Files.walk(root)) { - return files.map(root::relativize).collect(Collectors.toSet()); + // Ignore files created by system prefs if any. + final Path prefsDir = Path.of(".systemPrefs"); + return files.map(root::relativize) + .filter(x -> !x.startsWith(prefsDir)) + .collect(Collectors.toSet()); } } diff --git a/test/jdk/tools/launcher/TestSpecialArgs.java b/test/jdk/tools/launcher/TestSpecialArgs.java index 25e877be4b9..a3953093a08 100644 --- a/test/jdk/tools/launcher/TestSpecialArgs.java +++ b/test/jdk/tools/launcher/TestSpecialArgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7124089 7131021 8042469 8066185 8074373 + * @bug 7124089 7131021 8042469 8066185 8074373 8258917 * @summary Checks for Launcher special flags, such as MacOSX specific flags, * and JVM NativeMemoryTracking flags. * @modules jdk.compiler @@ -252,6 +252,18 @@ void testNMArgumentProcessing() throws FileNotFoundException { ensureNoWarnings(tr); } + @Test + void testNMTTools() throws FileNotFoundException { + TestResult tr; + // Tools (non-java launchers) should handle NTM (no "wrong launcher" warning). + tr = doExec(jarCmd, "-J-XX:NativeMemoryTracking=summary", "--help"); + ensureNoWarnings(tr); + + // And java terminal args (like "--help") don't stop "-J" args parsing. + tr = doExec(jarCmd, "--help", "-J-XX:NativeMemoryTracking=summary"); + ensureNoWarnings(tr); + } + void ensureNoWarnings(TestResult tr) { checkTestResult(tr); if (tr.contains("warning: Native Memory Tracking")) { diff --git a/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java index 37f021e1354..f8be5825751 100644 --- a/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java +++ b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -239,15 +239,15 @@ void run(Path jarFile, String action, Result expectedResult, String... vmopts) } @Test(dataProvider = "denyCases") - public void testDeny(String action, Result expectedResult) throws Exception { - run(action, expectedResult, "--illegal-access=deny"); - } - - @Test(dataProvider = "permitCases") public void testDefault(String action, Result expectedResult) throws Exception { run(action, expectedResult); } + @Test(dataProvider = "denyCases") + public void testDeny(String action, Result expectedResult) throws Exception { + run(action, expectedResult, "--illegal-access=deny"); + } + @Test(dataProvider = "permitCases") public void testPermit(String action, Result expectedResult) throws Exception { run(action, expectedResult, "--illegal-access=permit"); @@ -267,41 +267,42 @@ public void testDebug(String action, Result expectedResult) throws Exception { run(action, expectedResult, "--illegal-access=debug"); } - /** * Specify --add-exports to export a package */ public void testWithAddExportsOption() throws Exception { - // warning - run("reflectPublicMemberNonExportedPackage", successWithWarning()); + // not accessible + run("reflectPublicMemberNonExportedPackage", fail("IllegalAccessException")); - // no warning due to --add-exports + // should succeed with --add-exports run("reflectPublicMemberNonExportedPackage", successNoWarning(), "--add-exports", "java.base/sun.security.x509=ALL-UNNAMED"); - // attempt two illegal accesses, one allowed by --add-exports - run("reflectPublicMemberNonExportedPackage" - + ",setAccessibleNonPublicMemberExportedPackage", - successWithWarning(), - "--add-exports", "java.base/sun.security.x509=ALL-UNNAMED"); + // not accessible + run("setAccessibleNonPublicMemberNonExportedPackage", fail("InaccessibleObjectException")); + + // should fail as --add-exports does not open package + run("setAccessibleNonPublicMemberNonExportedPackage", fail("InaccessibleObjectException"), + "--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED"); } /** * Specify --add-open to open a package */ public void testWithAddOpensOption() throws Exception { - // warning - run("setAccessibleNonPublicMemberExportedPackage", successWithWarning()); + // not accessible + run("reflectPublicMemberNonExportedPackage", fail("IllegalAccessException")); + + // should succeed with --add-opens + run("reflectPublicMemberNonExportedPackage", successNoWarning(), + "--add-opens", "java.base/sun.security.x509=ALL-UNNAMED"); + + // not accessible + run("setAccessibleNonPublicMemberExportedPackage", fail("InaccessibleObjectException")); - // no warning due to --add-opens + // should succeed with --add-opens run("setAccessibleNonPublicMemberExportedPackage", successNoWarning(), "--add-opens", "java.base/java.lang=ALL-UNNAMED"); - - // attempt two illegal accesses, one allowed by --add-opens - run("reflectPublicMemberNonExportedPackage" - + ",setAccessibleNonPublicMemberExportedPackage", - successWithWarning(), - "--add-opens", "java.base/java.lang=ALL-UNNAMED"); } /** @@ -373,19 +374,20 @@ public void testWithAddExportsInManifest() throws Exception { Attributes attrs = man.getMainAttributes(); attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); attrs.put(Attributes.Name.MAIN_CLASS, "TryAccess"); - attrs.put(new Attributes.Name("Add-Exports"), "java.base/sun.security.x509"); + attrs.put(new Attributes.Name("Add-Exports"), + "java.base/sun.security.x509 java.base/sun.nio.ch"); Path jarfile = Paths.get("x.jar"); Path classes = Paths.get(TEST_CLASSES); JarUtils.createJarFile(jarfile, man, classes, Paths.get("TryAccess.class")); run(jarfile, "reflectPublicMemberNonExportedPackage", successNoWarning()); - run(jarfile, "setAccessibleNonPublicMemberExportedPackage", successWithWarning()); + run(jarfile, "reflectPublicMemberNonExportedPackage", successNoWarning(), + "--illegal-access=permit"); - // attempt two illegal accesses, one allowed by Add-Exports - run(jarfile, "reflectPublicMemberNonExportedPackage," - + "setAccessibleNonPublicMemberExportedPackage", - successWithWarning()); + // should fail as Add-Exports does not open package + run(jarfile, "setAccessibleNonPublicMemberNonExportedPackage", + fail("InaccessibleObjectException")); } /** @@ -403,29 +405,26 @@ public void testWithAddOpensInManifest() throws Exception { run(jarfile, "setAccessibleNonPublicMemberExportedPackage", successNoWarning()); - run(jarfile, "reflectPublicMemberNonExportedPackage", successWithWarning()); - - // attempt two illegal accesses, one allowed by Add-Opens - run(jarfile, "reflectPublicMemberNonExportedPackage," - + "setAccessibleNonPublicMemberExportedPackage", - successWithWarning()); + run(jarfile, "setAccessibleNonPublicMemberExportedPackage", successNoWarning(), + "--illegal-access=permit"); } /** - * Test that default behavior is to print a warning on the first illegal - * access only. + * Test that --illegal-access=permit behavior is to print a warning on the + * first illegal access only. */ public void testWarnOnFirstIllegalAccess() throws Exception { String action1 = "reflectPublicMemberNonExportedPackage"; String action2 = "setAccessibleNonPublicMemberExportedPackage"; - int warningCount = count(run(action1).asLines(), "WARNING"); + int warningCount = count(run(action1, "--illegal-access=permit").asLines(), "WARNING"); + assertTrue(warningCount > 0); // multi line warning // same illegal access - List output1 = run(action1 + "," + action1).asLines(); + List output1 = run(action1 + "," + action1, "--illegal-access=permit").asLines(); assertTrue(count(output1, "WARNING") == warningCount); // different illegal access - List output2 = run(action1 + "," + action2).asLines(); + List output2 = run(action1 + "," + action2, "--illegal-access=permit").asLines(); assertTrue(count(output2, "WARNING") == warningCount); } diff --git a/test/jdk/tools/launcher/modules/patch/automatic/PatchTest.java b/test/jdk/tools/launcher/modules/patch/automatic/PatchTest.java new file mode 100644 index 00000000000..cf2b6318015 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/PatchTest.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @library /test/lib + * @modules jdk.compiler + * @build PatchTest + * jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.util.JarUtils + * jdk.test.lib.process.ProcessTools + * @run testng PatchTest + * @bug 8259395 + * @summary Tests patching an automatic module + */ + +import java.io.File; +import java.util.List; +import java.nio.file.Files; +import java.nio.file.Path; + +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.util.JarUtils; +import static jdk.test.lib.process.ProcessTools.*; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeClass; +import static org.testng.Assert.*; + +public class PatchTest { + + private static final String APP_NAME = "myapp"; + + private static final String MODULE_NAME = "somelib"; + + private static final String EXTEND_PATCH_NAME = "patch1"; + private static final String AUGMENT_PATCH_NAME = "patch2"; + + private static final String APP_MAIN = "myapp.Main"; + private static final String EXTEND_PATCH_MAIN = "somelib.test.TestMain"; + private static final String AUGMENT_PATCH_MAIN = "somelib.Dummy"; + + private static final String TEST_SRC = System.getProperty("test.src"); + + private static final Path APP_SRC = Path.of(TEST_SRC, APP_NAME); + private static final Path APP_CLASSES = Path.of("classes", APP_NAME); + private static final Path SOMELIB_SRC = Path.of(TEST_SRC, MODULE_NAME); + private static final Path SOMELIB_EXTEND_PATCH_SRC = Path.of(TEST_SRC, EXTEND_PATCH_NAME); + private static final Path SOMELIB_AUGMENT_PATCH_SRC = Path.of(TEST_SRC, AUGMENT_PATCH_NAME); + private static final Path SOMELIB_CLASSES = Path.of("classes", MODULE_NAME); + private static final Path SOMELIB_EXTEND_PATCH_CLASSES = Path.of("classes", EXTEND_PATCH_NAME); + private static final Path SOMELIB_AUGMENT_PATCH_CLASSES = Path.of("classes", AUGMENT_PATCH_NAME); + private static final Path SOMELIB_JAR = Path.of("mods", MODULE_NAME + "-0.19.jar"); + + private static final String MODULE_PATH = String.join(File.pathSeparator, SOMELIB_JAR.toString(), APP_CLASSES.toString()); + + /** + * The test consists of 2 modules: + * + * somelib - dummy automatic module. + * myapp - explicit module, uses somelib + * + * And two patches: + * + * patch1 - adds an additional package. (extend) + * patch2 - only replaces existing classes. (augment) + * + */ + @BeforeClass + public void compile() throws Exception { + boolean compiled; + + // create mods/somelib-0.19.jar + + compiled = CompilerUtils.compile(SOMELIB_SRC, SOMELIB_CLASSES); + assertTrue(compiled); + + JarUtils.createJarFile(SOMELIB_JAR, SOMELIB_CLASSES); + + + // compile patch 1 + compiled = CompilerUtils.compile(SOMELIB_EXTEND_PATCH_SRC, SOMELIB_EXTEND_PATCH_CLASSES, + "--module-path", SOMELIB_JAR.toString(), + "--add-modules", MODULE_NAME, + "--patch-module", MODULE_NAME + "=" + SOMELIB_EXTEND_PATCH_SRC); + assertTrue(compiled); + + // compile patch 2 + compiled = CompilerUtils.compile(SOMELIB_AUGMENT_PATCH_SRC, SOMELIB_AUGMENT_PATCH_CLASSES, + "--module-path", SOMELIB_JAR.toString(), + "--add-modules", MODULE_NAME, + "--patch-module", MODULE_NAME + "=" + SOMELIB_AUGMENT_PATCH_SRC); + assertTrue(compiled); + + // compile app + compiled = CompilerUtils.compile(APP_SRC, APP_CLASSES, + "--module-path", SOMELIB_JAR.toString()); + assertTrue(compiled); + } + + @Test + public void testExtendAutomaticModuleOnModulePath() throws Exception { + int exitValue + = executeTestJava("--module-path", MODULE_PATH, + "--patch-module", MODULE_NAME + "=" + SOMELIB_EXTEND_PATCH_CLASSES, + "-m", APP_NAME + "/" + APP_MAIN, "patch1") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + + @Test + public void testAugmentAutomaticModuleOnModulePath() throws Exception { + int exitValue + = executeTestJava("--module-path", MODULE_PATH, + "--patch-module", MODULE_NAME + "=" + SOMELIB_AUGMENT_PATCH_CLASSES, + "-m", APP_NAME + "/" + APP_MAIN, "patch2") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + + @Test + public void testExtendAutomaticModuleAsInitialModule() throws Exception { + int exitValue + = executeTestJava("--module-path", SOMELIB_JAR.toString(), + "--patch-module", MODULE_NAME + "=" + SOMELIB_EXTEND_PATCH_CLASSES, + "-m", MODULE_NAME + "/" + EXTEND_PATCH_MAIN) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + + @Test + public void testAugmentAutomaticModuleAsInitialModule() throws Exception { + int exitValue + = executeTestJava("--module-path", SOMELIB_JAR.toString(), + "--patch-module", MODULE_NAME + "=" + SOMELIB_AUGMENT_PATCH_CLASSES, + "-m", MODULE_NAME + "/" + AUGMENT_PATCH_MAIN) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/myapp/module-info.java b/test/jdk/tools/launcher/modules/patch/automatic/myapp/module-info.java new file mode 100644 index 00000000000..9100b5c280a --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/myapp/module-info.java @@ -0,0 +1,3 @@ +module myapp { + requires somelib; +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/myapp/myapp/Main.java b/test/jdk/tools/launcher/modules/patch/automatic/myapp/myapp/Main.java new file mode 100644 index 00000000000..6f17522f366 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/myapp/myapp/Main.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package myapp; + +import somelib.Invariants; + +/** + * This test is modelled to use --patch-module to gain access to non-exported internals. + */ + +public class Main { + public static void main(String[] args) { + Invariants.test(args[0]); + } +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/PatchInfo.java b/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/PatchInfo.java new file mode 100644 index 00000000000..1273edfe50b --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/PatchInfo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package somelib; + +// This class will be patched +public class PatchInfo { + + public static String patchName() { + return "patch1"; + } + +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/test/TestMain.java b/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/test/TestMain.java new file mode 100644 index 00000000000..b5982d58300 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/patch1/somelib/test/TestMain.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package somelib.test; + +import somelib.Invariants; + +/** + * This test is modelled to use --patch-module to gain access to non-exported internals. + */ + +public class TestMain { + public static void main(String[] args) { + Invariants.test("patch1"); + } +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/Dummy.java b/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/Dummy.java new file mode 100644 index 00000000000..d6d40d0cd7d --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/Dummy.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package somelib; + +public class Dummy { + public static boolean returnTrue() { + return true; + } + + public static void main(String[] args) { + Invariants.test("patch2"); + } +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/PatchInfo.java b/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/PatchInfo.java new file mode 100644 index 00000000000..374250c5794 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/patch2/somelib/PatchInfo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package somelib; + +// This class will be patched +public class PatchInfo { + + public static String patchName() { + return "patch2"; + } + +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Dummy.java b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Dummy.java new file mode 100644 index 00000000000..dc80db09fe0 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Dummy.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package somelib; + +public class Dummy { + public static boolean returnTrue() { + return true; + } +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Invariants.java b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Invariants.java new file mode 100644 index 00000000000..2f972ce9a61 --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/Invariants.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package somelib; + +import java.lang.module.ModuleDescriptor; + +public class Invariants { + public static void test(String expectPatch) { + ModuleDescriptor ownDesc = Invariants.class.getModule().getDescriptor(); + + assertThat(ownDesc.isAutomatic(), "Expected to be executed in an automatic module"); + assertThat(ownDesc.requires().stream().anyMatch( + r -> r.name().equals("java.base") && r.modifiers().contains(ModuleDescriptor.Requires.Modifier.MANDATED)), + "requires mandated java.base"); + assertThat(Dummy.returnTrue(), "Dummy.returnTrue returns true"); + assertThat(expectPatch.equals(PatchInfo.patchName()), "Module is patched with the right patch"); + } + + private static void assertThat(boolean expected, String message) { + if (!expected) { + throw new AssertionError(message); + } + } +} diff --git a/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/PatchInfo.java b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/PatchInfo.java new file mode 100644 index 00000000000..49f3b40683c --- /dev/null +++ b/test/jdk/tools/launcher/modules/patch/automatic/somelib/somelib/PatchInfo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package somelib; + +// This class will be patched +public class PatchInfo { + + public static String patchName() { + return "original"; + } + +} diff --git a/test/jdk/valhalla/valuetypes/InlineConstructorTest.java b/test/jdk/valhalla/valuetypes/InlineConstructorTest.java index 95348021c15..26f618248b3 100644 --- a/test/jdk/valhalla/valuetypes/InlineConstructorTest.java +++ b/test/jdk/valhalla/valuetypes/InlineConstructorTest.java @@ -61,7 +61,7 @@ public static void testInlineClassConstructor() throws Exception { String cn = INLINE_TYPE.getName(); Class c = Class.forName(cn); - assertTrue(c.isInlineClass()); + assertTrue(c.isPrimitiveClass()); assertEquals(c, INLINE_TYPE); } diff --git a/test/jdk/valhalla/valuetypes/MethodHandleTest.java b/test/jdk/valhalla/valuetypes/MethodHandleTest.java index fd3b28c835f..7d864c49604 100644 --- a/test/jdk/valhalla/valuetypes/MethodHandleTest.java +++ b/test/jdk/valhalla/valuetypes/MethodHandleTest.java @@ -118,15 +118,15 @@ static void testArray(Class c, Object o) throws Throwable { } Class elementType = c.getComponentType(); - if (elementType.isInlineClass()) { + if (elementType.isPrimitiveClass()) { assertTrue(elementType == elementType.valueType().get()); } // set an array element to null try { Object v = (Object)setter.invoke(array, 0, null); - assertFalse(elementType.isInlineClass(), "should fail to set an inline class array element to null"); + assertFalse(elementType.isPrimitiveClass(), "should fail to set an inline class array element to null"); } catch (NullPointerException e) { - assertTrue(elementType.isInlineClass(), "should only fail to set an inline class array element to null"); + assertTrue(elementType.isPrimitiveClass(), "should only fail to set an inline class array element to null"); } } @@ -161,7 +161,7 @@ public void run() throws Throwable { unreflectField(f); findGetter(f); varHandle(f); - if (c.isInlineClass()) + if (c.isPrimitiveClass()) ensureImmutable(f); else ensureNullable(f); @@ -194,7 +194,7 @@ void unreflectField(Field f) throws Throwable { void setValueField(String name, Object obj, Object value) throws Throwable { Field f = c.getDeclaredField(name); boolean isStatic = Modifier.isStatic(f.getModifiers()); - assertTrue(f.getType().isInlineClass() || f.getType().valueType().isPresent()); + assertTrue(f.getType().isPrimitiveClass() || f.getType().valueType().isPresent()); assertTrue((isStatic && obj == null) || (!isStatic && obj != null)); Object v = f.get(obj); @@ -289,7 +289,7 @@ private void setStaticField(Field f, Object value) throws Throwable { */ void ensureNullable(Field f) throws Throwable { assertFalse(Modifier.isStatic(f.getModifiers())); - boolean canBeNull = !f.getType().isInlineClass(); + boolean canBeNull = !f.getType().isPrimitiveClass(); // test reflection try { f.set(o, null); diff --git a/test/jdk/valhalla/valuetypes/Reflection.java b/test/jdk/valhalla/valuetypes/Reflection.java index 9b279127208..3e75853adbb 100644 --- a/test/jdk/valhalla/valuetypes/Reflection.java +++ b/test/jdk/valhalla/valuetypes/Reflection.java @@ -40,9 +40,9 @@ public class Reflection { @Test public static void sanityTest() { - assertTrue(Point.ref.class.permittedSubclasses().length == 1); - assertTrue(Line.ref.class.permittedSubclasses().length == 1); - assertTrue(NonFlattenValue.ref.class.permittedSubclasses().length == 1); + assertTrue(Point.ref.class.getPermittedSubclasses().length == 1); + assertTrue(Line.ref.class.getPermittedSubclasses().length == 1); + assertTrue(NonFlattenValue.ref.class.getPermittedSubclasses().length == 1); } @Test @@ -81,8 +81,8 @@ public static void testNonFlattenValue() throws Exception { @Test public static void testMirrors() throws Exception { Class inlineClass = Point.class; - assertTrue(inlineClass.isInlineClass()); - assertFalse(Point.ref.class.isInlineClass()); + assertTrue(inlineClass.isPrimitiveClass()); + assertFalse(Point.ref.class.isPrimitiveClass()); assertEquals(inlineClass.valueType().get(), Point.class); assertEquals(inlineClass.referenceType().get(), Point.ref.class); assertEquals(Point.ref.class.valueType().get(), Point.class); @@ -123,7 +123,7 @@ public static void testClassName() { private final Object o; Reflection(Class type, String cn, Object o) throws Exception { this.c = Class.forName(cn); - if (!c.isInlineClass() || c != type) { + if (!c.isPrimitiveClass() || c != type) { throw new RuntimeException(cn + " is not an inline class"); } @@ -164,7 +164,7 @@ void testArray(Class elementType) { Class arrayType = array.getClass(); assertTrue(arrayType.isArray()); Class componentType = arrayType.getComponentType(); - assertTrue(componentType.isInlineClass() || componentType.valueType().isPresent()); + assertTrue(componentType.isPrimitiveClass() || componentType.valueType().isPresent()); assertEquals(componentType, elementType); // Array is a reference type assertEquals(arrayType.referenceType().get(), arrayType); diff --git a/test/jdk/valhalla/valuetypes/UninitializedInlineValueTest.java b/test/jdk/valhalla/valuetypes/UninitializedInlineValueTest.java new file mode 100644 index 00000000000..ee43e3c76de --- /dev/null +++ b/test/jdk/valhalla/valuetypes/UninitializedInlineValueTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test + * @compile --enable-preview --source ${jdk.version} UninitializedInlineValueTest.java + * @run testng/othervm --enable-preview -XX:InlineFieldMaxFlatSize=128 UninitializedInlineValueTest + * @run testng/othervm --enable-preview -XX:InlineFieldMaxFlatSize=0 UninitializedInlineValueTest + * @summary Test reflection and method handle on accessing a field of inline type + * that may be flattened or non-flattened + */ + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Field; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class UninitializedInlineValueTest { + static inline class EmptyInline { + public boolean isEmpty() { + return true; + } + } + + static inline class InlineValue { + Object o; + EmptyInline empty; + InlineValue() { + this.o = null; + this.empty = new EmptyInline(); + } + } + + static class MutableValue { + Object o; + EmptyInline empty; + volatile EmptyInline vempty; + } + + @Test + public void emptyInlineClass() throws ReflectiveOperationException { + EmptyInline e = new EmptyInline(); + Field[] fields = e.getClass().getDeclaredFields(); + assertTrue(fields.length == 0); + } + + @Test + public void testInlineValue() throws ReflectiveOperationException { + InlineValue v = new InlineValue(); + Field f0 = v.getClass().getDeclaredField("o"); + Object o = f0.get(v); + assertTrue(o == null); + + // field of inline type must be non-null + Field f1 = v.getClass().getDeclaredField("empty"); + assertTrue(f1.getType() == EmptyInline.class); + EmptyInline empty = (EmptyInline)f1.get(v); + assertTrue(empty.isEmpty()); // test if empty is non-null with default value + } + + @Test + public void testMutableValue() throws ReflectiveOperationException { + MutableValue v = new MutableValue(); + Field f0 = v.getClass().getDeclaredField("o"); + f0.set(v, null); + assertTrue( f0.get(v) == null); + + // field of inline type must be non-null + Field f1 = v.getClass().getDeclaredField("empty"); + assertTrue(f1.getType() == EmptyInline.class); + EmptyInline empty = (EmptyInline)f1.get(v); + assertTrue(empty.isEmpty()); // test if empty is non-null with default value + + Field f2 = v.getClass().getDeclaredField("vempty"); + assertTrue(f2.getType() == EmptyInline.class); + EmptyInline vempty = (EmptyInline)f2.get(v); + assertTrue(vempty.isEmpty()); // test if vempty is non-null with default value + + f1.set(v, new EmptyInline()); + assertTrue((EmptyInline)f1.get(v) == new EmptyInline()); + f2.set(v, new EmptyInline()); + assertTrue((EmptyInline)f2.get(v) == new EmptyInline()); + } + + @Test + public void testMethodHandleInlineValue() throws Throwable { + InlineValue v = new InlineValue(); + MethodHandle mh = MethodHandles.lookup().findGetter(InlineValue.class, "empty", EmptyInline.class); + EmptyInline empty = (EmptyInline) mh.invokeExact(v); + assertTrue(empty.isEmpty()); // test if empty is non-null with default value + } + + @Test + public void testMethodHandleMutableValue() throws Throwable { + MutableValue v = new MutableValue(); + MethodHandle getter = MethodHandles.lookup().findGetter(MutableValue.class, "empty", EmptyInline.class); + EmptyInline empty = (EmptyInline) getter.invokeExact(v); + assertTrue(empty.isEmpty()); // test if empty is non-null with default value + + MethodHandle getter1 = MethodHandles.lookup().findGetter(MutableValue.class, "vempty", EmptyInline.class); + EmptyInline vempty = (EmptyInline) getter1.invokeExact(v); + assertTrue(vempty.isEmpty()); // test if vempty is non-null with default value + + MethodHandle setter = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyInline.class); + setter.invokeExact(v, new EmptyInline()); + empty = (EmptyInline) getter.invokeExact(v); + assertTrue(empty == new EmptyInline()); + + MethodHandle setter1 = MethodHandles.lookup().findSetter(MutableValue.class, "vempty", EmptyInline.class); + setter1.invokeExact(v, new EmptyInline()); + vempty = (EmptyInline) getter1.invokeExact(v); + assertTrue(vempty == new EmptyInline()); + } + + @Test(expectedExceptions = { IllegalAccessException.class}) + public void noWriteAccess() throws ReflectiveOperationException { + InlineValue v = new InlineValue(); + Field f = v.getClass().getDeclaredField("empty"); + f.set(v, null); + } + + @Test(expectedExceptions = { NullPointerException.class}) + public void nonNullableField_reflection() throws ReflectiveOperationException { + MutableValue v = new MutableValue(); + Field f = v.getClass().getDeclaredField("empty"); + f.set(v, null); + } + + @Test(expectedExceptions = { NullPointerException.class}) + public void nonNullableField_MethodHandle() throws Throwable { + MutableValue v = new MutableValue(); + MethodHandle mh = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyInline.class); + EmptyInline.ref e = null; + EmptyInline empty = (EmptyInline) mh.invokeExact(v, (EmptyInline)e); + } +} diff --git a/test/jdk/valhalla/valuetypes/ValueArray.java b/test/jdk/valhalla/valuetypes/ValueArray.java index 78690587b89..71477c60136 100644 --- a/test/jdk/valhalla/valuetypes/ValueArray.java +++ b/test/jdk/valhalla/valuetypes/ValueArray.java @@ -56,7 +56,7 @@ void run() { testClassName(); testArrayElements(); - if (componentType.isInlineClass()) { + if (componentType.isPrimitiveClass()) { Object[] qArray = (Object[]) Array.newInstance(componentType, 0); Object[] lArray = (Object[]) Array.newInstance(componentType.referenceType().get(), 0); testInlineArrayCovariance(componentType, qArray, lArray); @@ -72,7 +72,7 @@ void testClassName() { sb.append("["); c = c.getComponentType(); } - sb.append(c.isInlineClass() ? "Q" : "L").append(c.getName()).append(";"); + sb.append(c.isPrimitiveClass() ? "Q" : "L").append(c.getName()).append(";"); assertEquals(sb.toString(), arrayClassName); } @@ -92,7 +92,7 @@ void testArrayElements() { Arrays.setAll(array, i -> this.array[i]); // test nullable - if (!componentType.isInlineClass()) { + if (!componentType.isPrimitiveClass()) { for (int i=0; i < array.length; i++) { Array.set(array, i, null); } @@ -107,7 +107,7 @@ void testArrayElements() { } void testInlineArrayCovariance(Class componentType, Object[] qArray, Object[] lArray) { - assertTrue(componentType.isInlineClass()); + assertTrue(componentType.isPrimitiveClass()); // Class.instanceOf (self) assertTrue(qArray.getClass().isInstance(qArray)); diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 2f594461353..cdb3d6a3028 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -239,18 +239,17 @@ protected String vmJvmci() { return "false"; } - switch (GC.selected()) { - case Serial: - case Parallel: - case G1: - // These GCs are supported with JVMCI - return "true"; - default: - break; + // Not all GCs have full JVMCI support + if (!WB.isJVMCISupportedByGC()) { + return "false"; } - // Every other GC is not supported - return "false"; + // Interpreted mode cannot enable JVMCI + if (vmCompMode().equals("Xint")) { + return "false"; + } + + return "true"; } /** @@ -271,21 +270,6 @@ protected String cpuFeatures() { return CPUInfo.getFeatures().toString(); } - private boolean isGcSupportedByGraal(GC gc) { - switch (gc) { - case Serial: - case Parallel: - case G1: - return true; - case Epsilon: - case Z: - case Shenandoah: - return false; - default: - throw new IllegalStateException("Unknown GC " + gc.name()); - } - } - /** * For all existing GC sets vm.gc.X property. * Example vm.gc.G1=true means: @@ -296,11 +280,11 @@ private boolean isGcSupportedByGraal(GC gc) { * @param map - property-value pairs */ protected void vmGC(SafeMap map) { - var isGraalEnabled = Compiler.isGraalEnabled(); + var isJVMCIEnabled = Compiler.isJVMCIEnabled(); for (GC gc: GC.values()) { map.put("vm.gc." + gc.name(), () -> "" + (gc.isSupported() - && (!isGraalEnabled || isGcSupportedByGraal(gc)) + && (!isJVMCIEnabled || gc.isSupportedByJVMCICompiler()) && (gc.isSelected() || GC.isSelectedErgonomically()))); } } diff --git a/test/langtools/ProblemList.txt b/test/langtools/ProblemList.txt index 38aa386de32..c9f71106f0a 100644 --- a/test/langtools/ProblemList.txt +++ b/test/langtools/ProblemList.txt @@ -75,3 +75,4 @@ tools/sjavac/ClasspathDependencies.java # # jdeps +tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java 8258421 generic-all Deprecation vs JDK-private annotation class diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT index ae86a0030e8..b4011478db0 100644 --- a/test/langtools/TEST.ROOT +++ b/test/langtools/TEST.ROOT @@ -22,3 +22,7 @@ useNewOptions=true # Use --patch-module instead of -Xmodule: useNewPatchModule=true + +# Path to libraries in the topmost test directory. This is needed so @library +# does not need ../../ notation to reach them +external.lib.roots = ../../ diff --git a/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java b/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java index 043c7e95732..02915f5cefc 100644 --- a/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java +++ b/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ public void testReflow() { "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" + "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" + "1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234 1234\n" + - "1234 1234 1234 1234 1234 1234 1234 1234 1234\n"; + "1234 1234 1234 1234 1234 1234 1234 1234 1234 \n"; if (!Objects.equals(actual, expected)) { throw new AssertionError("Incorrect output: " + actual); diff --git a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java index e96d63cc869..622ee4b21f8 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java +++ b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4638136 7198273 8025633 8081854 8182765 + * @bug 4638136 7198273 8025633 8081854 8182765 8258659 * @summary Add ability to skip over nav bar for accessibility * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -54,8 +54,6 @@ public void test() { Skip navigation links""", // Top navbar """ - - - """); + """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testAbstractMethod/TestAbstractMethod.java b/test/langtools/jdk/javadoc/doclet/testAbstractMethod/TestAbstractMethod.java index ce84fa054e4..d834bbae92f 100644 --- a/test/langtools/jdk/javadoc/doclet/testAbstractMethod/TestAbstractMethod.java +++ b/test/langtools/jdk/javadoc/doclet/testAbstractMethod/TestAbstractMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,8 +50,8 @@ public void test() { checkOutput("pkg/A.html", true, """ -
      default void
      """, +
      default void
      """, """
      \ \
      """, """ -
      abstract void
      """); +
      abstract void
      """); checkOutput("pkg/C.html", true, """ diff --git a/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java b/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java index d0b324b73a0..488cb9238c4 100644 --- a/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java +++ b/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java @@ -50,6 +50,6 @@ public void test() { checkOutput("pkg/AnnotationOptional.html", true, """ -
      """); +
      """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java index 8f6c6eb766f..056a235287a 100644 --- a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java @@ -67,8 +67,7 @@ public void test() {

      DEFAULT_NAME

      static final <\ - span class="return-type">java.lang.String \ - DEFAULT_NAME
      + span class="return-type">java.lang.String DEFAULT_NAME """); checkOutput("pkg/AnnotationType.html", true, @@ -80,13 +79,12 @@ public void test() {
    9. Field | 
    10. """); checkOutput("pkg/AnnotationType.html", true, - "", + "", "
        ", "
      • ", """ -
        """, +
        """, "

        Element Details

        ", - "", "", "
          ", "
        • ", @@ -94,7 +92,7 @@ public void test() {
          """, "

          value

          \n", """ -
          int value
          """); +
          int value
          """); checkOutput("pkg/AnnotationType.html", false, """ @@ -124,10 +122,10 @@ public void testLinkSource() { checkOutput("pkg/AnnotationType.html", true, """ - public @interface AnnotationType"""); + public @interface AnnotationType"""); checkOutput("pkg/AnnotationTypeField.html", true, """ - public @interface AnnotationTypeField"""); + public @interface AnnotationTypeField"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java b/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java index e9264b38888..36a6b83c17d 100644 --- a/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java +++ b/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java @@ -57,21 +57,21 @@ public void test() {
        • pkg.ParentClass""", """ -

          Annotation Type Hierarchy

          +

          Annotation Interface Hierarchy

          """, """ -

          Enum Hierarchy

          +

          Enum Class Hierarchy

          • java.lang.Object
            • java.lang.Enum<E> (implements java.lang.Comparable<T\ >, java.lang.constant.Constable, java.io.Serializable)
            diff --git a/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java b/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java index a8844065bfe..0a26e9c3458 100644 --- a/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java +++ b/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java @@ -56,6 +56,7 @@ public void testDocFilesInModulePackages() { "Hello World" (phi-WINDOW-TITLE-phi)""", "phi-TOP-phi", // check top navbar + "phi-HEADER-phi", """ Module""", """ @@ -66,7 +67,6 @@ public void testDocFilesInModulePackages() { Deprecated""", """ Index""", - "phi-HEADER-phi", """ In a named module acme.module and named package p.""", "
            Since:Module""", """ @@ -103,7 +104,6 @@ public void testDocFilesInMultiModulePackagesWithRecursiveCopy() { Deprecated""", """ Index""", - "phi-HEADER-phi", """ In a named module acme.module and named package p.""", "
            Since:Module""", """ @@ -127,7 +128,6 @@ public void testDocFilesInMultiModulePackagesWithRecursiveCopy() { Deprecated""", """ Index""", - "phi-HEADER-phi", "SubSubReadme.html at third level of doc-file directory.", // check footer "phi-BOTTOM-phi" diff --git a/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java b/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java index 2a54b3e615e..5fdfef942e3 100644 --- a/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java +++ b/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,32 +80,33 @@ public void test() { checkOutput("pkg/DeprecatedClassByAnnotation.html", true, """ -
            @Deprecated
            -                    public class DeprecatedClassByAnnotation
            -                    extends java.lang.Object
            """, +
            @Deprecated + public class DeprecatedClassByAnnotation + extends java.lang.Object
            """, """
            @Deprecated(forRemoval=true) public int<\ - /span> field
            + /span> field
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            """, """
            @Deprecated(forRemoval=true) - public DeprecatedClassByAnnotation()
            + public DeprecatedClassByAnnotation()
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            """, """
            @Deprecated public void\ -  method()
            +  method()
            Deprecated.
            """); checkOutput("pkg/TestAnnotationType.html", true, """
            -
            @Deprecated(forRemoval=true)
            +                    
            @Deprecated(forRemoval=true) @Documented - public @interface TestAnnotationType
            + public @interface TestAnnotationType
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            annotation_test1 passes.
            @@ -113,21 +114,21 @@ public class DeprecatedClassByAnnotation """
            @Deprecated(forRemoval=true) static final int field
            + ">int field
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            annotation_test4 passes.
            """, """
            @Deprecated(forRemoval=true) - int required
            + int required
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            annotation_test3 passes.
            """, """
            java.lang.String&\ - nbsp;optional
            + nbsp;optional
            Deprecated.
            annotation_test2 passes.
            """); @@ -135,16 +136,16 @@ public class DeprecatedClassByAnnotation checkOutput("pkg/TestClass.html", true, """
            -
            @Deprecated(forRemoval=true)
            -                    public class TestClass
            -                    extends java.lang.Object
            +
            @Deprecated(forRemoval=true) + public class TestClass + extends java.lang.Object
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            class_test1 passes.
            """, """
            @Deprecated(forRemoval=true) - public TestClass()
            + public TestClass()
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            class_test3 passes. This is the second sentence\ @@ -171,22 +172,22 @@ public class TestClass
            """, """ -
            +
            Deprecated.
            class_test5 passes.
            """, """ -
            +
            Deprecated.
            class_test6 passes.
            """, """ -
            +
            Deprecated.
            class_test7 passes.
            @@ -212,9 +213,10 @@ public class TestClass checkOutput("pkg/TestEnum.html", true, """
            -
            @Deprecated(forRemoval=true)
            -                    public enum TestEnum
            -                    extends java.lang.Enum<TestEnum>
            +
            @Deprecated(forRemoval=true) + public enum TestEnum + extends java.lang.Enum<TestEnum>
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            enum_test1 passes.
            @@ -222,8 +224,8 @@ public enum TestEnum """
            @Deprecated(forRemoval=true) public static final TestEnum FOR_REMOVAL
            + rn-type">TestEnum FOR_REMOVAL
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            enum_test3 passes.
            @@ -232,9 +234,9 @@ public enum TestEnum checkOutput("pkg/TestError.html", true, """
            -
            @Deprecated(forRemoval=true)
            -                    public class TestError
            -                    extends java.lang.Error
            +
            @Deprecated(forRemoval=true) + public class TestError + extends java.lang.Error
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            error_test1 passes.
            @@ -243,9 +245,9 @@ public class TestError checkOutput("pkg/TestException.html", true, """
            -
            @Deprecated(forRemoval=true)
            -                    public class TestException
            -                    extends java.lang.Exception
            +
            @Deprecated(forRemoval=true) + public class TestException + extends java.lang.Exception
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            exception_test1 passes.
            @@ -254,9 +256,9 @@ public class TestException checkOutput("pkg/TestInterface.html", true, """
            -
            @Deprecated(forRemoval=true)
            -                    public class TestInterface
            -                    extends java.lang.Object
            +
            @Deprecated(forRemoval=true) + public class TestInterface + extends java.lang.Object
            Deprecated, for re\ moval: This API element is subject to removal in a future version.
            interface_test1 passes.
            @@ -267,15 +269,15 @@ public class TestInterface """, """
            @@ -284,12 +286,12 @@ public class TestInterface
            Element
            Description
            """, """ -
            -
            Enums
            +
            +
            Enum Classes
            -
            Enum
            +
            Enum Class
            Description
            - +
            enum_test1 passes.
            """, @@ -299,7 +301,7 @@ public class TestInterface
            Exceptions
            Description
            - +
            exception_test1 passes.
            """, @@ -309,25 +311,25 @@ public class TestInterface
            Field
            Description
            - +
            - +
            annotation_test4 passes.
            - +
            class_test2 passes. This is the second sentence of deprecated description for a field.
            - +
            error_test2 passes.
            - +
            exception_test2 passes.
            - +
            interface_test2 passes.
            @@ -339,25 +341,25 @@ public class TestInterface
            Method
            Description
            - +
            - +
            annotation_test2 passes.
            - +
            annotation_test3 passes.
            - +
            class_test5 passes. This is the second sentence of deprecated description for a method.
            - +
            class_test7 passes. Overloaded method 2.
            - +
            class_test6 passes. Overloaded method 1.
            """, @@ -367,13 +369,13 @@ public class TestInterface
            Constructor
            Description
            - +
            - +
            class_test3 passes. This is the second sentence of deprecated description for a constructor.
            - +
            class_test4 passes. Overloaded constructor.
            """); diff --git a/test/langtools/jdk/javadoc/doclet/testHelpFile/TestHelpFile.java b/test/langtools/jdk/javadoc/doclet/testHelpFile/TestHelpFile.java index 7497d4bd2ba..bc6c1d8f25c 100644 --- a/test/langtools/jdk/javadoc/doclet/testHelpFile/TestHelpFile.java +++ b/test/langtools/jdk/javadoc/doclet/testHelpFile/TestHelpFile.java @@ -63,7 +63,7 @@ public void test() {
            • Interfaces
            • Classes
            • -
            • Enums
            • """, +
            • Enum Classes
            • """, """
        • diff --git a/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java b/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java index 44f1ab79c3e..8612ac4d665 100644 --- a/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java +++ b/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java @@ -87,8 +87,9 @@ public void test1() { checkOutput("pkg1/A.VisibleInnerExtendsInvisibleInner.html", true, """ -
          public static class A.VisibleInnerExtendsInvisibleInner
          -                    extends A
          """, +
          public static class <\ + span class="element-name type-name-label">A.VisibleInnerExtendsInvisibleInner + extends A
          """, """ visibleField""", """ diff --git a/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java b/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java index 574c7bf5a4e..d8a085e5602 100644 --- a/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java +++ b/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java @@ -76,7 +76,8 @@ public void test() { "Class C4<E extends C4<E>>", //Signature does not link to the page itself. """ - public abstract class C4<E extends C4<E>>""" + public abstract class C4<E extends C4<E>>""" ); checkOutput(Output.OUT, false, diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java index 4b884752d91..fa373d588bd 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java @@ -106,9 +106,9 @@ void checkCommon(boolean checkC5) { // for default value. checkOutput("pkg1/C1.html", true, """ -
          public class C1
          -                    extends java.lang.Object
          -                    implements java.io.Serializable
          """); +
          public class C1 + extends java.lang.Object + implements java.io.Serializable
          """); checkOutput("pkg1/C4.html", true, """
          @@ -338,15 +338,14 @@ void checkNoCommentNoDeprecated(boolean expectFound) { checkOutput("pkg1/C1.html", expectFound, """
          public void readObject(\ - ) + lass="return-type">void readObject() throws java.io.IOException
        • """); checkOutput("pkg1/C2.html", expectFound, """ -
          public C2()
          +
          public C2()
      • """); @@ -354,8 +353,8 @@ void checkNoCommentNoDeprecated(boolean expectFound) { """
        public static final\  C1.ModalExclusionType APPLIC\ - ATION_EXCLUDE
        + class in pkg1">C1.ModalExclusionType APPLICATION_E\ + XCLUDE
      """); diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java index 248edc2607a..34cc2e5944a 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java @@ -50,7 +50,7 @@ public void test() { checkOutput(Output.OUT, true, "attribute not supported in HTML5: summary", """ - attribute border for table only accepts "" or "1", use CSS instead: BORDER""", + attribute "border" for table only accepts "" or "1": BORDER""", "attribute not supported in HTML5: cellpadding", "attribute not supported in HTML5: cellspacing", "attribute not supported in HTML5: align"); diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java index 03d0fa9d5e3..0bfb75659cf 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6786688 8008164 8162363 8169819 8183037 8182765 8184205 8242649 + * @bug 6786688 8008164 8162363 8169819 8183037 8182765 8184205 8242649 8259726 * @summary HTML tables should have table summary, caption and table headers. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -51,12 +51,30 @@ public void test() { javadoc("-d", "out", "-sourcepath", testSrc, "-use", + "--no-platform-links", "pkg1", "pkg2"); checkExit(Exit.OK); checkHtmlTableTag(); checkHtmlTableCaptions(); checkHtmlTableHeaders(); + checkHtmlTableContents(); + } + + @Test + public void testNoComment() { + javadoc("-d", "out-nocomment", + "-nocomment", + "-sourcepath", testSrc, + "-use", + "--no-platform-links", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkHtmlTableTag(); + checkHtmlTableCaptions(); + checkHtmlTableHeaders(); + checkHtmlTableContentsNoComment(); } /* @@ -173,10 +191,10 @@ void checkHtmlTableSummaries() { checkOutput("pkg2/package-summary.html", true, """
      - """, +
      """, """
      -
      """); +
      """); // Class documentation checkOutput("pkg1/C1.html", true, @@ -291,8 +309,8 @@ void checkHtmlTableCaptions() { "
      Interface Summary
      "); checkOutput("pkg2/package-summary.html", true, - "
      Enum Summary
      ", - "
      Annotation Types Summary
      "); + "
      Enum Class Summary
      ", + "
      Annotation Interfaces Summary
      "); // Class documentation checkOutput("pkg1/C1.html", true, @@ -355,7 +373,7 @@ void checkHtmlTableCaptions() { checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true, """ """); // Package use documentation @@ -403,10 +421,10 @@ void checkHtmlTableHeaders() { checkOutput("pkg2/package-summary.html", true, """ -
      Enum
      +
      Enum Class
      Description
      """, """ -
      Annotation Type
      +
      Annotation Interface
      Description
      """); // Class documentation @@ -520,4 +538,292 @@ void checkHtmlTableHeaders() {
      Package
      Description
      """); } + + /* + * Test for validating HTML table contents. + */ + void checkHtmlTableContents() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + """ + +
      +
      A sample interface used to test table tags.
      +
      """, + """ + +
      +
      A test class.
      +
      """); + + checkOutput("pkg2/package-summary.html", true, + """ + +
      +
      A sample enum.
      +
      """, + """ + +
      +
      Test Annotation class.
      +
      """); + + // Class documentation + checkOutput("pkg1/C1.html", true, + """ + + +
      +
      Test field for class.
      +
      """, + """ +
      void
      +
      method1​(int a, + int b)
      +
      +
      Method that is implemented.
      +
      """); + + checkOutput("pkg2/C2.html", true, + """ + + +
      +
      A test field.
      +
      """, + """ + +
      method​(C1 param)
      +
      +
      A sample method.
      +
      """); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + """ + +
      +
      Test comment.
      +
      """); + + checkOutput("pkg2/C3.html", true, + """ + +
      +
      Comment.
      +
      """); + + checkOutput("pkg2/C4.html", true, + """ +
      boolean
      + +
       
      + """); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + """ + +
      +
      Test package 1 used to test table tags.
      +
      """); + + checkOutput("pkg2/class-use/C2.html", true, + """ + +
      C1.<\ + code>field\ +
      +
      +
      Test field for class.
      +
      """, + """ + +
      C1.<\ + code>method​(C2 \ + ;param)
      +
      +
      Method thats does some processing.
      +
      """); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + """ + +
      +
      Test package 1 used to test table tags.
      +
      """, + """ + +
      +
      A test class.
      +
      """); + + // Deprecated + checkOutput("deprecated-list.html", true, + """ + +
      +
      don't use this field anymore.
      +
      """, + """ + +
      +
      don't use this anymore.
      +
      """); + + // Constant values + checkOutput("constant-values.html", true, + """ +
      public static final java.lang.String
      + +
      "C1"
      + """); + + // Overview Summary + checkOutput("index.html", true, + """ + +
      +
      Test package 1 used to test table tags.
      +
      """); + } + + /* + * Test for validating HTML table contents with -nocomment option. + */ + void checkHtmlTableContentsNoComment() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + """ + +
      """, + """ + +
      """); + + checkOutput("pkg2/package-summary.html", true, + """ + +
      """, + """ + +
      """); + + // Class documentation + checkOutput("pkg1/C1.html", true, + """ + + +
      """, + """ +
      void
      +
      method1​(int a, + int b)
      +
      """); + + checkOutput("pkg2/C2.html", true, + """ + + +
      """, + """ + +
      method​(C1 param)
      +
      """); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + """ + +
      """); + + checkOutput("pkg2/C3.html", true, + """ + +
      """); + + checkOutput("pkg2/C4.html", true, + """ +
      boolean
      + +
      + """); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + """ + +
      """); + + checkOutput("pkg2/class-use/C2.html", true, + """ + +
      C1.<\ + code>field\ +
      +
      """, + """ + +
      C1.<\ + code>method​(C2 \ + ;param)
      +
      """); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + """ + +
      """, + """ + +
      """); + + // Deprecated + checkOutput("deprecated-list.html", true, + """ + +
      """, + """ + +
      """); + + // Constant values + checkOutput("constant-values.html", true, + """ +
      public static final java.lang.String
      + +
      "C1"
      + """); + + // Overview Summary + checkOutput("index.html", true, + """ + +
      """); + } } diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java b/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java index ac9452962ff..66b75de1b1c 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java @@ -159,9 +159,10 @@ public void test_other() { checkOutput("pkg3/A.ActivationDesc.html", true, """ -
      public class A.ActivationDesc
      -                    extends java.lang.Object
      -                    implements java.io.Serializable
      +
      public class A.ActivationDesc + extends java.lang.Object + implements java.io.Serializable
      An activation descriptor contains the information necessary to activate an object:
      • the object's group identifier, @@ -181,9 +182,10 @@ public void test_other() { checkOutput("pkg3/A.ActivationGroupID.html", true, """ -
        public class A.ActivationGroupID
        -                    extends java.lang.Object
        -                    implements java.io.Serializable
        +
        public class A.ActivationGroupID + extends java.lang.Object + implements java.io.Serializable
        The identifier for a registered activation group serves several purposes:
        • identifies the group uniquely within the activation system, and diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java index 0b17cdb9757..8383dbe8c78 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java @@ -144,10 +144,10 @@ void html5Output() {

          Interface Hierarchy

          """, """
          -

          Annotation Type Hierarchy

          """, +

          Annotation Interface Hierarchy

          """, """
          -

          Enum Hierarchy

          """, +

          Enum Class Hierarchy

          """, """
          """, """ @@ -272,11 +272,11 @@ void html5Output() { """, """
          -

          Annotation Type Hierarchy

          +

          Annotation Interface Hierarchy

          """, """
          -

          Enum Hierarchy

          +

          Enum Class Hierarchy

          """, """
          """, @@ -534,19 +534,19 @@ void html5Output() {
          """, """ -
          +

          Required Element Summary

          Required Elements
          """, """ -
          +

          Optional Element Summary

          Optional Elements
          """, """ -
          +
            - +
          • Element Details

            @@ -759,7 +759,7 @@ void html5NegatedOutput() {

            Interface Hierarchy

            """, """
          -

          Enum Hierarchy

          """); +

          Enum Class Hierarchy

          """); // Negated test for index-all page checkOutput("index-all.html", false, diff --git a/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java b/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java index a2eb6926782..4c93bc8c4ee 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java +++ b/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java @@ -52,8 +52,7 @@ public void test() { """
          public <T> void m(T&nbs\ - p;t1, + n> m(T t1, T t2) throws java.lang.Exception
          """); diff --git a/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java b/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java index 3a1f87f3156..60da53d2fd4 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java +++ b/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java @@ -60,11 +60,11 @@ public void test() { >""", """ AnnotationType - Annotation Type in AnnotationType - Annotation Interface in pkg""", """ - Coin - Enum in pkg""", + Coin - Enum Class in pkg""", """ Class in <Unnamed>""", """ @@ -77,6 +77,6 @@ tic variable in class pkg.C
           
          """, """ -
          Enum - Search tag in enum pkg.Coin
          """); +
          Enum - Search tag in enum class pkg.Coin
          """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java index ab8b0bcf5f6..0e0e160fb19 100644 --- a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java +++ b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,11 +68,10 @@ public void test() { checkOutput("pkg/Interface.html", true, """ -
          int method()
          """, +
          int method()
          """, """
          static final <\ - span class="return-type">int field<\ - /div>""", + span class="return-type">int field
          """, // Make sure known implementing class list is correct and omits type parameters. """
          @@ -130,18 +129,17 @@ public void test() {

          f

          public static \ - int f + int f
          A hider field
          """, """ -
          static void
          - -
          +
          static void
          +
          m()
          +
          A hider method
          """, @@ -150,8 +148,8 @@ public void test() {

          staticMethod

          public static \ - void staticMetho\ - d()
          + void staticMethod()
          Description copied from inte\ rface: Inter\ faceWithStaticMembers
          @@ -160,8 +158,9 @@ public void test() { checkOutput("pkg/ClassWithStaticMembers.InnerClass.html", true, """ -
          public static class ClassWithStaticMembers.InnerClass
          -                    extends java.lang.Object
          +
          public static class <\ + span class="element-name type-name-label">ClassWithStaticMembers.InnerClass + extends java.lang.Object
          A hider inner class
          """); } diff --git a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java index 62fe5d34a8a..0d1a45feef4 100644 --- a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java +++ b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363 * 8167967 8172528 8175200 8178830 8182257 8186332 8182765 8025091 - * 8203791 8184205 + * 8203791 8184205 8249633 * @summary Test of the JavaFX doclet features. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -33,6 +33,10 @@ * @run main TestJavaFX */ +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + import javadoc.tester.JavadocTester; public class TestJavaFX extends JavadocTester { @@ -61,15 +65,15 @@ public void test1() { setRate(double)""", """
          public final <\ - span class="return-type">void setRate​(double value)
          + span class="return-type">void setRate̴\ + 3;(double value)
          Sets the value of the property rate.
          Property description:
          """, """
          public final <\ - span class="return-type">double getRate()
          + span class="return-type">double getRate()<\ + /div>
          Gets the value of the property rate.
          Property description:
          """, @@ -85,8 +89,8 @@ public void test1() {
          JavaFX 8.0
          """, "
          Property description:
          ", """ - """, """ + C.BooleanProperty pausedProperty
          Defines if paused. The second line.
          """, """

          isPaused

          public final <\ - span class="return-type">double isPaused()
          + span class="return-type">double isPaused()\ +
          Gets the value of the property paused.
          """, """

          setPaused

          public final <\ - span class="return-type">void setPaused​(boolean value)
          + span class="return-type">void setPaused\ + 203;(boolean value)
        Sets the value of the property paused.
        Property description:
        @@ -124,8 +127,8 @@ public void test1() {

        isPaused

        public final <\ - span class="return-type">double isPaused()
        + span class="return-type">double isPaused()\ +
      Gets the value of the property paused.
      Property description:
      @@ -137,16 +140,15 @@ public void test1() {

      rate

      public final <\ span class="return-type">C\ - .DoubleProperty rateProperty + .DoubleProperty rateProperty
      Defines the direction/speed at which the Timeline is expected to be played. This is the second line.
      """, """

      setRate

      public final <\ - span class="return-type">void setRate​(double value)
      + span class="return-type">void setRate̴\ + 3;(double value)
      Sets the value of the property rate.
      Property description:
      @@ -160,8 +162,8 @@ public void test1() {

      getRate

      public final <\ - span class="return-type">double getRate()
      + span class="return-type">double getRate()<\ + /div>
      Gets the value of the property rate.
      Property description:
      @@ -249,8 +251,8 @@ public void test2() {

      beta

      public java.lang.Object betaPr\ - operty
      + lass="return-type">java.lang.Object betaProperty<\ + /span>
    11. @@ -258,7 +260,7 @@ public void test2() {

      gamma

      public final <\ span class="return-type">java.util.List<java.lang.String> gammaProperty
      + n class="element-name">gammaProperty
    12. @@ -266,7 +268,7 @@ public void test2() {

      delta

      public final <\ span class="return-type">java.util.List<java.util.Set<? super java.lang.Ob\ - ject>> deltaProperty
      + ject>> deltaProperty
    13. @@ -315,37 +317,37 @@ public void test3() {
      Modifier and Type
      Method
      Description
      -
      <T> java.lang.Object
      - +
      alphaProperty​(java.util.List<T>\  foo)
      -
       
      -
      java.lang.Object
      - +
      java.lang.Object
      +
      -
       
      -
      java.util.List<java.util.Set<? super java.\ +
       
      +
      java.util.List<java.util.Set<? super java.\ lang.Object>>
      - -
       
      -
      java.util.List<java.lang.String> 
      +
      java.util.List<java.lang.String> - -
       
      """ +
       
      """ ); } @@ -368,4 +370,56 @@ public void test4() { // make sure the doclet indeed emits the warning checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag <"); } + + /* + * Verify that no warnings are produced on methods that may have synthesized comments. + */ + @Test + public void test5() throws IOException { + Path src5 = Files.createDirectories(Path.of("src5").resolve("pkg")); + Files.writeString(src5.resolve("MyClass.java"), + """ + package pkg; + + // The following import not required with --disable-javafx-strict-checks + // import javafx.beans.property.*; + + /** + * This is my class. + */ + public class MyClass { + /** + * This is my property that enables something + */ + private BooleanProperty something = new SimpleBooleanProperty(false); + + public final boolean isSomething() { + return something.get(); + } + + public final void setSomething(boolean val) { + something.set(val); + } + + public final BooleanProperty somethingProperty() { + return something; + } + + /** Dummy declaration. */ + public class BooleanProperty { } + } + """); + + javadoc("-d", "out5", + "--javafx", + "--disable-javafx-strict-checks", + "-Xdoclint:all", + "--source-path", "src5", + "pkg"); + checkExit(Exit.OK); + + checkOutput(Output.OUT, false, + "warning", + "no comment"); + } } diff --git a/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java b/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java index 486c5dd6262..c6a697fc8ef 100644 --- a/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java +++ b/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,12 +56,12 @@ public void testDefault() { checkOutput("pkg/A.html", true, """ -
      default void
      """, +
      default void
      """, """
      default void defaultMethod()
      + class="return-type">void defaultMethod() """, """
      \ diff --git a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java index 0487373cd9a..3e476dfd267 100644 --- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java +++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java @@ -112,9 +112,11 @@ Resource Identifiers (URI): Generic Syntax,
      public abstract class StringBuilderChild - extends Object""" +
      public abstract class StringBuilderChild + extends Object
      """ ); // Generate the documentation using -linkoffline and a relative path as the first parameter. @@ -155,8 +157,9 @@ Resource Identifiers (URI): Generic Syntax,
      public class A - extends java.lang.Object +
      public class A + extends java.lang.Object
      Test links.
      public class A - extends java.lang.Object +
      public class A + extends java.lang.Object
      Test links.
      - +
    14. Element Details

      @@ -240,9 +240,9 @@ public void m2() { } """
    15. """, """ diff --git a/test/langtools/jdk/javadoc/doclet/testMethodSignature/TestMethodSignature.java b/test/langtools/jdk/javadoc/doclet/testMethodSignature/TestMethodSignature.java index 91644b194bc..4bd0a81f4bd 100644 --- a/test/langtools/jdk/javadoc/doclet/testMethodSignature/TestMethodSignature.java +++ b/test/langtools/jdk/javadoc/doclet/testMethodSignature/TestMethodSignature.java @@ -51,11 +51,11 @@ public void test() { checkOutput("pkg/C.html", true, """
      @Generated("GeneratedConstructor") - public C()
      """, + public C()
      """, """
      public static \ - void simpleMetho\ + void simpleMetho\ d(int i, java.lang.String s, boolean b)
      """, @@ -65,8 +65,8 @@ public void test() { date="a date", comments="some comment about the method below") public static void annotatedMethod(int i, + e">void annotatedMethod(int i, java.lang.String s, boolean b)
      """, @@ -83,9 +83,9 @@ public void test() { T8 extends java.lang.AutoCloseable> C.Wit\ h8Types<T1,​T2,​T3,​T4,​T5,​T6,​T7,&#\ - 8203;T8> bigGenericMethod​\ - (C.F0&\ - lt;? extends T1> t1, + 8203;T8> bigGenericMethod(C.F0<? ex\ + tends T1> t1, C.F0<? extends T2> t2, C.F0<? extends T3> t3, C.F0<? extends T4> t4, @@ -111,9 +111,9 @@ public void test() { T8 extends java.lang.AutoCloseable> C.Wit\ h8Types<T1,​T2,​T3,​T4,​T5,​T6,​T7,&#\ - 8203;T8> bigGenericAnnotatedMethod​(\ - C.F0<? extends T1> t1, + 8203;T8> bigGenericAnnotatedMethod̴\ + 3;(C.F0<? extends T1> t1, C.F0<? extends T2> t2, C.F0<? extends T3> t3, C.F0<? extends T4> t4, diff --git a/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java b/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java index 684573a4b47..a9559fcd18e 100644 --- a/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,9 @@ public void test() { onclick="show('method-summary-table', 'method-summary-table-tab6', 3)" class="t\ able-tab">Deprecated Methods\
      """, - "
      "); + """ +
      """); checkOutput("pkg1/B.html", true, """ @@ -122,7 +124,9 @@ public void test() { onclick="show('method-summary-table', 'method-summary-table-tab6', 3)" class="t\ able-tab">Deprecated Methods\
      """, - "
      "); + """ +
      """); checkOutput("pkg1/A.html", false, "
      Methods
      "); diff --git a/test/langtools/jdk/javadoc/doclet/testModifierEx/TestModifierEx.java b/test/langtools/jdk/javadoc/doclet/testModifierEx/TestModifierEx.java index 6f13f6a61a0..326d7df8a1e 100644 --- a/test/langtools/jdk/javadoc/doclet/testModifierEx/TestModifierEx.java +++ b/test/langtools/jdk/javadoc/doclet/testModifierEx/TestModifierEx.java @@ -47,19 +47,24 @@ public void test1(){ checkExit(Exit.OK); checkOutput("pkg1/Abstract.html", true, """ -
      public abstract class Abstract""");
      +                    
      public abstract class Abstract"""); checkOutput("pkg1/Interface.html", true, """ -
      interface Interface
      """); +
      interface Interface
      """); checkOutput("pkg1/Interface.Kind.html", true, """ -
      public static interface Interface.Kind
      """); +
      public static interface Interface.Kind
      """); checkOutput("pkg1/Enum.html", true, """ -
      public enum Enum""");
      +                    
      public enum Enum"""); checkOutput("pkg1/Klass.StaticEnum.html", true, """ -
      public static enum Klass.StaticEnum""");
      +                    
      public static enum Klass.StaticEnum"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java b/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java index e756f8ee41e..7b23cbc14f8 100644 --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ public void exportSingle(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 3, TabKind.EXPORTS); checkTableHead("m"); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); } @Test @@ -118,8 +118,8 @@ public void exportMultiple(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 3, TabKind.EXPORTS); checkTableHead("m"); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); - checkPackageRow("m", "q", 1, "package-summary-table-tab1 package-summary-table", null, null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); + checkPackageRow("m", "q", 1, "package-summary-table package-summary-table-tab1", null, null, " "); } @Test @@ -147,8 +147,8 @@ public void exportSameName(Path base) throws Exception { checkCaption("o", 3, TabKind.EXPORTS); checkTableHead("m"); checkTableHead("o"); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); - checkPackageRow("o", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); + checkPackageRow("o", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); checkOutput("m/p/package-summary.html", true, """
      Module m
      @@ -201,7 +201,7 @@ public void exportSomeQualified(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 3, TabKind.EXPORTS); checkTableHead("m"); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); javadoc("-d", base.resolve("out-all").toString(), "-quiet", @@ -213,8 +213,8 @@ public void exportSomeQualified(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 3, TabKind.EXPORTS); checkTableHead("m", ColKind.EXPORTED_TO); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", "All Modules", null, " "); - checkPackageRow("m", "q", 1, "package-summary-table-tab1 package-summary-table", + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", "All Modules", null, " "); + checkPackageRow("m", "q", 1, "package-summary-table package-summary-table-tab1", """ other""", null, " "); } @@ -238,7 +238,7 @@ public void exportWithConcealed(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 4, TabKind.EXPORTS); checkTableHead("m"); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", null, null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", null, null, " "); javadoc("-d", base.resolve("out-all").toString(), "-quiet", @@ -251,8 +251,8 @@ public void exportWithConcealed(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 3, TabKind.EXPORTS, TabKind.CONCEALED); checkTableHead("m", ColKind.EXPORTED_TO); - checkPackageRow("m", "p", 0, "package-summary-table-tab1 package-summary-table", "All Modules", null, " "); - checkPackageRow("m", "q", 1, "package-summary-table-tab3 package-summary-table", "None", null, " "); + checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab1", "All Modules", null, " "); + checkPackageRow("m", "q", 1, "package-summary-table package-summary-table-tab3", "None", null, " "); } @Test @@ -287,8 +287,8 @@ public void exportOpenWithConcealed(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 4, TabKind.EXPORTS, TabKind.OPENS); checkTableHead("m", ColKind.EXPORTED_TO, ColKind.OPENED_TO); - checkPackageRow("m", "e.all", 0, "package-summary-table-tab1 package-summary-table", "All Modules", "None", " "); - checkPackageRow("m", "eo", 1, "package-summary-table-tab1 package-summary-table package-summary-table-tab2", "All Modules", "All Modules", " "); + checkPackageRow("m", "e.all", 0, "package-summary-table package-summary-table-tab1", "All Modules", "None", " "); + checkPackageRow("m", "eo", 1, "package-summary-table package-summary-table-tab1 package-summary-table-tab2", "All Modules", "All Modules", " "); javadoc("-d", base.resolve("out-all").toString(), "-quiet", @@ -301,12 +301,12 @@ public void exportOpenWithConcealed(Path base) throws Exception { checkExit(Exit.OK); checkCaption("m", 4, TabKind.EXPORTS, TabKind.OPENS, TabKind.CONCEALED); checkTableHead("m", ColKind.EXPORTED_TO, ColKind.OPENED_TO); - checkPackageRow("m", "c", 0, "package-summary-table-tab3 package-summary-table", "None", "None", " "); - checkPackageRow("m", "e.all", 1, "package-summary-table-tab1 package-summary-table", "All Modules", "None", " "); - checkPackageRow("m", "e.other", 2, "package-summary-table-tab1 package-summary-table", + checkPackageRow("m", "c", 0, "package-summary-table package-summary-table-tab3", "None", "None", " "); + checkPackageRow("m", "e.all", 1, "package-summary-table package-summary-table-tab1", "All Modules", "None", " "); + checkPackageRow("m", "e.other", 2, "package-summary-table package-summary-table-tab1", """ other""", "None", " "); - checkPackageRow("m", "eo", 3, "package-summary-table-tab1 package-summary-table package-summary-table-tab2", "All Modules", "All Modules", " "); + checkPackageRow("m", "eo", 3, "package-summary-table package-summary-table-tab1 package-summary-table-tab2", "All Modules", "All Modules", " "); checkPackageRow("m", "o.all", 4, "package-summary-table package-summary-table-tab2", "None", "All Modules", " "); checkPackageRow("m", "o.other", 5, "package-summary-table package-summary-table-tab2", "None", """ @@ -470,7 +470,7 @@ public void openWithConcealed(Path base) throws Exception { checkCaption("m", 3, TabKind.OPENS, TabKind.CONCEALED); checkTableHead("m", ColKind.OPENED_TO); checkPackageRow("m", "p", 0, "package-summary-table package-summary-table-tab2", null, "All Modules", " "); - checkPackageRow("m", "q", 1, "package-summary-table-tab3 package-summary-table", null, "None", " "); + checkPackageRow("m", "q", 1, "package-summary-table package-summary-table-tab3", null, "None", " "); } diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java index 09d6625f683..da5868ff3bb 100644 --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 * 8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464 * 8164407 8192007 8182765 8196200 8196201 8196202 8196202 8205593 8202462 - * 8184205 8219060 8223378 8234746 8239804 8239816 8253117 + * 8184205 8219060 8223378 8234746 8239804 8239816 8253117 8245058 * @summary Test modules support in javadoc. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -289,6 +289,7 @@ public void testSingleModuleMultiplePkg() { "--show-module-contents=all", "-Xdoclint:none", "--module-source-path", testSrc, + "--add-modules", "moduleC", "--module", "moduleB", "testpkg2mdlB", "testpkgmdlB"); checkExit(Exit.OK); @@ -497,27 +498,6 @@ void checkDescription(boolean found) {
      """); } - void checkNoDescription(boolean found) { - checkOutput("moduleA/module-summary.html", found, - """ -
      -

      @Deprecated(forRemoval=true) -

      -

      Module moduleA

      -
        -
      • -
          -
        • - """); - checkOutput("moduleB/module-summary.html", found, - """ -
            -
          • -
              -
            • - """); - } - void checkHtml5Description(boolean found) { checkOutput("moduleA/module-summary.html", found, """ @@ -563,10 +543,11 @@ void checkHtml5NoDescription(boolean found) { checkOutput("moduleA/module-summary.html", found, """
              -

              @Deprecated(forRemoval=true) -

              Module moduleA

              +
              +
              @Deprecated(forRemoval=true) + module moduleA
              • @@ -574,13 +555,15 @@ void checkHtml5NoDescription(boolean found) { """); checkOutput("moduleB/module-summary.html", found, """ -

                @\ - AnnotationType(optional\ - ="Module Annotation", - required=2016) -

                +

                Module moduleB

                +
                +
                @AnnotationType(optional="Module Annotation", + required=2016) + module moduleB
                • @@ -742,8 +725,8 @@ void checkModuleSummary() {

                  Modules

                  """, """ - -
                   
                  """, + +
                   
                  """, """
                  @@ -885,16 +868,16 @@ void checkModulesInSearch(boolean found) { void checkModuleModeCommon() { checkOutput("index.html", true, """ - -
                  + +
                  This is a test description for the moduleA module with a Search phrase search phrase.
                  """, """ - -
                  + +
                  This is a test description for the moduleB module.
                  """, """ - -
                  + +
                  This is a test description for the moduletags module.
                  Type Link: TestClassInModuleTags.
                  Member Link: testMethod(String).
                  @@ -912,8 +895,8 @@ void checkModuleModeCommon() { """); checkOutput("moduletags/module-summary.html", true, """ - -
                   
                  """, + +
                   
                  """, """
                • Description | 
                • Modules | 
                • @@ -957,8 +940,8 @@ void checkModuleModeCommon() { void checkModuleModeApi(boolean found) { checkOutput("moduleA/module-summary.html", found, """ - -
                   
                  """); + +
                   
                  """); checkOutput("moduleB/module-summary.html", found, """
                • Description | 
                • @@ -1007,9 +990,9 @@ void checkModuleModeAll(boolean found) { """, """ - -
                  All Modules
                  -
                   
                  """, + +
                  All Modules
                  +
                   
                  """, """
                  \ \
                  """, """ - -
                  None
                  -
                   
                  """); + +
                  None
                  +
                   
                  """); checkOutput("moduleB/module-summary.html", found, """
                • Description | 
                • @@ -1109,7 +1092,7 @@ void checkModuleDeprecation(boolean found) {
                • Modules
                """, """ - +
                This module is deprecated.
                """); checkOutput("moduleB/module-summary.html", !found, @@ -1119,8 +1102,12 @@ void checkModuleDeprecation(boolean found) { """); checkOutput("moduletags/module-summary.html", found, """ -

                @Deprecated -

                """, +
                +

                Module moduletags

                +
                +
                +
                @Deprecated + module moduletags
                """, """
                Deprecated.
                """); } @@ -1128,11 +1115,16 @@ void checkModuleDeprecation(boolean found) { void checkModuleAnnotation() { checkOutput("moduleB/module-summary.html", true, """ -

                @\ - AnnotationType(optional\ - ="Module Annotation", +

                +

                Module moduleB

                +
                +
                +
                @AnnotationType(option\ + al="Module Annotation", required=2016) -

                """); +
                module moduleB
                """); checkOutput("moduleB/module-summary.html", false, "@AnnotationTypeUndocumented"); } @@ -1339,9 +1331,9 @@ void checkLinkSource(boolean includePrivate) {
                Package
                Description
                -
                \ + -
                 
                +
                 
                """); @@ -1349,8 +1341,10 @@ void checkLinkSource(boolean includePrivate) { """

                -
                public class TestClassInModuleA
                -                    extends java.lang.Object
                +
                public class TestClassInModuleA + extends java.lang.Object
                """); checkOutput("src-html/moduleA/testpkgmdlA/TestClassInModuleA.html", true, """ @@ -1390,7 +1384,7 @@ void checkAllPkgsAllClasses(boolean found) { \ + notation Interfaces Summary\
                """, """ diff --git a/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java b/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java index e01d88d8276..b8fe273d7d6 100644 --- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java +++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java @@ -24,7 +24,7 @@ /* * @test * @bug 4131628 4664607 7025314 8023700 7198273 8025633 8026567 8081854 8150188 8151743 8196027 8182765 - * 8196200 8196202 8223378 + * 8196200 8196202 8223378 8258659 * @summary Make sure the Next/Prev Class links iterate through all types. * Make sure the navagation is 2 columns, not 3. * @library /tools/lib ../../lib @@ -89,9 +89,7 @@ public void test(Path ignore) { checkOutput("pkg/A.html", true, """ - - - +
                @@ -100,9 +98,7 @@ public void test(Path ignore) { checkOutput("pkg/package-summary.html", true, """ - - - +
                @@ -122,9 +118,7 @@ public void test1(Path ignore) { checkOutput("pkg/A.html", true, """ - - - +
                @@ -133,9 +127,7 @@ public void test1(Path ignore) { checkOutput("pkg/package-summary.html", true, """ - - - + """); } @@ -153,9 +145,7 @@ public void test2(Path ignore) { """
                - +
                """); @@ -164,9 +154,7 @@ public void test2(Path ignore) { """
                - +
                """); } diff --git a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java index 49b80f44dd5..cef801499f1 100644 --- a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java +++ b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,29 +65,31 @@ public void test() { void checkEnums() { checkOutput("pkg/Coin.html", true, // Make sure enum header is correct. - "Enum Coin", + "Enum Class Coin", // Make sure enum signature is correct. - """ -
                public enum Coin
                -                    extends java.lang.Enum<Coin>
                """, + """ +
                public enum Coin + extends java.lang.Enum<Coin>
                """, // Check for enum constant section "
                Enum Constants
                ", // Detail for enum constant """ Dime""", // Automatically insert documentation for values() and valueOf(). - "Returns an array containing the constants of this enum type,", - "Returns the enum constant of this type with the specified name", + "Returns an array containing the constants of this enum class,", + "Returns the enum constant of this class with the specified name", "Overloaded valueOf() method has correct documentation.", "Overloaded values method has correct documentation.", """
                public static \ - Coin valueOf(\ - java.lang.String name)
                -
                Returns the enum constant of this type with the specified name. + Coin valueOf(java.la\ + ng.String name)
                +
                Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an - enum constant in this type. (Extraneous whitespace characters are\s + enum constant in this class. (Extraneous whitespace characters are\s not permitted.)
                Parameters:
                @@ -95,7 +97,7 @@ enum constant in this type. (Extraneous whitespace characters are\s
                Returns:
                the enum constant with the specified name
                Throws:
                -
                java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
                +
                java.lang.IllegalArgumentException - if this enum class has no constant with the specified name
                java.lang.NullPointerException - if the argument is null
                """); // NO constructor section @@ -134,33 +136,32 @@ void checkTypeParameters() {
                public <T extends java.util.List,​ V> - java.lang.String[] methodThatHasTypeParameters(T par\ - am1, + java.lang.String[] meth\ + odThatHasTypeParameters(T param1, V param2)
                """, // Method that returns TypeParameters """ -
                E[]
                -
                methodThatReturnsTypeParameterA&#\ 8203;(E[] e)""", """
                public E[] methodThatReturnsTypePar\ - ameterA(E[] methodThatReturnsTypeParameterA\ + (E[] e)
                """, """ -
                <T extends java.lang.Object & java.lang.C\ +
                <T extends java.lang.Object & java.lang.C\ omparable<? super T>>
                T
                -
                methodtThatReturnsTypeParamet\ ersB​(java.util.Collection<? extends T> coll)""", """ @@ -168,12 +169,11 @@ void checkTypeParameters() { """, // Method takes a TypeVariable """ -
                <X extends java.lang.Throwable>
                E
                - +
                orElseThrow​(java.util.func\ tion.Supplier<? extends X> exceptionSupplier)""" ); @@ -197,8 +197,11 @@ void checkTypeParameters() { // Signature of subclass that has type parameters. checkOutput("pkg/TypeParameterSubClass.html", true, """ -
                public class TypeParameterSubClass<T extends java.lang.String>
                -                    extends TypeParameterSuperClass<T>
                """); +
                public class TypeParameterSubClass<T extends java.lang.\ + String> + extends TypeParameterSuperClass<T>
                """); // Interface generic parameter substitution // Signature of subclass that has type parameters. @@ -232,8 +235,8 @@ void checkTypeParameters() {
                public <T extends java.lang.Number & java.lang.Runnable&g\ t; - T fooR\ - 03;(T t)
                """); + T foo(T t)
                """); //============================================================== // Test Class-Use Documentation for Type Parameters. @@ -523,11 +526,13 @@ void checkAnnotationTypeUsage() { checkOutput("pkg/AnnotationTypeUsage.html", true, // CLASS """ -
                @AnnotationType\
                -                    (optional="Class Annotation",
                +                    
                @AnnotationType(optional="Class Annotation", required=1994) - public class AnnotationTypeUsage - extends java.lang.Object
                """, + public class AnnotationTypeUsage + extends java.lang.Object
                """, // FIELD """
                AnnotationTypeUsage #optional()">optional="Field Annotation", required=1994) public int<\ - /span> field
                """, + /span> field
                """, // CONSTRUCTOR """
                @AnnotationType(optional="Constructor Annotation", required=1994) - public AnnotationTypeUsage()
                """, + public AnnotationTypeUsage()
                """, // METHOD """
                AnnotationTypeUsage #optional()">optional="Method Annotation", required=1994) public void\ -  method()
                """, +  method()
                """, // METHOD PARAMS """
                public void methodWithParams(@AnnotationType(optio\ - nal="Parameter Annotation",required\ - =1994) + lass="return-type">void methodWithParams&#\ + 8203;(@AnnotationType(optional\ + ="Parameter Annotation",required=19\ + 94) int documented, int undocmented)
                """, // CONSTRUCTOR PARAMS """
                public AnnotationTypeUsage(@AnnotationType(optional="Constructor Param Annotation",<\ - a href="AnnotationType.html#required()">required=1994) + lass="element-name">AnnotationTypeUsage(<\ + a href="AnnotationType.html" title="annotation in pkg">@AnnotationType(optional="Constructor Param Annotation",\ + required=1994) int documented, int undocmented)
                """); @@ -682,12 +687,11 @@ public class AnnotationTypeUsage
                ex // XXX: Add array test case after this if fixed: //5020899: Incorrect internal representation of class-valued annotation elements - // Make sure that annotations are surrounded by
                 and 
                checkOutput("pkg1/B.html", true, """ -
                @A""",
                +                    
                @A""", """ - public interface B
                """); + public interface B
                """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java index 37c64d059b3..417373a2c15 100644 --- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java +++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java @@ -192,21 +192,23 @@ public void testLinkSource() { checkLinks(); checkOutput("linksource/AnnotationTypeField.html", true, """ -
                @Documented
                -                    public @interface AnnotationTypeField
                """, +
                @Documented + public @interface AnnotationTypeField\ +
                """, """

                DEFAULT_NAME

                static final <\ - span class="return-type">java.lang.String \ - DEFAULT_NAME
                """, + span class="return-type">java.lang.String DEFAULT_NAME""", """

                name

                java.lang.String&\ - nbsp;name
                """); + nbsp;name"""); checkOutput("src-html/linksource/AnnotationTypeField.html", true, "Source code", @@ -215,11 +217,12 @@ public void testLinkSource() { checkOutput("linksource/Properties.html", true, """ -
                public class Properties""",
                +                    
                public class Properties""", """
                public java.lang.Object someProperty
                """); + lass="return-type">java.lang.Object
                 someProperty
                """); checkOutput("src-html/linksource/Properties.html", true, "Source code", @@ -228,20 +231,22 @@ public void testLinkSource() { checkOutput("linksource/SomeClass.html", true, """ -
                public class SomeClass
                -                    extends java.lang.Object
                """, +
                public class SomeC\ + lass + extends java.lang.Object
                """, """
                public int field
                """, + lass="return-type">int field""", """
                public SomeC\ - lass()
                """, + lass="element-name">Some\ + Class()""", """
                public int method()
                """); + lass="return-type">int method()"""); checkOutput("src-html/linksource/SomeClass.html", true, "Source code", @@ -257,14 +262,14 @@ public void testLinkSource() { checkOutput("linksource/SomeEnum.html", true, """
                public static final\ -  SomeEnum VALUE1
                """, +  SomeEnum VALUE1""", """
                public static final\ -  SomeEnum VALUE2
                """); +  SomeEnum VALUE2"""); checkOutput("src-html/linksource/SomeEnum.html", true, """ diff --git a/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java b/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java index 6a11932f92e..e77dac4fa30 100644 --- a/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java +++ b/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java @@ -249,9 +249,9 @@ class IndexOrderingTest { String expectedEnumOrdering[] = { """ - Add.add.html" title="enum in REPLACE_ME\"""", + Add.add.html" title="enum class in REPLACE_ME\"""", """ - Add.ADD.html" title="enum in REPLACE_ME\"""" + Add.ADD.html" title="enum class in REPLACE_ME\"""" }; String expectedFieldOrdering[] = { @@ -397,78 +397,78 @@ void run() throws IOException { checkOrder("index-all.html", composeTestVectors()); checkOrder("add0/add/package-tree.html", """ - """, + """, """ - """); + """); checkOrder("overview-tree.html", """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """, + """, """ - """); + """); } void emitFile(String pkgname, String clsname, ListOrder order) throws IOException { @@ -558,9 +558,9 @@ void run() { checkOrder("index-all.html", "something - package something", "something - Class in", - "something - Enum in", + "something - Enum Class in", "something - Interface in", - "something - Annotation Type in", + "something - Annotation Interface in", "something - Variable in class", "something() - Constructor", """ @@ -588,20 +588,16 @@ void run() { "

                Field Details

                ", """
                static final <\ - span class="return-type">int one""", + span class="return-type">int one
                """, """
                static final <\ - span class="return-type">int two""", + span class="return-type">int two
                """, """
                static final <\ - span class="return-type">int three<\ - /div>""", + span class="return-type">int three
                """, """
                static final <\ - span class="return-type">int four"""); + span class="return-type">int four
                """); checkOrder("pkg5/AnnoOptionalTest.html", "

                Optional Element Summary

                ", diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java index 66b5622b977..896f15a73d4 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java @@ -56,8 +56,7 @@ public void test() {

                toString

                public void toString()<\ - /div> + lass="return-type">void toString()
                Why can't I do this ?
                """); } diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenDeprecatedMethods.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenDeprecatedMethods.java index 79701086d1e..31cbfb14fb1 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenDeprecatedMethods.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverriddenDeprecatedMethods.java @@ -62,13 +62,13 @@ public void test() { """ @Deprecated public void\ -  func1()""", +  func1()""", """
                Deprecated.
                """, """ @Deprecated public void\ -  func2()""", +  func2()""", """
                Deprecated.
                """, """ diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverrideMethods.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverrideMethods.java index c157f386ee6..91319de51b2 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverrideMethods.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverrideMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8157000 8192850 8182765 + * @bug 8157000 8192850 8182765 8223607 * @summary test the behavior of --override-methods option * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -304,35 +304,267 @@ public void testSummary() { m7()""", """ m7()""", - "Returns the enum constant of this type with the specified name.", + "Returns the enum constant of this class with the specified name.", """ - Returns an array containing the constants of this enum type, in + Returns an array containing the constants of this enum class, in the order they are declared.""" ); - // Check methods with covariant return types - // Only m2 should be shown in summary; m1 and m3 should listed as declared in Base + // Check methods with covariant return types, changes in modifiers or thrown exceptions. + // Only those should be shown in summary; m1, m3, m9 should listed as declared in Base checkOutput("pkg6/Sub.html", true, """
                Modifier and Type
                Method
                Description
                -
                java.lang.String
                -
                \ +
                java.lang.String
                +
                -
                +
                This is Base::m2.
                +
                void
                +
                m4()
                +
                +
                This is Base::m4.
                +
                +
                java.lang.Object
                +
                m5()
                +
                +
                This is Base::m5.
                +
                +
                java.lang.Object
                +
                m6()
                +
                +
                This is Base::m6.
                +
                +
                java.lang.Object
                +
                m7()
                +
                +
                This is Base::m7.
                +
                +
                abstract java.lang.Object
                +
                m8()
                +
                +
                This is Base::m8.
                """, """

                Methods declared in class p\ kg6.Base

                - m1, m3
                + m1, m3, m9
                """); } + + @Test + public void testSummaryAnnotations() { + javadoc("-d", "out-summary-annotations", + "-sourcepath", testSrc, + "--no-platform-links", + "-javafx", + "--disable-javafx-strict-checks", + "--override-methods=summary", + "-private", + "pkg7"); + + checkExit(Exit.OK); + + checkOutput("pkg7/AnnotatedSub1.html", true, + """ +
                +

                Methods declared in int\ + erface pkg7.Annotate\ + dBase

                + m1
                """); + + checkOutput("pkg7/AnnotatedSub2.html", true, + """ + + +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub3.html", true, + """ + + +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub4.html", true, + """ +
                java.lang.Iterable<@A java.lang.String>&nbs\ + p;m1(java.lang\ + .Class<? extends java.lang.CharSequence> p1, + int[] p2)
                +
                Description copied from inte\ + rface: Ann\ + otatedBase
                +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub5.html", true, + """ +
                java.lang.Iterable<ja\ + va.lang.String> m1(@A + @A java.lang.Class<? extends\ + java.lang.CharSequence> p1, + int[] p2)
                +
                Description copied from inte\ + rface: Ann\ + otatedBase
                +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub6.html", true, + """ +
                java.lang.Iterable<ja\ + va.lang.String> m1(java.lang.Class<@A ? extends java.lang.CharSequence> p1, + int[] p2)
                +
                Description copied from inte\ + rface: Ann\ + otatedBase
                +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub7.html", true, + """ +
                java.lang.Iterable<ja\ + va.lang.String> m1(java.lang.Class<? extends @A java.lang.CharSequence> p1, + int[] p2)
                +
                Description copied from inte\ + rface: Ann\ + otatedBase
                +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + + checkOutput("pkg7/AnnotatedSub8.html", true, + """ +
                java.lang.Iterable<ja\ + va.lang.String> m1(java.lang.Class<? extends java.lang.CharSequence> p1, + int @A [] p2)
                +
                Description copied from inte\ + rface: Ann\ + otatedBase
                +
                This is AnnotatedBase::m1.
                +
                +
                Specified by:
                +
                m1 in interface AnnotatedBase
                +
                Parameters:
                +
                p1 - first parameter
                +
                p2 - second parameter
                +
                Returns:
                +
                something
                +
                """); + } } diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Base.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Base.java index f11a9ce6bb7..3a7f9650337 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Base.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Base.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,21 +23,55 @@ package pkg6; +import java.io.IOException; + public class Base { /** * This is Base::m1. * @return something - * */ + */ public Object m1() { } + /** * This is Base::m2. * @return something - * */ + */ public Object m2() { } /** * This is Base::m3. * @return something - * */ + */ public T m3() { } + + /** + * This is Base::m4. + */ + protected void m4() { } + + /** + * This is Base::m5. + * @throws IOException an error + */ + public Object m5() throws IOException { } + + /** + * This is Base::m6. + */ + public Object m6() { } + + /** + * This is Base::m7. + */ + public abstract Object m7(); + + /** + * This is Base::m8. + */ + public Object m8() { } + + /** + * This is Base::m9. + */ + public abstract Object m9(); } diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Sub.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Sub.java index 2752ff9221e..694852f6d5e 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Sub.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg6/Sub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,5 +33,23 @@ public String m2() { } // not a covariant override @Override public T m3() { } + // change visibility to public + @Override + public void m4() { } + // drop checked exception + @Override + public Object m5() { } + // add final modifier + @Override + public final Object m6() { } + // implement abstract method + @Override + public Object m7() { } + // override concrete method as abstract + @Override + public abstract Object m8(); + // override abstract method unchanged + @Override + public abstract Object m9(); } diff --git a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg7/Annotated.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg7/Annotated.java new file mode 100644 index 00000000000..b10da9d4399 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg7/Annotated.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg7; + +import java.lang.annotation.Documented; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +// Adding documented annotations anywhere in the signature of an overriding +// method should cause it to be included in the details section even with +// --override-methods=summary option. + +interface AnnotatedBase { + /** + * This is AnnotatedBase::m1. + * @param p1 first parameter + * @param p2 second parameter + * @return something + */ + public Iterable m1(Class p1, int[] p2); +} + +interface AnnotatedSub1 extends AnnotatedBase { + @Override + public Iterable m1(Class p1, int[] p2); +} + +interface AnnotatedSub2 extends AnnotatedBase { + @Override + @A + public Iterable m1(Class p1, int[] p2); +} + +interface AnnotatedSub3 extends AnnotatedBase { + @Override + public @A Iterable m1(Class p1, int[] p2); +} + +interface AnnotatedSub4 extends AnnotatedBase { + @Override + public Iterable<@A String> m1(Class p1, int[] p2); +} + +interface AnnotatedSub5 extends AnnotatedBase { + @Override + public Iterable m1(@A Class p1, int[] p2); +} + +interface AnnotatedSub6 extends AnnotatedBase { + @Override + public Iterable m1(Class<@A ? extends CharSequence> p1, int[] p2); +} + +interface AnnotatedSub7 extends AnnotatedBase { + @Override + public Iterable m1(Class p1, int[] p2); +} + +interface AnnotatedSub8 extends AnnotatedBase { + @Override + public Iterable m1(Class p1, int @A [] p2); +} + +@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) +@Documented +@interface A {} diff --git a/test/langtools/jdk/javadoc/doclet/testPackageAnnotation/TestPackageAnnotation.java b/test/langtools/jdk/javadoc/doclet/testPackageAnnotation/TestPackageAnnotation.java index 2b7d64b97af..0179b8a600a 100644 --- a/test/langtools/jdk/javadoc/doclet/testPackageAnnotation/TestPackageAnnotation.java +++ b/test/langtools/jdk/javadoc/doclet/testPackageAnnotation/TestPackageAnnotation.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8222091 + * @bug 8222091 8245058 * @summary Javadoc does not handle package annotations correctly on package-info.java * @library ../../lib/ * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -52,10 +52,11 @@ public void testPackageInfoAnnotationNoComment() { """
                -

                @Deprecated(since="1<2>3") -

                Package pkg1

                +
                +
                @Deprecated(since="1<2>3") + package pkg1
                """); } @@ -87,10 +88,11 @@ public void testPackageInfoAndHtml() { """
                -

                @Deprecated(since="1<2>3") -

                Package pkg3

                +
                +
                @Deprecated(since="1<2>3") + package pkg3
                """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/TestPreview.java b/test/langtools/jdk/javadoc/doclet/testPreview/TestPreview.java new file mode 100644 index 00000000000..24af7cfe134 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/TestPreview.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8250768 + * @summary test generated docs for items declared using preview + * @library ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:+open + * @build javadoc.tester.* + * @run main TestPreview + */ + +import java.nio.file.Paths; +import java.text.MessageFormat; +import java.util.ResourceBundle; +import javadoc.tester.JavadocTester; + +public class TestPreview extends JavadocTester { + + public static void main(String... args) throws Exception { + TestPreview tester = new TestPreview(); + tester.runTests(); + } + + @Test + public void testUserJavadoc() { + String doc = Paths.get(testSrc, "doc").toUri().toString(); + javadoc("-d", "out-user-javadoc", + "-XDforcePreview", "--enable-preview", "-source", System.getProperty("java.specification.version"), + "--patch-module", "java.base=" + Paths.get(testSrc, "api").toAbsolutePath().toString(), + "--add-exports", "java.base/preview=m", + "--module-source-path", testSrc, + "-linkoffline", doc, doc, + "m/pkg"); + checkExit(Exit.OK); + + ResourceBundle bundle = ResourceBundle.getBundle("jdk.javadoc.internal.doclets.formats.html.resources.standard", ModuleLayer.boot().findModule("jdk.javadoc").get()); + + { + String zero = MessageFormat.format(bundle.getString("doclet.PreviewLeadingNote"), "TestPreviewDeclaration"); + String one = MessageFormat.format(bundle.getString("doclet.Declared_Using_Preview"), "TestPreviewDeclaration", "Sealed Classes", "sealed"); + String two = MessageFormat.format(bundle.getString("doclet.PreviewTrailingNote1"), "TestPreviewDeclaration"); + String three = MessageFormat.format(bundle.getString("doclet.PreviewTrailingNote2"), new Object[0]); + String expectedTemplate = """ +
                {0} +
                  +
                • {1}
                • +
                +
                {2}
                +
                {3}
                +
                """; + String expected = MessageFormat.format(expectedTemplate, zero, one, two, three); + checkOutput("m/pkg/TestPreviewDeclaration.html", true, expected); + } + + checkOutput("m/pkg/TestPreviewDeclarationUse.html", true, + "TestPreviewDeclarationPREVIEW"); + checkOutput("m/pkg/TestPreviewAPIUse.html", true, + "CorePREVIEW"); + checkOutput("m/pkg/DocAnnotation.html", true, + "
                "); + checkOutput("m/pkg/DocAnnotationUse1.html", true, + "
                "); + checkOutput("m/pkg/DocAnnotationUse2.html", true, + "
                "); + } + + @Test + public void testPreviewAPIJavadoc() { + javadoc("-d", "out-preview-api", + "--patch-module", "java.base=" + Paths.get(testSrc, "api").toAbsolutePath().toString(), + "--add-exports", "java.base/preview=m", + "--source-path", Paths.get(testSrc, "api").toAbsolutePath().toString(), + "--show-packages=all", + "preview"); + checkExit(Exit.OK); + + checkOutput("preview-list.html", true, + """ +
                +
                Record Classes
                +
                +
                Record Class
                +
                Description
                + +
                +
                + """, + """ +
                +
                Methods
                +
                +
                Method
                +
                Description
                + +
                +
                Returns the value of the i record component.
                +
                + """); + } +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Core.java b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Core.java new file mode 100644 index 00000000000..d2cf31c2e89 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Core.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package preview; + +import jdk.internal.javac.PreviewFeature; +import jdk.internal.javac.PreviewFeature.Feature; + +@PreviewFeature(feature=Feature.TEST) +public class Core { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecord.java b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecord.java new file mode 100644 index 00000000000..0cfd84d197c --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecord.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package preview; + +import jdk.internal.javac.PreviewFeature; +import jdk.internal.javac.PreviewFeature.Feature; + +@PreviewFeature(feature=Feature.TEST) +public record CoreRecord(int i) { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecordComponent.java b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecordComponent.java new file mode 100644 index 00000000000..bb081c6c651 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/CoreRecordComponent.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package preview; + +import jdk.internal.javac.PreviewFeature; +import jdk.internal.javac.PreviewFeature.Feature; + +public record CoreRecordComponent(@PreviewFeature(feature=Feature.TEST) int i) { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Reflective.java b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Reflective.java new file mode 100644 index 00000000000..d4e39595871 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/api/preview/Reflective.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package preview; + +import jdk.internal.javac.PreviewFeature; +import jdk.internal.javac.PreviewFeature.Feature; + +@PreviewFeature(feature=Feature.TEST, reflective=true) +public class Reflective { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/doc/element-list b/test/langtools/jdk/javadoc/doclet/testPreview/doc/element-list new file mode 100644 index 00000000000..c59f8fc41e3 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/doc/element-list @@ -0,0 +1,2 @@ +module:java.base +preview diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/doc/java.base/preview/Core.html b/test/langtools/jdk/javadoc/doclet/testPreview/doc/java.base/preview/Core.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/doc/java.base/preview/Reflective.html b/test/langtools/jdk/javadoc/doclet/testPreview/doc/java.base/preview/Reflective.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/module-info.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/module-info.java new file mode 100644 index 00000000000..28d46298083 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/module-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +module m { + exports pkg; +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotation.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotation.java new file mode 100644 index 00000000000..d6b5b3d9f83 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotation.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +import java.lang.annotation.Documented; + +@Documented +public @interface DocAnnotation { + + public Class a1() default Object.class; + public Class[] a2() default {}; + public Class a3() default TestPreviewDeclaration.class; + +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse1.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse1.java new file mode 100644 index 00000000000..be143546810 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse1.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +@DocAnnotation(a1=TestPreviewDeclaration.class) +public class DocAnnotationUse1 { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse2.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse2.java new file mode 100644 index 00000000000..0f95e684e46 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/DocAnnotationUse2.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +@DocAnnotation(a2={TestPreviewDeclaration.class}) +public class DocAnnotationUse2 { +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewAPIUse.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewAPIUse.java new file mode 100644 index 00000000000..1eb59b84628 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewAPIUse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +import preview.*; + +public class TestPreviewAPIUse { + + public Core fieldCore; + public Reflective fieldReflective; + +} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclaration.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclaration.java new file mode 100644 index 00000000000..81ae744423f --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclaration.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public sealed interface TestPreviewDeclaration permits Impl { +} +class Impl implements TestPreviewDeclaration {} diff --git a/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclarationUse.java b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclarationUse.java new file mode 100644 index 00000000000..74cbe30959f --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testPreview/m/pkg/TestPreviewDeclarationUse.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class TestPreviewDeclarationUse { + + public TestPreviewDeclaration field; + +} diff --git a/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java b/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java index 4959b0bc490..4ba978067b9 100644 --- a/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java +++ b/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java @@ -73,8 +73,8 @@ public void testDefault() { // Method is documented as though it is declared in the inheriting method. """
                public void methodInheritedFro\ - mParent(int p1) + lass="return-type">void methodInheritedFromParent\ + (int p1) throws java.lang.Exception
                """, """
                @@ -191,7 +191,8 @@ public void testPrivate() { blicInterface
                """, """ -
                public class PublicChild""");
                +                    
                public class PublicChild"""); checkOutput("pkg/PublicInterface.html", true, // Field inheritence from non-public superinterface. @@ -235,10 +236,12 @@ public void testPrivate() { //Make sure when no modifier appear in the class signature, the //signature is displayed correctly without extra space at the beginning. """ -
                class PrivateParent""");
                +                    
                class PrivateParent"""); checkOutput("pkg/PrivateParent.html", false, """ -
                 class PrivateParent""");
                +                    
                class PrivateParent"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testProperty/TestProperty.java b/test/langtools/jdk/javadoc/doclet/testProperty/TestProperty.java index 987d854b20e..073a0eb06ea 100644 --- a/test/langtools/jdk/javadoc/doclet/testProperty/TestProperty.java +++ b/test/langtools/jdk/javadoc/doclet/testProperty/TestProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ public void testArrays() {
                public final <\ span class="return-type">Obje\ ctProperty<MyObj>\ -  goodProperty
                +  goodProperty
                This is an Object property where the Object is a single Object.
                See Also:
                @@ -67,7 +67,7 @@ public void testArrays() {
                public final <\ span class="return-type">Obje\ ctProperty<MyObj[]> badProperty
                + n> badProperty
                This is an Object property where the Object is an array.
                See Also:
                @@ -86,12 +86,12 @@ public void testArrays() { // tab classes should be used in the method table """ - - """ ); @@ -100,8 +100,8 @@ public void testArrays() {
                public final <\ span class="return-type">Obje\ ctProperty<java.util.List<T>> listProperty<\ - /span>
                + r in MyClassT">T>> listProperty<\ + /div>
                This is an Object property where the Object is a single List<T>.
                See Also:
                diff --git a/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java b/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java index d35298134b9..8cd2cb6ca2c 100644 --- a/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java +++ b/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java @@ -87,7 +87,7 @@ public void bar() { } checkOutput("example/JavadocTest.Bar.html", true, """ -

                Record JavadocTest.Bar

                +

                Record Class JavadocTest.Bar

                """, """
                bar() diff --git a/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java b/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java index 2390eb8b383..0ecd564b1f0 100644 --- a/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8225055 8239804 8246774 + * @bug 8225055 8239804 8246774 8258338 * @summary Record types * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -73,9 +73,9 @@ public void testRecordKeywordUnnamedPackage(Path base) throws IOException { checkOutput("R.html", true, """ -

                Record R

                """, +

                Record Class R

                """, """ - public record R""", + public record R""", """ R​(int r1)"""); } @@ -94,9 +94,9 @@ public void testRecordKeywordNamedPackage(Path base) throws IOException { checkOutput("p/R.html", true, """ -

                Record R

                """, +

                Record Class R

                """, """ - public record R""", + public record R""", """ R​(int r1)"""); } @@ -115,9 +115,9 @@ public void testEmptyRecord(Path base) throws IOException { checkOutput("p/R.html", true, """ -

                Record R

                """, +

                Record Class R

                """, """ - public record R""", + public record R""", """ R()"""); } @@ -140,9 +140,9 @@ public record R(int r1) { }"""); checkOutput("p/R.html", true, """ -

                Record R

                """, +

                Record Class R

                """, """ - public record R""", + public record R""", """
                Record Components:
                @@ -171,9 +171,9 @@ public record R(int r1) { }"""); checkOutput("p/R.html", true, """ -

                Record R<T>

                """, +

                Record Class R<T>

                """, """ - public record R<T>""", + public record R<T>""", """
                Type Parameters:
                @@ -208,7 +208,7 @@ public record R(int r1) { }"""); """
                """, "R", - "Creates an instance of a R record.", + "Creates an instance of a R record class.", """
                """, """ @@ -223,25 +223,25 @@ public record R(int r1) { }"""); Returns the value of the r1 record component.""", """ toString""", - "Returns a string representation of this record.", + "Returns a string representation of this record class.", "Method Details", """ - toString""", - "Returns a string representation of this record. The representation " - + "contains the name of the type, followed by the name and value of " + toString""", + "Returns a string representation of this record class. The representation " + + "contains the name of the class, followed by the name and value of " + "each of the record components.", """ - hashCode""", + hashCode""", "Returns a hash code value for this object. The value is derived " + "from the hash code of each of the record components.", """ - equals""", + equals""", """ Indicates whether some other object is "equal to" this one. The objects are equa\ l if the other object is of the same class and if all the record components are \ - equal. All components in this record are compared with '=='.""", + equal. All components in this record class are compared with '=='.""", """ - r1""", + r1""", """ Returns the value of the r1 record component.""" ); @@ -271,7 +271,7 @@ public record R(int r1) { }"""); """
                """, "R", - "Creates an instance of a R record.", + "Creates an instance of a R record class.", """
                """, """ @@ -286,25 +286,25 @@ public record R(int r1) { }"""); Returns the value of the r1 record component.""", """ toString""", - "Returns a string representation of this record.", + "Returns a string representation of this record class.", "Method Details", """ - toString""", - "Returns a string representation of this record. The representation " - + "contains the name of the type, followed by the name and value of " + toString""", + "Returns a string representation of this record class. The representation " + + "contains the name of the class, followed by the name and value of " + "each of the record components.", """ - hashCode""", + hashCode""", "Returns a hash code value for this object. The value is derived " + "from the hash code of each of the record components.", """ - equals""", + equals""", """ Indicates whether some other object is "equal to" this one. The objects are equa\ l if the other object is of the same class and if all the record components are \ - equal. All components in this record are compared with '=='.""", + equal. All components in this record class are compared with '=='.""", """ - r1""", + r1""", """ Returns the value of the r1 record component.""" ); @@ -313,13 +313,13 @@ l if the other object is of the same class and if all the record components are @Test public void testGeneratedEqualsPrimitive(Path base) throws IOException { testGeneratedEquals(base, "int a, int b", - "All components in this record are compared with '=='."); + "All components in this record class are compared with '=='."); } @Test public void testGeneratedEqualsReference(Path base) throws IOException { testGeneratedEquals(base, "Object a, Object b", - "All components in this record are compared with Objects::equals(Object,Object)"); + "All components in this record class are compared with Objects::equals(Object,Object)"); } @Test @@ -471,26 +471,93 @@ void testAnnotations(Path base, Set types) throws IOException { checkOutput("p/R.html", true, """ -
                public record R("""
                +                    
                public record R(""" + rcAnno + """ int i) - extends java.lang.Record
                """, + extends java.lang.Record
                """, "
                " + fAnno + """ private final int<\ - /span> i
                """, + /span> i
                """, """
                public R(""" + lass="element-name">R(""" + pAnno + "int i)
                ", "
                " + mAnno + """ public int&\ - nbsp;i()
                """); + nbsp;i()
                """); } + + @Test + public void testDeprecatedRecord(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; /** This is record R. + * @deprecated Do not use. + */ + @Deprecated + public record R(int r1) { }"""); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", "-noindex", + "-sourcepath", src.toString(), + "p"); + checkExit(Exit.OK); + + checkOutput("deprecated-list.html", true, + """ +

                Contents

                + """, + """ +
                +
                Record Classes
                +
                +
                Record Class
                +
                Description
                + +
                +
                Do not use.
                +
                """); + } + + @Test + public void testDeprecatedRecordComponent(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; /** This is record R. */ + public record R(@Deprecated int r1) { }"""); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", "-noindex", + "-sourcepath", src.toString(), + "p"); + checkExit(Exit.OK); + + checkOutput("deprecated-list.html", true, + """ +

                Contents

                + """, + """ +
                +
                Methods
                +
                +
                Method
                +
                Description
                + +
                +
                """); + } } diff --git a/test/langtools/jdk/javadoc/doclet/testReturnTag/TestReturnTag.java b/test/langtools/jdk/javadoc/doclet/testReturnTag/TestReturnTag.java index 6b33ab2c15f..ba6bf527149 100644 --- a/test/langtools/jdk/javadoc/doclet/testReturnTag/TestReturnTag.java +++ b/test/langtools/jdk/javadoc/doclet/testReturnTag/TestReturnTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,39 +23,409 @@ /* * @test - * @bug 4490068 - * @summary Warn when a return tag is used on a method without a return type. - * @library ../../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build javadoc.tester.* + * @bug 4490068 8075778 + * @summary General tests for inline or block at-return tag + * @library /tools/lib ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build toolbox.ToolBox javadoc.tester.* * @run main TestReturnTag */ +import java.io.IOException; +import java.nio.file.Path; + import javadoc.tester.JavadocTester; +import toolbox.ToolBox; public class TestReturnTag extends JavadocTester { - /** - * Trigger warning message when return tag is used on a void method. - * - * @return I really don't return anything. - */ - public void method() {} - public static void main(String... args) throws Exception { TestReturnTag tester = new TestReturnTag(); - tester.runTests(); + tester.runTests(m -> new Object[] { Path.of(m.getName()) }); } - @Test - public void tests() { + ToolBox tb = new ToolBox(); + + @Test // 4490068 + public void testInvalidReturn(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * Trigger warning message when return tag is used on a void method. + * + * @return I really don't return anything. + */ + public void method() {} + } + """); + javadoc("-Xdoclint:none", - "-d", "out", - "-sourcepath", testSrc, - testSrc("TestReturnTag.java")); + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); checkExit(Exit.OK); checkOutput(Output.OUT, true, "warning - @return tag cannot be used in method with void return type."); } + + @Test + public void testBlock(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * First sentence. Second sentence. + * @return the result + */ + public int m() { return 0; } + } + """); + + javadoc("-Xdoclint:none", + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                First sentence. Second sentence.
                +
                +
                Returns:
                +
                the result
                +
                + """); + } + + @Test + public void testInlineShort(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * {@return the result} + */ + public int m() { return 0; } + } + """); + + javadoc("-Xdoclint:none", + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                Returns the result.
                +
                +
                Returns:
                +
                the result
                +
                + """); + } + + @Test + public void testInlineLong(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * {@return the result} More text. + */ + public int m() { return 0; } + } + """); + + javadoc("-Xdoclint:none", + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                Returns the result. More text.
                +
                +
                Returns:
                +
                the result
                +
                + """); + } + + @Test + public void testInlineMarkup(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * {@return abc {@code def} ghi jkl} + */ + public int m() { return 0; } + } + """); + + javadoc("-Xdoclint:none", + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                Returns abc def ghi jkl.
                +
                +
                Returns:
                +
                abc def ghi jkl
                +
                + """); + } + + @Test + public void testBlockMarkup(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * @return abc {@code def} ghi jkl + */ + public int m() { return 0; } + } + """); + + javadoc("-Xdoclint:none", + "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                +
                Returns:
                +
                abc def ghi jkl
                +
                + """); + } + + @Test + public void testEmptyInline(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * {@return} + */ + public int m() { return 0; } + } + """); + + javadoc("-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput(Output.OUT, true, + "C.java:4: warning: no description for @return"); + + checkOutput("C.html", true, + """ +
                Returns .
                +
                +
                Returns:
                +
                + """); + } + + @Test + public void testInlineNotFirst(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * Some text. {@return the result} More text. + */ + public int m() { return 0; } + } + """); + + javadoc("-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput(Output.OUT, true, + "C.java:4: warning: {@return} not at beginning of description"); + + checkOutput("C.html", true, + """ +
                Some text. Returns the result. More text.
                +
                + """); + } + + @Test + public void testDuplicate(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class C { + /** + * {@return the result} More text. + * @return again + */ + public int m() { return 0; } + } + """); + + javadoc( "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput(Output.OUT, true, + "C.java:5: warning: @return has already been specified"); + + checkOutput("C.html", true, + """ +
                Returns the result. More text.
                +
                +
                Returns:
                +
                again
                + """); + } + + @Test + public void testSimpleInheritBlock(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class Super { + /** + * @return the result + */ + public int m() { return 0; } + } + """, + """ + /** Comment. */ + public class C extends Super { + @Override + public int m() { return 1; } + } + """); + + javadoc( "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                +
                Overrides:
                +
                m in class Super
                +
                Returns:
                +
                the result
                +
                + """); + } + + @Test + public void testSimpleInheritInline(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class Super { + /** + * {@return the result} + */ + public int m() { return 0; } + } + """, + """ + /** Comment. */ + public class C extends Super { + @Override + public int m() { return 1; } + } + """); + + javadoc( "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                Description copied from class: Super
                +
                Returns the result.
                +
                +
                Overrides:
                +
                m in class Super
                +
                Returns:
                +
                the result
                """); + } + + @Test + public void testPreferInlineOverInherit(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Comment. */ + public class Super { + /** + * {@return the result} + */ + public int m() { return 0; } + } + """, + """ + /** Comment. */ + public class C extends Super { + /** + * {@return the overriding result} + */ + @Override + public int m() { return 1; } + } + """); + + javadoc( "-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + src.resolve("C.java").toString()); + checkExit(Exit.OK); + + checkOutput("C.html", true, + """ +
                Returns the overriding result.
                +
                +
                Overrides:
                +
                m in class Super
                +
                Returns:
                +
                the overriding result
                +
                + """); + } } diff --git a/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java b/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java index 5e0b5c4e114..7c13190fe71 100644 --- a/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testSealedTypes/TestSealedTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,10 @@ public void testSealedModifierClass(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed class A"); + """ +
                public sealedPREVIEW class A"""); } @Test @@ -75,7 +78,10 @@ public void testSealedModifierInterface(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed interface A"); + """ +
                public sealedPREVIEW interface A"""); } @Test @@ -92,10 +98,16 @@ public void testNonSealedModifierClass(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed class A"); + """ +
                public sealedPREVIEW class A"""); checkOutput("p/B.html", true, - "public non-sealed class B"); + """ +
                public non-sealedPREVIEW class B"""); } @Test @@ -112,10 +124,16 @@ public void testNonSealedModifierInterface(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed interface A"); + """ +
                public sealedPREVIEW interface A"""); checkOutput("p/B.html", true, - "public non-sealed interface B"); + """ +
                public non-sealedPREVIEW interface B"""); } @Test @@ -132,10 +150,16 @@ public void testSealedSubtypeModifierClass(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed class A"); + """ +
                public sealedPREVIEW class A"""); checkOutput("p/B.html", true, - "public abstract sealed class B"); + """ +
                public abstract sealed<\ + a href="#preview-p.B">PREVIEW class B"""); } @Test @@ -152,10 +176,16 @@ public void testSealedSubtypeInterface(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "public sealed interface A"); + """ +
                public sealedPREVIEW interface A"""); checkOutput("p/B.html", true, - "public sealed interface B"); + """ +
                public sealedPREVIEW interface B"""); } @Test @@ -173,9 +203,14 @@ public void testSinglePermits(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW BPREVIEW
                """); } @Test @@ -195,11 +230,16 @@ public void testMultiplePermits(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B, "
                -                + "C, "
                -                + "D
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW BPREVIEW, CPREVIEW, DPREVIEW
                """); } @Test @@ -219,11 +259,16 @@ public void testPartialMultiplePermits(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B, "
                -                + "C "
                -                + "(not exhaustive)
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW BPREVIEW, CPREVIEW (not exhaustive)<\ + /div>"""); } // @Test // javac incorrectly rejects the source @@ -244,10 +289,15 @@ public void testPartialMultiplePermitsWithSubtypes1(Path base) throws IOExceptio checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B, "
                -                + "C, p.D
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW A.BPREVIEW, A.C\ + PREVIEW, A.D
                """); } @Test @@ -269,11 +319,15 @@ public void testPartialMultiplePermitsWithSubtypes2(Path base) throws IOExceptio checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B, "
                -                + "C "
                -                + "(not exhaustive)
                "); + """ +
                public sealedPREVIEW class A\ + + extends java.lang.Object + permitsPREVIEW BPREVIEW,\ + CPREVIEW<\ + /a> (not exhaustive)
                """); } @Test @@ -294,11 +348,16 @@ public void testImplicitPermitsAuxiliary(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits B, "
                -                + "C, "
                -                + "D
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW BPREVIEW, CPREVIEW, DPREVIEW
                """); } @Test @@ -319,10 +378,15 @@ public void testImplicitPermitsNested(Path base) throws IOException { checkExit(Exit.OK); checkOutput("p/A.html", true, - "
                public sealed class A\n"
                -                + "extends java.lang.Object\n"
                -                + "permits A.B, "
                -                + "A.C, "
                -                + "A.D
                "); + """ +
                public sealedPREVIEW class A + extends java.lang.Object + permitsPREVIEW A.BPR\ + EVIEW, A.CPREVIEW, A.D\ + PREVIEW
                """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java index 9bf0cb7aa63..a13276f5270 100644 --- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java +++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java @@ -25,7 +25,7 @@ * @test * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881 * 8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202 - * 8184205 8214468 8222548 8223378 8234746 8241219 8254627 + * 8184205 8214468 8222548 8223378 8234746 8241219 8254627 8247994 * @summary Test the search feature of javadoc. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -452,7 +452,7 @@ void checkSingleIndex(boolean expectedOutput, boolean html5) { """
                search phrase with desc deprecated - Search t\ - ag in annotation type pkg2.TestAnnotationType
                """, + ag in annotation interface pkg2.TestAnnotationType""", """
                SearchTagDeprecatedClass - Search tag in class pkg2.TestClas\ @@ -487,14 +487,14 @@ void checkSingleIndex(boolean expectedOutput, boolean html5) { /a> - Search tag in pkg.AnotherClass.CONSTANT1
                """, """
                ONE - Enum constant in enum pkg2.TestEnum
                """, + n> - Enum constant in enum class pkg2.TestEnum""", """
                THREE<\ - /span> - Enum constant in enum pkg2.TestEnum - Enum constant in enum class pkg2.TestEnum""", """
                TWO - Enum constant in enum pkg2.TestEnum
                """); + n> - Enum constant in enum class pkg2.TestEnum"""); checkOutput("index-all.html", true, """
                class_test1 passes. Search tag search phrase with desc deprecated - Searc\ - h tag in annotation type pkg2.TestAnnotationType""", + h tag in annotation interface pkg2.TestAnnotationType""", """
                SearchTagDeprecatedClass - Search tag in class pkg2.TestC\ @@ -575,16 +575,16 @@ void checkSplitIndex() { checkOutput("index-files/index-9.html", true, """
                ONE - Enum constant in enum pkg2.TestEnum - Enum constant in enum class pkg2.TestEnum"""); checkOutput("index-files/index-14.html", true, """
                THREE - Enum constant in enum pkg2.TestEnum - Enum constant in enum class pkg2.TestEnum
                """, """
                TWO - Enum constant in enum pkg2.TestEnum - Enum constant in enum class pkg2.TestEnum"""); } @@ -611,7 +611,7 @@ void checkIndexNoComment() { """
                search phrase with desc deprecated - Search t\ - ag in annotation type pkg2.TestAnnotationType
                """, + ag in annotation interface pkg2.TestAnnotationType""", """
                SearchTagDeprecatedClass - Search tag in class pkg2.TestClas\ @@ -655,7 +655,7 @@ void checkIndexNoDeprecated() { """
                search phrase with desc deprecated - Search t\ - ag in annotation type pkg2.TestAnnotationType
                """, + ag in annotation interface pkg2.TestAnnotationType""", """
                SearchTagDeprecatedClass - Search tag in class pkg2.TestClas\ @@ -711,11 +711,15 @@ void checkJqueryAndImageFiles(boolean expectedOutput) { } void checkSearchJS() { + // ensure all resource keys were resolved + checkOutput("search.js", false, + "##REPLACE:"); + checkOutput("search.js", true, - "function concatResults(a1, a2) {", + "function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) {", """ - $("#search").on('click keydown paste', function() { - if ($(this).val() == watermark) { + search.on('click keydown paste', function() { + if ($(this).val() === watermark) { $(this).val('').removeClass('watermark'); } });""", @@ -737,7 +741,6 @@ function getURLPrefix(ui) { } }); } - return urlPrefix; } return urlPrefix; }""", @@ -830,7 +833,7 @@ void checkAllPkgsAllClasses() { \ + um Class Summary\ \ + notation Interfaces Summary\
                diff --git a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java index 630efe61e1d..8c5e77c3c15 100644 --- a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java +++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,10 @@ * @bug 8178982 8220497 8210683 8241982 * @summary Test the search feature of javadoc. * @library ../../lib + * @library /test/lib * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build javadoc.tester.* + * @build jtreg.SkippedException * @run main TestSearchScript */ @@ -45,6 +47,8 @@ import java.io.IOException; import java.util.List; +import jtreg.SkippedException; + /* * Tests for the search feature using any available javax.script JavaScript engine. * The test is skipped if no JavaScript engine is available. @@ -61,7 +65,7 @@ private Invocable getEngine() throws ScriptException, IOException, NoSuchMethodE // Use "js" engine name to use any available JavaScript engine. ScriptEngine engine = engineManager.getEngineByName("js"); if (engine == null) { - return null; + throw new SkippedException("JavaScript engine is not available."); } // For GraalJS set Nashorn compatibility mode via Bindings, // see https://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md @@ -85,35 +89,31 @@ public void testModuleSearch() throws ScriptException, IOException, NoSuchMethod Invocable inv = getEngine(); - if (inv == null) { - out.println("No JavaScript engine available. Test skipped."); - return; - } - // exact match, case sensitivity checkSearch(inv, "mapmodule", List.of("mapmodule")); checkSearch(inv, "mappkg", List.of("mapmodule/mappkg", "mapmodule/mappkg.impl", "mappkg.system.property")); - checkSearch(inv, "Mapmodule", List.of()); - checkSearch(inv, "Mappkg", List.of()); + checkSearch(inv, "Mapmodule", List.of("mapmodule")); + checkSearch(inv, "Mappkg", List.of("mapmodule/mappkg", "mapmodule/mappkg.impl", "mappkg.system.property")); checkSearch(inv, "mymap", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "MyMap", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "mymap(", List.of("mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "MyMap(", List.of("mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "mymap()", List.of("mappkg.impl.MyMap.MyMap()")); checkSearch(inv, "MyMap()", List.of("mappkg.impl.MyMap.MyMap()")); - checkSearch(inv, "Mymap", List.of()); - checkSearch(inv, "Mymap()", List.of()); + checkSearch(inv, "Mymap", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); + checkSearch(inv, "Mymap()", List.of("mappkg.impl.MyMap.MyMap()")); // left boundaries, ranking checkSearch(inv, "map", List.of("mapmodule", "mapmodule/mappkg", "mapmodule/mappkg.impl", "mappkg.Map", "mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)", "mappkg.system.property")); - checkSearch(inv, "Map", List.of("mappkg.Map", "mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", - "mappkg.impl.MyMap.MyMap(Map)")); - checkSearch(inv, "MAP", List.of()); + checkSearch(inv, "Map", List.of("mapmodule", "mapmodule/mappkg", "mapmodule/mappkg.impl", "mappkg.Map", "mappkg.impl.MyMap", + "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)", "mappkg.system.property")); + checkSearch(inv, "MAP", List.of("mapmodule", "mapmodule/mappkg", "mapmodule/mappkg.impl", "mappkg.Map", "mappkg.impl.MyMap", + "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)", "mappkg.system.property")); checkSearch(inv, "value", List.of("mappkg.impl.MyMap.OTHER_VALUE", "mappkg.impl.MyMap.some_value")); - checkSearch(inv, "VALUE", List.of("mappkg.impl.MyMap.OTHER_VALUE")); + checkSearch(inv, "VALUE", List.of("mappkg.impl.MyMap.OTHER_VALUE", "mappkg.impl.MyMap.some_value")); checkSearch(inv, "map.other", List.of("mappkg.impl.MyMap.OTHER_VALUE")); - checkSearch(inv, "Map.some_", List.of("mappkg.impl.MyMap.some_value")); + checkSearch(inv, "Map.Some_", List.of("mappkg.impl.MyMap.some_value")); checkSearch(inv, "Mm", List.of()); checkSearch(inv, "mym", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); @@ -123,12 +123,12 @@ public void testModuleSearch() throws ScriptException, IOException, NoSuchMethod // camel case checkSearch(inv, "MM", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "MyM", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); - checkSearch(inv, "Mym", List.of()); + checkSearch(inv, "Mym", List.of("mappkg.impl.MyMap", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "i.MyM.MyM(", List.of("mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "i.MMa.MMa(", List.of("mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "i.MyM.MyM(Ma", List.of("mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "i.MMa.MMa(M", List.of("mappkg.impl.MyMap.MyMap(Map)")); - checkSearch(inv, "i.Mym.MyM(", List.of()); + checkSearch(inv, "i.Mym.MyM(", List.of("mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)")); checkSearch(inv, "i.Mym.Ma(", List.of()); checkSearch(inv, "mapm", List.of("mapmodule")); @@ -142,13 +142,14 @@ public void testModuleSearch() throws ScriptException, IOException, NoSuchMethod checkSearch(inv, "mapmod.", List.of()); checkSearch(inv, "mappkg.", List.of("mapmodule/mappkg.impl", "mappkg.Map", "mappkg.system.property")); checkSearch(inv, "mappkg.", List.of("mapmodule/mappkg.impl", "mappkg.Map", "mappkg.system.property")); - checkSearch(inv, "Map.", List.of("mappkg.Map.contains(Object)", "mappkg.Map.get(Object)", "mappkg.Map.iterate()", - "mappkg.Map.put(Object, Object)", "mappkg.Map.remove(Object)", - "mappkg.impl.MyMap.contains(Object)", "mappkg.impl.MyMap.get(Object)", - "mappkg.impl.MyMap.iterate()", "mappkg.impl.MyMap.MyMap()", - "mappkg.impl.MyMap.MyMap(Map)", "mappkg.impl.MyMap.OTHER_VALUE", - "mappkg.impl.MyMap.put(Object, Object)", "mappkg.impl.MyMap.remove(Object)", - "mappkg.impl.MyMap.some_value")); + checkSearch(inv, "Map.", List.of("mapmodule/mappkg.impl", "mappkg.Map", "mappkg.Map.contains(Object)", + "mappkg.Map.get(Object)", "mappkg.Map.iterate()", "mappkg.Map.put(Object, Object)", + "mappkg.Map.remove(Object)", "mappkg.impl.MyMap.contains(Object)", + "mappkg.impl.MyMap.get(Object)", "mappkg.impl.MyMap.iterate()", + "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)", + "mappkg.impl.MyMap.OTHER_VALUE", "mappkg.impl.MyMap.put(Object, Object)", + "mappkg.impl.MyMap.remove(Object)", "mappkg.impl.MyMap.some_value", + "mappkg.system.property")); checkSearch(inv, "mym.", List.of("mappkg.impl.MyMap.contains(Object)", "mappkg.impl.MyMap.get(Object)", "mappkg.impl.MyMap.iterate()", "mappkg.impl.MyMap.MyMap()", "mappkg.impl.MyMap.MyMap(Map)", "mappkg.impl.MyMap.OTHER_VALUE", @@ -165,8 +166,8 @@ public void testModuleSearch() throws ScriptException, IOException, NoSuchMethod checkSearch(inv, "operty", List.of()); // search tag - checkSearch(inv, "search tag", List.of("multiline search tag", "search tag")); - checkSearch(inv, "search tag", List.of("multiline search tag", "search tag")); + checkSearch(inv, "search tag", List.of("search tag", "multiline search tag")); + checkSearch(inv, "search tag", List.of("search tag", "multiline search tag")); checkSearch(inv, "search ", List.of("multiline search tag", "search tag")); checkSearch(inv, "tag", List.of("multiline search tag", "search tag")); checkSearch(inv, "sea", List.of("multiline search tag", "search tag")); @@ -186,23 +187,17 @@ public void testPackageSource() throws ScriptException, IOException, NoSuchMetho Invocable inv = getEngine(); - if (inv == null) { - out.println("No JavaScript engine available. Test skipped."); - return; - } - // exact match, case sensitvity, left boundaries checkSearch(inv, "list", List.of("listpkg", "listpkg.List", "listpkg.ListProvider", "listpkg.MyList", "listpkg.MyListFactory", "listpkg.ListProvider.ListProvider()", "listpkg.MyListFactory.createList(ListProvider, MyListFactory)", "listpkg.ListProvider.makeNewList()", "listpkg.MyList.MyList()", "listpkg.MyListFactory.MyListFactory()")); - checkSearch(inv, "List", List.of("listpkg.List", "listpkg.ListProvider", "listpkg.MyList", + checkSearch(inv, "List", List.of("listpkg", "listpkg.List", "listpkg.ListProvider", "listpkg.MyList", "listpkg.MyListFactory", "listpkg.ListProvider.ListProvider()", "listpkg.MyListFactory.createList(ListProvider, MyListFactory)", "listpkg.ListProvider.makeNewList()", "listpkg.MyList.MyList()", "listpkg.MyListFactory.MyListFactory()")); - // partial match checkSearch(inv, "fact", List.of("listpkg.MyListFactory", "listpkg.MyListFactory.MyListFactory()")); checkSearch(inv, "pro", List.of("listpkg.ListProvider", "listpkg.ListProvider.ListProvider()")); @@ -230,7 +225,9 @@ public void testPackageSource() throws ScriptException, IOException, NoSuchMetho List.of("listpkg.List.of()", "listpkg.List.of(E)", "listpkg.List.of(E, E)", "listpkg.List.of(E, E, E)", "listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)", "listpkg.List.of(E...)")); - checkSearch(inv, "L.l.o", List.of()); + checkSearch(inv, "L.l.o", List.of("listpkg.List.of()", "listpkg.List.of(E)", "listpkg.List.of(E, E)", + "listpkg.List.of(E, E, E)", "listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)", + "listpkg.List.of(E...)")); // whitespace checkSearch(inv, "(e,e,e", @@ -281,10 +278,10 @@ public void testPackageSource() throws ScriptException, IOException, NoSuchMetho // _ word boundaries and case sensitivity checkSearch(inv, "some", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "SOME", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); - checkSearch(inv, "Some", List.of()); + checkSearch(inv, "Some", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "int", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "INT", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); - checkSearch(inv, "Int", List.of()); + checkSearch(inv, "Int", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "int_con", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "INT_CON", List.of("listpkg.Nolist.SOME_INT_CONSTANT")); checkSearch(inv, "NT", List.of()); @@ -295,7 +292,7 @@ public void testPackageSource() throws ScriptException, IOException, NoSuchMetho // Test for all packages, all classes links checkSearch(inv, "all", List.of("All Packages", "All Classes")); checkSearch(inv, "All", List.of("All Packages", "All Classes")); - checkSearch(inv, "ALL", List.of()); + checkSearch(inv, "ALL", List.of("All Packages", "All Classes")); // test for generic types, var-arg and array args checkSearch(inv, "(map)", diff --git a/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js b/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js index bc918373e01..52c1b136035 100644 --- a/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js +++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/javadoc-search.js @@ -47,6 +47,16 @@ function tryLoad(docsPath, file) { } } +var updateSearchResults = function() {}; + +function indexFilesLoaded() { + return moduleSearchIndex + && packageSearchIndex + && typeSearchIndex + && memberSearchIndex + && tagSearchIndex; +} + var $ = function(f) { if (typeof f === "function") { f(); diff --git a/test/langtools/jdk/javadoc/doclet/testSerialMissing/TestSerialMissing.java b/test/langtools/jdk/javadoc/doclet/testSerialMissing/TestSerialMissing.java new file mode 100644 index 00000000000..b0210468dc5 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testSerialMissing/TestSerialMissing.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8251200 + * @summary False positive messages about missing comments for serialization + * @library /tools/lib ../../lib/ + * @modules jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* + * @build toolbox.ToolBox javadoc.tester.* + * @run main TestSerialMissing + */ + +import java.io.IOException; +import java.nio.file.Path; + +import javadoc.tester.JavadocTester; +import toolbox.ToolBox; + +public class TestSerialMissing extends JavadocTester { + public static void main(String... args) throws Exception { + TestSerialMissing tester = new TestSerialMissing(); + tester.runTests(m -> new Object[] { Path.of(m.getName()) } ); + } + + ToolBox tb = new ToolBox(); + + @Test + public void testPackagePrivate(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + /** Module m. */ + module m { exports p; } + """, + """ + package p; + /** PUBLIC class. */ + public class PUBLIC extends Exception { } + """, + """ + package p; + // no comment: class should not be documented + class PACKAGE_PRIVATE extends Exception { } + """); + + javadoc("-d", base.resolve("api").toString(), + "-sourcepath", src.toString(), + "--module", "m"); + checkExit(Exit.OK); + + // should not be any reference to PACKAGE_PRIVATE.java, such as for no comment + checkOutput(Output.OUT, false, + "PACKAGE_PRIVATE"); + } +} \ No newline at end of file diff --git a/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java b/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java index 14cc5c251dd..cadaabf1906 100644 --- a/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java +++ b/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java @@ -76,7 +76,7 @@ public void test(Path base) throws Exception { checkOutput("serialized-form.html", true, """
                public void readObject&\ + lass="return-type">void readObject&\ #8203;(java.io.ObjectInputStream arg0) throws java.lang.ClassNotFoundException, java.io.IOException
                diff --git a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java index f6f636cda7a..6cc1d107979 100644 --- a/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java +++ b/test/langtools/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -160,7 +160,7 @@ public void test(Path base) { .col-first a:link, .col-first a:visited, .col-second a:link, .col-second a:visited, .col-constructor-name a:link, .col-constructor-name a:visited, - .col-deprecated-item-name a:link, .col-deprecated-item-name a:visited, + .col-summary-item-name a:link, .col-summary-item-name a:visited, .constant-values-container a:link, .constant-values-container a:visited, .all-classes-container a:link, .all-classes-container a:visited, .all-packages-container a:link, .all-packages-container a:visited { @@ -352,7 +352,7 @@ Set addExtraCSSClassNamesTo(Set styles) throws Exception { "method-summary", // the following provide the ability to optionally override components of the // memberSignature structure - "member-name", + "name", "modifiers", "packages", "return-type", diff --git a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java index 6f0ec9cff85..add9c5d905d 100644 --- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java +++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java @@ -93,7 +93,7 @@ thod in class p1.A

                m3

                public void m3()
                + lass="return-type">void m3()
                First sentence some text maybe second sentence.
                """ diff --git a/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java b/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java index 7cee7c24f6d..88ebfe6087d 100644 --- a/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java +++ b/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java @@ -63,7 +63,7 @@ public void test(Path base) throws Exception { checkOrder("mymodule/mypackage/MyAnnotation.html", """ -

                Annotation Type MyAnnotation

                """, +

                Annotation Interface MyAnnotation

                """, """ (annotation) the test.property system property.""", "

                Element Details

                ", @@ -99,7 +99,7 @@ public void test(Path base) throws Exception { checkOrder("mymodule/mypackage/MyEnum.html", """ -

                Enum MyEnum

                """, +

                Enum Class MyEnum

                """, """ (enum) the test.property system property.""", "

                Enum Constant Details

                ", @@ -166,7 +166,7 @@ public void test(Path base) throws Exception {

                T

                """, """
                test.property - Search tag in annotation type mypackag\ + test.property">test.property - Search tag in annotation interface mypackag\ e.MyAnnotation
                System Property
                """, """ @@ -175,7 +175,7 @@ public void test(Path base) throws Exception {
                System Property
                """, """
                test.property - Search tag in enum mypackage.MyEnum
                + roperty">test.property - Search tag in enum class mypackage.MyEnum
                System Property
                """, """
                new Object[]{Path.of(m.getName())}); + } + + private final ToolBox tb = new ToolBox(); + + @Test + public void testAnnotationInterface(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; /** Comment. */ public @interface A { + int m(); + } + """ + ); + testAnnotationInterface(base, src, SourceVersion.RELEASE_15); + testAnnotationInterface(base, src, SourceVersion.latest()); + } + + void testAnnotationInterface(Path base, Path src, SourceVersion sv) { + String v = asOption(sv); + javadoc("-d", base.resolve("out" + v).toString(), + "--source-path", src.toString(), + "--source", v, + "-use", + "p"); + checkExit(Exit.OK); + + checkOutput("p/A.html", sv.compareTo(SourceVersion.RELEASE_16) < 0, + """ +

                Annotation Type A

                """ + ); + checkOutput("p/A.html", sv.compareTo(SourceVersion.RELEASE_16) >= 0, + """ +

                Annotation Interface A

                """ + ); + + + checkOutput("p/class-use/A.html", sv.compareTo(SourceVersion.RELEASE_16) < 0, + """ +

                Uses of Annotation Type
                p.A

                """ + ); + checkOutput("p/class-use/A.html", sv.compareTo(SourceVersion.RELEASE_16) >= 0, + """ +

                Uses of Annotation Interface
                p.A

                """ + ); + + + } + + @Test + public void testEnumClass(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; /** Comment. */ public enum E { } + """ + ); + testEnumClass(base, src, SourceVersion.RELEASE_15); + testEnumClass(base, src, SourceVersion.latest()); + } + + void testEnumClass(Path base, Path src, SourceVersion sv) { + String v = asOption(sv); + javadoc("-d", base.resolve("out" + v).toString(), + "--source-path", src.toString(), + "--source", v, + "p"); + checkExit(Exit.OK); + + checkOutput("p/E.html", sv.compareTo(SourceVersion.RELEASE_16) < 0, + """ +

                Enum E

                """ + ); + checkOutput("p/E.html", sv.compareTo(SourceVersion.RELEASE_16) >= 0, + """ +

                Enum Class E

                """ + ); + } + + @Test + public void testSearch(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; /** Comment. */ public class C { } + """ + ); + testSearch(base, src, SourceVersion.RELEASE_15); + testSearch(base, src, SourceVersion.latest()); + } + + public void testSearch(Path base, Path src, SourceVersion sv) { + String v = asOption(sv); + javadoc("-d", base.resolve("out" + v).toString(), + "--source-path", src.toString(), + "--source", v, + "p"); + checkExit(Exit.OK); + + checkOutput("search.js", sv.compareTo(SourceVersion.RELEASE_16) < 0, + """ + var catTypes = "Types";""" // + ); + checkOutput("search.js", sv.compareTo(SourceVersion.RELEASE_16) >= 0, + """ + var catTypes = "Classes and Interfaces";""" + ); + } + + private String asOption(SourceVersion sv) { + return sv.name().replace("RELEASE_", ""); + } +} diff --git a/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java b/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java index 4f116ab7ce9..57e88d60c9e 100644 --- a/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java +++ b/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java @@ -76,7 +76,7 @@ public interface C { """
                <T extends java\ .lang.Throwable> void m() + an class="element-name">m() throws T, java.lang.Exception
                """, diff --git a/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java b/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java index cd1349f88cd..49af127c44a 100644 --- a/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java +++ b/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8005091 8009686 8025633 8026567 6469562 8071982 8071984 8162363 8175200 8186332 8182765 - * 8187288 8241969 + * 8187288 8241969 8259216 * @summary Make sure that type annotations are displayed correctly * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -63,7 +63,7 @@ public void test() { a> java.lang.CharSequence,
                @ClassExtA ParameterizedInterface<@ClassExtB java.lang.String>"""); + in typeannos">@ClassExtB java.lang.String>
                """); checkOutput("typeannos/MyInterface.html", true, """ @@ -71,48 +71,49 @@ public void test() { Parameteriz\ edInterface<@Cla\ ssExtA java.lang.String>, @ClassExtB java.lang.CharSequence"""); + ypeannos">@ClassExtB java.lang.CharSequence"""); // Test for type annotations on Class Parameters (ClassParameters.java). checkOutput("typeannos/ExtendsBound.html", true, """ - class ExtendsBound<K extends @ClassParamA java.lang.String>"""); + class ExtendsBound<K extend\ + s @ClassParamA ja\ + va.lang.String>"""); checkOutput("typeannos/ExtendsGeneric.html", true, """ -
                class ExtendsGeneric<K extends @ClassParamA Unannotated<@ClassParamB java.lang.String>>""");
                +                    
                class ExtendsGeneric<K extends @ClassParamA Unannotated<@ClassParamB java.lang.String>>"""); checkOutput("typeannos/TwoBounds.html", true, """ -
                class TwoBounds<K extends @ClassParamA java.lang.String,\
                -                    203;V extends @ClassP\
                -                    aramB java.lang.String>""");
                +                    
                class TwoBounds<K extends @ClassParamA java.lang.String,​V extends\ + @ClassParamB jav\ + a.lang.String>"""); checkOutput("typeannos/Complex1.html", true, """ - class Complex1<K extends @ClassParamA java.lang.String & jav\ - a.lang.Runnable>"""); + class Complex1<K extends @ClassParamA java.l\ + ang.String & java.lang.Runnable>"""); checkOutput("typeannos/Complex2.html", true, """ - class Complex2<K extends java.lang.String &\ - @ClassParamB jav\ - a.lang.Runnable>"""); + class Complex2<K extends ja\ + va.lang.String & \ + @ClassParamB java.lang.Runnable>"""); checkOutput("typeannos/ComplexBoth.html", true, """ - class ComplexBoth<K extends @ClassParamA java.lang.String & \ - @ClassParamA java\ - .lang.Runnable>"""); + class ComplexBoth<K extends\ + @ClassParamA jav\ + a.lang.String & @\ + ClassParamA java.lang.Runnable>"""); // Test for type annotations on fields (Fields.java). checkOutput("typeannos/DefaultScope.html", true, @@ -121,18 +122,18 @@ class ComplexBoth<K extends Parameterized<@FldA java.lang.String,​@FldB java.lang.String> bothTypeArgs
                """, + class="element-name">bothTypeArgs
                """, """
                @FldA java.lang.String @FldB [] ar\ - ray1Deep
                """, + ="annotation in typeannos">@FldB []
                 a\ + rray1Deep""", """
                java.lang.String @FldB [][] array2SecondOld
                """, + ass="element-name">array2SecondOld""", // When JDK-8068737, we should change the order """ @@ -141,7 +142,7 @@ class ComplexBoth<K extends @FldC @FldB [] @FldC<\ /a> @FldA [] \ - ;array2Deep"""); + ;array2Deep"""); checkOutput("typeannos/ModifiedScoped.html", true, """ @@ -152,14 +153,14 @@ class ComplexBoth<K extends @FldA java.lang.String,\ ​@FldB java.lang.S\ tring>,​@FldB j\ - ava.lang.String> nestedParameterized""", + ava.lang.String> nestedParameterized""", """
                public final <\ span class="return-type">@Fl\ - dA java.lang.String[][] array2<\ - /div>"""); + dA java.lang.String[][] array2\ +
                """); // Test for type annotations on method return types (MethodReturnType.java). checkOutput("typeannos/MtdDefaultScope.html", true, @@ -167,20 +168,20 @@ class ComplexBoth<K extends public <T> @MRtnA java.lang.String&n\ - bsp;method()""", + bsp;method()""", // When JDK-8068737 is fixed, we should change the order """
                @MRtnA java.lang.String @MRtnB [] @MRtnA [] array2Deep<\ - /span>()
                """, + on in typeannos">@MRtnA []
                 array2Deep\ + ()""", """
                @MRtnA java.lang.String[][] array2()
                """); + lass="element-name">array2()"""); checkOutput("typeannos/MtdModifiedScoped.html", true, """ @@ -191,16 +192,16 @@ class ComplexBoth<K extends @MRtnA j\ ava.lang.String,​@MRt\ nB java.lang.String>,​@MRtnB java.lang.String> ne\ - stedMtdParameterized()"""); + eannos">@MRtnB java.lang.String> n\ + estedMtdParameterized()"""); // Test for type annotations on method type parameters (MethodTypeParameters.java). checkOutput("typeannos/UnscopedUnmodified.html", true, """
                <K extends @MTyParamA java.lang.Stri\ - ng> void methodExtends()
                """, + ng> void methodExtends()""", """
                <K extends <\ @@ -208,14 +209,14 @@ class ComplexBoth<K extends MtdTyParameterized<@MTyParamB java.lang.\ String>> - void nestedExtends()
                """); + void nestedExtends()"""); checkOutput("typeannos/PublicModifiedMethods.html", true, """
                public final <\ span class="type-parameters"><K extends @MTyParamA java.lang.String> - void methodExtends()
                """, + void methodExtends()""", """
                public final <\ @@ -225,45 +226,45 @@ class ComplexBoth<K extends MtdTyParameterize\ d<@MTyParamB\ java.lang.String>> - void dual()
                """); + void dual()"""); // Test for type annotations on parameters (Parameters.java). checkOutput("typeannos/Parameters.html", true, """
                void unannotated(ParaParameterized<java.\ - lang.String,​java.lang.String> a)
                """, + lass="element-name">unannotated​(ParaParameterized<java\ + .lang.String,​java.lang.String> a)""", """
                void nestedParaParameterized(ParaParameterized<\ - /a><@ParamA ParaParameterized<@ParamA java.lang.String\ - ,​@ParamB java.l\ - ang.String>,​@Par\ - amB java.lang.String> a)
                """, + lass="element-name">nestedParaParameterized​(ParaParameterized\ + <@ParamA ParaParameterized<<\ + a href="ParamA.html" title="annotation in typeannos">@ParamA java.lang.Strin\ + g,​@ParamB java.\ + lang.String>,​@Pa\ + ramB java.lang.String> a)""", // When JDK-8068737 is fixed, we should change the order """
                void array2Deep(@ParamA java.lang.String @ParamB [] @ParamA [] a)
                """); + lass="element-name">array2Deep​(@ParamA java.lang.String @ParamB [] @ParamA [] a)"""); // Test for type annotations on throws (Throws.java). checkOutput("typeannos/ThrDefaultUnmodified.html", true, """ -
                void oneException() +
                void oneException() throws @ThrA java.lang.Exception
                """, """
                void twoExceptions() + lass="element-name">twoExceptions() throws @ThrA java.lang.RuntimeException, @ThrA java.lang.Exception
                """); @@ -271,28 +272,28 @@ class ComplexBoth<K extends public final <\ - span class="return-type">void oneException\ - (java.lang.String a) + span class="return-type">void oneException\ + ​(java.lang.String a) throws @ThrA java.lang.Exception
                """, """
                public final <\ - span class="return-type">void twoException\ - s(java.lang.String a) + span class="return-type">void twoExceptions​(java.lang.String a) throws @ThrA java.lang.RuntimeException, @ThrA java.lang.Exception
                """); checkOutput("typeannos/ThrWithValue.html", true, """ -
                void oneException() +
                void oneException() throws @ThrB("m") java.lang.Exception
                """, """
                void twoExceptions() + lass="element-name">twoExceptions() throws @ThrB("m") java.lang.RuntimeException, @ThrA java.lang.Exception
                """); @@ -304,105 +305,105 @@ class ComplexBoth<K extends @TyParaA V extends @TyParaA java.lang.Stri\ ng> - void secondAnnotated()
                """ + void secondAnnotated()""" ); // Test for type annotations on wildcard type (Wildcards.java). checkOutput("typeannos/BoundTest.html", true, """
                void wcExtends(MyList<? extends @WldA java.lang.String> l)""", + lass="element-name">wcExtends​(MyList<? extends @WldA java.lang.String> l)<\ + /div>""", """
                MyList<? super @WldA java.lang.String> returnWcSuper()
                """); + tion in typeannos">@WldA java.lang.String> returnWcSuper()
                """); checkOutput("typeannos/BoundWithValue.html", true, """
                void wcSuper(MyList<? super @WldB("m") java.lang.String> l)<\ - /div>""", + lass="element-name">wcSuper​(MyList<? super @WldB("m") java.lang.String> l)\ +
                """, """
                MyList<? extends @WldB("m") java.lang.String> returnWcExtends()
                """); + ="element-name">returnWcExtends()"""); checkOutput("typeannos/SelfTest.html", true, """
                MyList<@WldA ?> returnWcExtends\ - ()
                """, + typeannos">@WldA ?> returnWcExtends\ + ()""", """
                MyList<@WldA ? extends @WldA MyList<@WldB("m") ?>>&\ - nbsp;complex()
                """); + nbsp;complex()"""); checkOutput("typeannos/SelfWithValue.html", true, """
                MyList<@WldB("m") ?> returnWcEx\ - tends()
                """, + typeannos">@WldB("m") ?> returnWcExtends()""", """
                MyList<@WldB("m") ? extends MyList<@WldB\ - ("m") ? super java.lang.String>> com\ - plex()
                """); + ("m") ? super java.lang.String>>
                 complex()"""); // Test for receiver annotations (Receivers.java). checkOutput("typeannos/DefaultUnmodified.html", true, """
                void withException(@RcvrA DefaultUnmodified&n\ - bsp;this) + lass="element-name">withException​(@RcvrA DefaultUnmodified&\ + nbsp;this) throws java.lang.Exception
                """, """
                java.lang.String&\ - nbsp;nonVoid(@RcvrA @RcvrB("m") DefaultUnmodified t\ - his)
                """, + nbsp;nonVoid(@RcvrA @RcvrB("m") DefaultUnmodified this)""", """
                <T extends java.l\ ang.Runnable> void accept(@RcvrA DefaultUnmodified this\ - , + ass="element-name">accept(@RcvrA DefaultUnmodified thi\ + s, T r) throws java.lang.Exception
                """); checkOutput("typeannos/PublicModified.html", true, """
                public final <\ - span class="return-type">java.lang.String \ - nonVoid(@RcvrA PublicModified this)
                """, + span class="return-type">java.lang.String
                 nonVoid\ + (@RcvrA PublicModified this)""", """
                public final <\ span class="type-parameters"><T extends java.lang.Runnable> void accept\ - ​(@RcvrA PublicModified this, + pan class="return-type">void accept​\ + (@RcvrA PublicModified this, T r) throws java.lang.Exception
                """); @@ -410,42 +411,57 @@ class ComplexBoth<K extends <T extends java.l\ ang.Runnable> void accept(@RcvrB("m") WithValue this, + ass="element-name">accept(@RcvrB("m") WithValue this, T r) throws java.lang.Exception"""); checkOutput("typeannos/WithFinal.html", true, """
                java.lang.String&\ - nbsp;nonVoid(@RcvrB("m") WithFinal afield)
                """); + nbsp;nonVoid(@RcvrB("m") WithFinal afield)"""); checkOutput("typeannos/WithBody.html", true, """
                void field(@RcvrA WithBody this)<\ - /div>"""); + lass="element-name">field​(@RcvrA WithBody this)\ +
                """); checkOutput("typeannos/Generic2.html", true, """
                void test2(@RcvrA Generic2<X> this\ - )
                """); + lass="element-name">test1
                ()""", + """ +
                void test2(@RcvrA Generic2<X> thi\ + s)
                """, + """ +
                void test3(Generic2<@RcvrA X> this)
                """, + """ +
                void test4(@RcvrA Generic2<@RcvrA X> this)
                """); // Test for repeated type annotations (RepeatedAnnotations.java). checkOutput("typeannos/RepeatingAtClassLevel.html", true, """ -
                @RepTypeA @RepTypeA
                +                    
                @RepTypeA @RepTypeA @RepTypeB @RepTypeB - class RepeatingAtClassLevel - extends java.lang.Object
                """); + class RepeatingAtClassLevel + extends java.lang.Object"""); // @ignore 8146008 // checkOutput("typeannos/RepeatingAtClassLevel2.html", true, @@ -476,7 +492,7 @@ class RepeatingAtClassLevel @RepConstructorB<\ /a> @RepConstruct\ orB - RepeatingOnConstructor()""", + RepeatingOnConstructor()""", """
                RepeatingAtClassLevel @RepConstructorB<\ /a> @RepConstruct\ orB - RepeatingOnConstructor(int i, + RepeatingOnConstructor(int i, int j)
                """, """ @@ -495,17 +511,17 @@ class RepeatingAtClassLevel @RepAllContextsB<\ /a> @RepAllContex\ tsB - RepeatingOnConstructor(int i, + RepeatingOnConstructor(int i, int j, int k)""", """ -
                RepeatingOnConstructor(@RepParameterA @RepParameterA @RepParameterB @RepParameterB +
                RepeatingOnConstructor&#\ + 8203;(@RepParameterA @RepParameterA @RepParameterB @RepParameterB java.lang.String parameter, @RepParameterA \ @RepParameterA \ @@ -532,7 +548,8 @@ class RepeatingAtClassLevel nnotation in typeannos">@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor this, + typeannos">@RepTypeUseB RepeatingOnConstructor RepeatingOnConstructor.this, @RepParameterA \ @RepParameterA \ @RepParameterB \ @@ -593,9 +610,13 @@ class RepeatingAtClassLevel """, """ -
                @RepFieldA @RepFieldA - @RepFieldB @RepFieldB - java.lang.Integer i1
                """, +
                @RepFieldA @RepFieldA + @RepFieldB @RepFieldB + java.lang.Integer i1
                """, """ """, + s="element-name">i2
                """, """ """, """ @@ -630,7 +651,7 @@ class RepeatingAtClassLevel ation in typeannos">@RepAllContextsA @RepAllContextsB @RepAllContextsB java.lang.Integer
                 <\ - span class="member-name">i4
                """, + span class="element-name">i4""", """ """); + ="annotation in typeannos">@RepTypeUseB [] sa"""); checkOutput("typeannos/RepeatingOnMethod.html", true, """ (package private) java.lang.String -
                test1()""", +
                test1()""", """ (package private) RepeatingAtClassLevel RepTypeUseA @RepT\ ypeUseB @RepTypeU\ seB java.lang.String
                -
                test2()""", +
                test2()""", """ (package private) RepeatingAtClassLevel RepTypeUseA @RepT\ ypeUseB @RepTypeU\ seB java.lang.String
                -
                test3()""", + - -
                genericMethod​(T t)""", +
                genericMethod​(T t)""", """ (package private) <T> java.lang.String
                - -
                test()""", - - """ - java.lang.String test(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnTypeParametersBoundsTypeArgumentsOn\ - Method<@RepTypeUse\ - A @RepTypeUseA @RepTypeUseB @RepTypeUseB T>&\ - nbsp;this)"""); +
                test()""", + + """ + java.lang.String test(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod&\ + lt;@RepTypeUseA <\ + a href="RepTypeUseA.html" title="annotation in typeannos">@RepTypeUseA @RepTypeUseB @RepTypeUseB T> th\ + is)"""); checkOutput("typeannos/RepeatingOnVoidMethodDeclaration.html", true, """ @@ -794,6 +815,6 @@ class RepeatingAtClassLevel f="RepMethodA.html" title="annotation in typeannos">@RepMethodA @RepMethodB @RepMethodB - void test()"""); + void test()"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testTypeParams/TestTypeParameters.java b/test/langtools/jdk/javadoc/doclet/testTypeParams/TestTypeParameters.java index 44a69e62a65..5358d7b9f16 100644 --- a/test/langtools/jdk/javadoc/doclet/testTypeParams/TestTypeParameters.java +++ b/test/langtools/jdk/javadoc/doclet/testTypeParams/TestTypeParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,8 +55,8 @@ public void test1() { checkOutput("pkg/C.html", true, """ -
                <W extends java.lang.String,​ +
                <W extends java.lang.String,​ V extends java.util.List>
                java.lang.Object
                """, "<T> java.lang.Object"); @@ -88,10 +88,10 @@ public void test2() { checkExit(Exit.OK); checkOutput("pkg/ClassUseTest3.html", true, - """ - public class ClassUseTest3<\ - /a><T extends ParamTest2&l\ - t;java.util.List<? extends Foo4&\ - gt;>>"""); + """ + public class ClassUseTest3<T extends ParamTest2<java.util.List<? extends Foo4>>>"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java index 40b92a4ad1b..81d41665842 100644 --- a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java +++ b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,9 +75,9 @@ public void test() {
                Class
                Description
                - -
                +
                <\ + a href="C.html" title="class in <Unnamed>">C
                +
                This is a class in the unnamed package.
                """); diff --git a/test/langtools/jdk/javadoc/doclet/testVisibleMembers/TestVisibleMembers.java b/test/langtools/jdk/javadoc/doclet/testVisibleMembers/TestVisibleMembers.java index 12803881469..c3adbc1b7e8 100644 --- a/test/langtools/jdk/javadoc/doclet/testVisibleMembers/TestVisibleMembers.java +++ b/test/langtools/jdk/javadoc/doclet/testVisibleMembers/TestVisibleMembers.java @@ -309,7 +309,7 @@ public void testStreamsMissingLinksSummary(Path base) throws Exception { checkOrder("p/C.html", "METHOD DETAIL", - "public", "void", "method", "See Also:", "sub()", "I.sub1()", + "public", "void", "method", "See Also:", "sub()", "sub1()", "public", "void", "m", "Method in C. See", "I.length()" ); @@ -325,9 +325,8 @@ public void testStreamsMissingLinksSummary(Path base) throws Exception { "METHOD DETAIL", "Method sub in p.IImpl", "Specified by:", "I.html", + "Specified by:", "II.html", "END OF CLASS DATA"); - - checkUnique("p/IImpl.html", "Specified by:"); } // see j.u.Spliterator diff --git a/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java b/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java index 5fe93c25139..e82b0622895 100644 --- a/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java +++ b/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8000612 8254627 + * @bug 8000612 8254627 8247994 * @summary need test program to validate javadoc resource bundles * @modules jdk.javadoc/jdk.javadoc.internal.tool * jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open @@ -34,6 +34,8 @@ import java.io.*; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.tools.*; import com.sun.tools.classfile.*; @@ -149,6 +151,9 @@ void findDeadKeys(Set codeKeys, Set resourceKeys) { // ignore these synthesized keys, tested by usageTests if (rk.matches("main\\.opt\\..*\\.(arg|desc)")) continue; + // ignore this partial key + if (rk.startsWith("doclet.Declared_Using_Preview.")) + continue; if (codeKeys.contains(rk)) continue; @@ -200,10 +205,21 @@ Set getCodeKeys() throws IOException { } } + // special handling for strings in search.js.template + FileObject fo = fm.getFileForInput(javadocLoc, + "jdk.javadoc.internal.doclets.formats.html", + "resources/search.js.template"); + CharSequence search_js = fo.getCharContent(true); + Pattern p = Pattern.compile("##REPLACE:(?[A-Za-z0-9._]+)##"); + Matcher m = p.matcher(search_js); + while (m.find()) { + results.add(m.group("key")); + } + // special handling for code strings synthesized in // jdk.javadoc.internal.doclets.toolkit.util.Utils.getTypeName String[] extras = { - "AnnotationType", "Class", "Enum", "Error", "Exception", "Interface", "Record" + "AnnotationType", "Class", "Enum", "EnumClass", "Error", "Exception", "Interface", "RecordClass" }; for (String s: extras) { if (results.contains("doclet." + s)) diff --git a/test/langtools/jdk/jshell/ExceptionsTest.java b/test/langtools/jdk/jshell/ExceptionsTest.java index d45f9458bd8..ed4a5ed44bd 100644 --- a/test/langtools/jdk/jshell/ExceptionsTest.java +++ b/test/langtools/jdk/jshell/ExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,7 +227,7 @@ public void throwFromWithoutSource() { assertExceptionMatch(se, new ExceptionInfo(IllegalStateException.class, message, newStackTraceElement("", "lambda$do_it$$0", se.snippet(), 1), - new StackTraceElement("com.sun.proxy.$Proxy0", "hashCode", null, -1), + new StackTraceElement("jdk.proxy1.$Proxy0", "hashCode", null, -1), newStackTraceElement("", "", se.snippet(), 1))); } diff --git a/test/langtools/jdk/jshell/ImportTest.java b/test/langtools/jdk/jshell/ImportTest.java index d5b03c47f41..e09490052cf 100644 --- a/test/langtools/jdk/jshell/ImportTest.java +++ b/test/langtools/jdk/jshell/ImportTest.java @@ -68,7 +68,7 @@ public void testImportOnDemand() { public void testImportStatic() { assertImportKeyMatch("import static java.lang.Math.PI;", "PI", SINGLE_STATIC_IMPORT_SUBKIND, added(VALID)); - assertEval("new Double(PI).toString().substring(0, 16).equals(\"3.14159265358979\");", "true"); + assertEval("Double.valueOf(PI).toString().substring(0, 16).equals(\"3.14159265358979\");", "true"); } public void testImportStaticOnDemand() { diff --git a/test/langtools/jdk/jshell/SourceLevelTest.java b/test/langtools/jdk/jshell/SourceLevelTest.java new file mode 100644 index 00000000000..ce5572e6f71 --- /dev/null +++ b/test/langtools/jdk/jshell/SourceLevelTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8259820 + * @summary Check JShell can handle -source 8 + * @modules jdk.jshell + * @run testng SourceLevelTest + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +public class SourceLevelTest extends ReplToolTesting { + + @DataProvider(name="sourceLevels") + public Object[][] sourceLevels() { + return new Object[][] { + new Object[] {"8"}, + new Object[] {"11"} + }; + } + + @Test(dataProvider="sourceLevels") + public void testSourceLevel(String sourceLevel) { + test(new String[] {"-C", "-source", "-C", sourceLevel}, + (a) -> assertCommand(a, "1 + 1", "$1 ==> 2"), + (a) -> assertCommand(a, "1 + 2", "$2 ==> 3") + ); + } + +} diff --git a/test/langtools/jdk/jshell/TypeNameTest.java b/test/langtools/jdk/jshell/TypeNameTest.java index 6e6c270063e..dc2b2152ca8 100644 --- a/test/langtools/jdk/jshell/TypeNameTest.java +++ b/test/langtools/jdk/jshell/TypeNameTest.java @@ -194,7 +194,7 @@ public void testJEP286NonDenotable2() { assertEval(" Z choose(Z z1, Z z2) { return z1; }"); assertType("choose(1, 1L);", "Number&Comparable&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc", - "Object"); + "Number"); } public void testVariableTypeName() { @@ -249,7 +249,7 @@ public void testBounds() { assertType("test1.get()", "CharSequence"); assertEval("class Test2 { public X get() { return null; } }"); assertEval("Test2 test2 = new Test2<>();"); - assertType("test2.get()", "Number&CharSequence", "Object"); + assertType("test2.get()", "Number&CharSequence", "Number"); assertEval("class Test3 { T[][] get() { return null; } }"); assertEval("Test3 test3 = new Test3<>();"); assertType("test3.get()", "String[][]"); diff --git a/test/langtools/jdk/jshell/VariablesTest.java b/test/langtools/jdk/jshell/VariablesTest.java index 16a4903bc26..4224331b331 100644 --- a/test/langtools/jdk/jshell/VariablesTest.java +++ b/test/langtools/jdk/jshell/VariablesTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8144903 8177466 8191842 8211694 8213725 8239536 + * @bug 8144903 8177466 8191842 8211694 8213725 8239536 8257236 8252409 * @summary Tests for EvaluationState.variables * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -38,6 +38,7 @@ import java.util.List; import javax.tools.Diagnostic; +import jdk.jshell.MethodSnippet; import jdk.jshell.Snippet; import jdk.jshell.TypeDeclSnippet; import jdk.jshell.VarSnippet; @@ -400,6 +401,13 @@ public void lvti() { assertEval("r15a.add(\"a\");"); assertEval("var r15b = r15a.get(0);"); assertEval("r15b", "\"a\""); + assertEval("class Z { }"); + assertEval("var r16a = new Z();"); + assertEval("var r16b = (Runnable) () -> {int r16b_; int r16b__;};"); + assertEval("class $ { }"); + assertEval("var r16c = new $();"); + assertEval("$ r16d() { return null; }"); + assertEval("var r16d = r16d();"); } public void test8191842() { @@ -410,10 +418,14 @@ public void test8191842() { public void lvtiRecompileDependentsWithIntersectionTypes() { assertEval(" Z get1() { return null; }", added(VALID)); - VarSnippet var = varKey(assertEval("var i1 = get1();", added(VALID))); + assertEval("var i1 = get1();", added(VALID)); + MethodSnippet get2 = methodKey(assertEval(" Z get2() { return null; }", + ste(MAIN_SNIPPET, NONEXISTENT, RECOVERABLE_NOT_DEFINED, false, null))); assertEval("import java.util.stream.*;", added(VALID), - ste(var, VALID, VALID, true, MAIN_SNIPPET)); + ste(get2, RECOVERABLE_NOT_DEFINED, VALID, true, MAIN_SNIPPET)); assertEval("void t1() { i1.run(); i1.length(); }", added(VALID)); + assertEval("var i2 = get2();", added(VALID)); + assertEval("void t2() { i2.run(); i2.count(); }", added(VALID)); } public void arrayInit() { @@ -598,4 +610,11 @@ public void setUp() { .remoteVMOptions("--class-path", tpath) .compilerOptions("--class-path", tpath)); } + + public void varIntersection() { + assertEval("interface Marker {}"); + assertEval("var v = (Marker & Runnable) () -> {};", added(VALID)); + assertEval("v.run()"); + } + } diff --git a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java index d3ce5c8cbba..27a2940a2c8 100644 --- a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java +++ b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java @@ -4,9 +4,7 @@ * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -123,6 +121,10 @@ protected File assertOK(boolean generate, String... constructs) { return assertCompile(expandMarkers(constructs), this::assertCompileSucceeded, generate); } + protected File assertOK(Consumer> diagConsumer, String... constructs) { + return assertCompile(expandMarkers(constructs), () -> assertCompileSucceeded(diagConsumer), false); + } + protected void assertOKWithWarning(String warning, String... constructs) { assertCompile(expandMarkers(constructs), () -> assertCompileSucceededWithWarning(warning), false); } diff --git a/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java b/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java index b65fd5fb2ee..47f496b5891 100644 --- a/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java +++ b/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java @@ -66,6 +66,10 @@ public Diagnostic getDiagWithKey(String key) { return null; } + public List> getAllDiags() { + return diags.stream().map(d -> (Diagnostic)d).collect(toList()); + } + /** Do the diagnostics contain the specified error key? */ public boolean containsErrorKey(String key) { return diags.stream() diff --git a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java index cd1be44745f..be94ec7a3fa 100644 --- a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java +++ b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java @@ -177,6 +177,13 @@ protected void assertCompileSucceeded() { fail("Expected successful compilation"); } + /** Assert that all previous calls to compile() succeeded, also accepts a diagnostics consumer */ + protected void assertCompileSucceeded(Consumer> diagConsumer) { + if (diags.errorsFound()) + fail("Expected successful compilation"); + diags.getAllDiags().stream().forEach(diagConsumer); + } + /** Assert that all previous calls to compile() succeeded */ protected void assertCompileSucceededWithWarning(String warning) { if (diags.errorsFound()) diff --git a/test/langtools/tools/doclint/AccessibilityTest.java b/test/langtools/tools/doclint/AccessibilityTest.java index 5d7e34fe00d..17e9c9aa48c 100644 --- a/test/langtools/tools/doclint/AccessibilityTest.java +++ b/test/langtools/tools/doclint/AccessibilityTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 + * @bug 8004832 8247955 8247957 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester @@ -47,11 +47,6 @@ public void missing_h4() { } */ public void missing_alt() { } - /** - *
      Modules 
      head
      data
      - */ - public void table_with_summary() { } - /** *
      ok
      head
      data
      */ @@ -60,6 +55,12 @@ public void table_with_caption() { } /** *
      head
      data
      */ - public void table_without_summary_and_caption() { } + public void table_without_caption() { } + + /** + *
      head
      data
      + */ + public void table_presentation() { } + } diff --git a/test/langtools/tools/doclint/AccessibilityTest.out b/test/langtools/tools/doclint/AccessibilityTest.out index 94c7611232a..b3497ce8185 100644 --- a/test/langtools/tools/doclint/AccessibilityTest.out +++ b/test/langtools/tools/doclint/AccessibilityTest.out @@ -19,7 +19,7 @@ AccessibilityTest.java:41: error: heading used out of sequence:
      , compared t AccessibilityTest.java:46: error: no "alt" attribute for image * ^ -AccessibilityTest.java:61: error: no summary or caption for table +AccessibilityTest.java:56: error: no caption for table *
      head
      data
      ^ 8 errors diff --git a/test/langtools/tools/doclint/AccessibilityTest5.java b/test/langtools/tools/doclint/AccessibilityTest5.java deleted file mode 100644 index a5393b3d544..00000000000 --- a/test/langtools/tools/doclint/AccessibilityTest5.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8247955 - * @summary Add new doclint package - * @modules jdk.javadoc/jdk.javadoc.internal.doclint - * @build DocLintTester - * @run main DocLintTester -XhtmlVersion:html5 -Xmsgs:-accessibility AccessibilityTest5.java - * @run main DocLintTester -XhtmlVersion:html5 -ref AccessibilityTest5.out AccessibilityTest5.java - */ - -// This test should be merged into AccessibilityTest.java when we drop support for html4. - -/** */ -public class AccessibilityTest5 { - /** - *
      ok
      head
      data
      - */ - public void table_with_caption() { } - - /** - *
      head
      data
      - */ - public void table_without_caption() { } - - /** - *
      head
      data
      - */ - public void table_presentation() { } -} - diff --git a/test/langtools/tools/doclint/AccessibilityTest5.out b/test/langtools/tools/doclint/AccessibilityTest5.out deleted file mode 100644 index 23ccfda6681..00000000000 --- a/test/langtools/tools/doclint/AccessibilityTest5.out +++ /dev/null @@ -1,4 +0,0 @@ -AccessibilityTest5.java:21: error: no summary or caption for table - *
      head
      data
      - ^ -1 error diff --git a/test/langtools/tools/doclint/AnchorTest.java b/test/langtools/tools/doclint/AnchorTest.java index d2d9324189d..7bce8a51966 100644 --- a/test/langtools/tools/doclint/AnchorTest.java +++ b/test/langtools/tools/doclint/AnchorTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 + * @bug 8004832 8247957 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester @@ -9,37 +9,10 @@ /** */ public class AnchorTest { - // tests for - - /** - * - */ - public void a_name_foo() { } - - /** - * - */ - public void a_name_already_defined() { } - - /** - * - */ - public void a_name_empty() { } - - /** - * - */ - public void a_name_invalid() { } - - /** - * - */ - public void a_name_missing() { } - // tests for /** - * + * */ public void a_id_foo() { } @@ -54,7 +27,7 @@ public void a_id_already_defined() { } public void a_id_empty() { } /** - * + * */ public void a_id_invalid() { } @@ -81,7 +54,7 @@ public void p_id_already_defined() { } public void p_id_empty() { } /** - *

      text

      + *

      text

      */ public void p_id_invalid() { } diff --git a/test/langtools/tools/doclint/AnchorTest.out b/test/langtools/tools/doclint/AnchorTest.out index 70bb1383ee3..72c062e4acb 100644 --- a/test/langtools/tools/doclint/AnchorTest.out +++ b/test/langtools/tools/doclint/AnchorTest.out @@ -1,49 +1,31 @@ AnchorTest.java:20: error: anchor already defined: "foo" - * - ^ -AnchorTest.java:25: error: invalid name for anchor: "" - * - ^ -AnchorTest.java:30: error: invalid name for anchor: "123" - * - ^ -AnchorTest.java:35: error: no value given for anchor - * - ^ -AnchorTest.java:47: error: anchor already defined: "foo" * ^ -AnchorTest.java:52: error: invalid name for anchor: "" - * - ^ -AnchorTest.java:52: error: anchor already defined: "" +AnchorTest.java:25: error: invalid name for anchor: "" * ^ -AnchorTest.java:57: error: invalid name for anchor: "123" - * - ^ -AnchorTest.java:57: error: anchor already defined: "123" - * +AnchorTest.java:30: error: invalid name for anchor: "123 " + * ^ -AnchorTest.java:62: error: no value given for anchor +AnchorTest.java:35: error: no value given for anchor * ^ -AnchorTest.java:74: error: anchor already defined: "foo" +AnchorTest.java:47: error: anchor already defined: "foo" *

      text

      ^ -AnchorTest.java:79: error: invalid name for anchor: "" +AnchorTest.java:52: error: invalid name for anchor: "" *

      text

      ^ -AnchorTest.java:79: error: anchor already defined: "" +AnchorTest.java:52: error: anchor already defined: "" *

      text

      ^ -AnchorTest.java:84: error: invalid name for anchor: "123" - *

      text

      +AnchorTest.java:57: error: invalid name for anchor: "123 " + *

      text

      ^ -AnchorTest.java:84: error: anchor already defined: "123" - *

      text

      +AnchorTest.java:57: error: anchor already defined: "123 " + *

      text

      ^ -AnchorTest.java:89: error: no value given for anchor +AnchorTest.java:62: error: no value given for anchor *

      text

      ^ -16 errors +10 errors diff --git a/test/langtools/tools/doclint/AnchorTest2.java b/test/langtools/tools/doclint/AnchorTest2.java index 79b668677f1..ac827032213 100644 --- a/test/langtools/tools/doclint/AnchorTest2.java +++ b/test/langtools/tools/doclint/AnchorTest2.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8020313 + * @bug 8020313 8247957 * @summary doclint doesn't reset HTML anchors correctly * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester @@ -10,12 +10,12 @@ /** */ public class AnchorTest2 { - /** */ + /** */ public void a_name_AnchorTest2() { } - /** */ + /** */ public void a_name_AnchorTest2_already_defined() { } - /** */ + /** */ public void a_name_AnchorTest2a_defined_in_other_file() { } } diff --git a/test/langtools/tools/doclint/AnchorTest2.out b/test/langtools/tools/doclint/AnchorTest2.out index 755e6073eb6..b74020b560a 100644 --- a/test/langtools/tools/doclint/AnchorTest2.out +++ b/test/langtools/tools/doclint/AnchorTest2.out @@ -1,4 +1,4 @@ AnchorTest2.java:16: error: anchor already defined: "AnchorTest2" - /** */ + /** */ ^ 1 error diff --git a/test/langtools/tools/doclint/AnchorTest2a.java b/test/langtools/tools/doclint/AnchorTest2a.java index 3a197138931..984f60d7e0f 100644 --- a/test/langtools/tools/doclint/AnchorTest2a.java +++ b/test/langtools/tools/doclint/AnchorTest2a.java @@ -1,7 +1,7 @@ /* /nodynamiccopyright/ */ /** - * + * */ public class AnchorTest2a { } diff --git a/test/langtools/tools/doclint/EmptyHtmlTest.java b/test/langtools/tools/doclint/EmptyHtmlTest.java index 7b07fa58825..f9df8c61cd3 100644 --- a/test/langtools/tools/doclint/EmptyHtmlTest.java +++ b/test/langtools/tools/doclint/EmptyHtmlTest.java @@ -102,6 +102,9 @@ void testInline(Path base, Class type) throws Exception { case "LiteralTree" -> test(d, type, "{@literal abc}"); + case "ReturnTree" -> + test(d, type, "{@return abc}"); + case "SummaryTree" -> test(d, type, "{@summary First sentence.}"); diff --git a/test/langtools/tools/doclint/EndTagsTest.java b/test/langtools/tools/doclint/EndTagsTest.java index ad2d1cebc68..ef5ca8bf400 100644 --- a/test/langtools/tools/doclint/EndTagsTest.java +++ b/test/langtools/tools/doclint/EndTagsTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8006236 + * @bug 8006236 8247957 * @summary doclint: structural issue hidden * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester @@ -10,10 +10,10 @@ /** */ public class EndTagsTest { - /**

      text image

      */ + /**

      text image

      */ public void valid_all() { } - /**

      text image */ + /**

      text image */ public void valid_omit_optional_close() { } /** */ diff --git a/test/langtools/tools/doclint/HtmlAttrsTest.java b/test/langtools/tools/doclint/HtmlAttrsTest.java index 3067e7b6050..f90b3f8461b 100644 --- a/test/langtools/tools/doclint/HtmlAttrsTest.java +++ b/test/langtools/tools/doclint/HtmlAttrsTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 + * @bug 8004832 8258916 8247957 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester @@ -24,5 +24,11 @@ public void obsolete() { } * text */ public void obsolete_use_css() { } + + /** + * multi-line mailto nobody + */ + public void multiline_mailto() { } } diff --git a/test/langtools/tools/doclint/HtmlAttrsTest.out b/test/langtools/tools/doclint/HtmlAttrsTest.out index 889d99ed446..59b3294a00f 100644 --- a/test/langtools/tools/doclint/HtmlAttrsTest.out +++ b/test/langtools/tools/doclint/HtmlAttrsTest.out @@ -1,12 +1,11 @@ HtmlAttrsTest.java:14: error: unknown attribute: xyz *

      text

      ^ -HtmlAttrsTest.java:19: warning: attribute obsolete: name +HtmlAttrsTest.java:19: error: attribute not supported in HTML5: name * alt ^ -HtmlAttrsTest.java:24: warning: attribute obsolete, use CSS instead: size +HtmlAttrsTest.java:24: error: tag not supported in HTML5: font * text - ^ -1 error -2 warnings + ^ +3 errors diff --git a/test/langtools/tools/doclint/HtmlTagsTest.java b/test/langtools/tools/doclint/HtmlTagsTest.java index 8f1926cf17a..d8b033d2fbb 100644 --- a/test/langtools/tools/doclint/HtmlTagsTest.java +++ b/test/langtools/tools/doclint/HtmlTagsTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 + * @bug 8004832 8247957 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester diff --git a/test/langtools/tools/doclint/HtmlTagsTest.out b/test/langtools/tools/doclint/HtmlTagsTest.out index 9e0b22de3dc..66d80e365e6 100644 --- a/test/langtools/tools/doclint/HtmlTagsTest.out +++ b/test/langtools/tools/doclint/HtmlTagsTest.out @@ -7,9 +7,6 @@ HtmlTagsTest.java:14: error: unknown tag: xyz HtmlTagsTest.java:19: error: unknown tag: xyz *
      ^ -HtmlTagsTest.java:24: error: self-closing element not allowed - *
      - ^ HtmlTagsTest.java:29: error: element not allowed in documentation comments: * ^ @@ -43,5 +40,5 @@ HtmlTagsTest.java:60: error: text not allowed in
        element HtmlTagsTest.java:65: error: tag not allowed here: *
          text
        • ...
        ^ -14 errors +13 errors 1 warning diff --git a/test/langtools/tools/doclint/anchorTests/p/Test.java b/test/langtools/tools/doclint/anchorTests/p/Test.java index bc734c9eb5b..a46f994cce1 100644 --- a/test/langtools/tools/doclint/anchorTests/p/Test.java +++ b/test/langtools/tools/doclint/anchorTests/p/Test.java @@ -1,5 +1,5 @@ /* @test /nodynamiccopyright/ - * @bug 8025246 + * @bug 8025246 8247957 * @summary doclint is showing error on anchor already defined when it's not * @library ../.. * @modules jdk.javadoc/jdk.javadoc.internal.doclint @@ -11,43 +11,43 @@ package p; /** - * dupTest - * dupTest again + * dupTest + * dupTest again * - * dupTestField - * dupTestMethod + * dupTestField + * dupTestMethod - * okClass - * okField - * okMethod + * okClass + * okField + * okMethod */ public class Test { - /** dupTestField again */ + /** dupTestField again */ public int f; - /** dupTestMethod again */ + /** dupTestMethod again */ public void m() { } /** - * dupNested - * dupNested again - * dupNestedField - * dupNestedMethod + * dupNested + * dupNested again + * dupNestedField + * dupNestedMethod * - * okClass again + * okClass again */ public class Nested { /** - * dupNestedField + * dupNestedField * - * okField again + * okField again */ public int f; /** - * dupNestedMethod + * dupNestedMethod * - * okMethod again + * okMethod again */ public void m() { } } diff --git a/test/langtools/tools/doclint/anchorTests/p/Test.out b/test/langtools/tools/doclint/anchorTests/p/Test.out index 3448c423e98..e55d25aaf3d 100644 --- a/test/langtools/tools/doclint/anchorTests/p/Test.out +++ b/test/langtools/tools/doclint/anchorTests/p/Test.out @@ -1,19 +1,19 @@ Test.java:15: error: anchor already defined: "dupTest" - * dupTest again + * dupTest again ^ Test.java:25: error: anchor already defined: "dupTestField" - /** dupTestField again */ + /** dupTestField again */ ^ Test.java:28: error: anchor already defined: "dupTestMethod" - /** dupTestMethod again */ + /** dupTestMethod again */ ^ Test.java:33: error: anchor already defined: "dupNested" - * dupNested again + * dupNested again ^ Test.java:41: error: anchor already defined: "dupNestedField" - * dupNestedField + * dupNestedField ^ Test.java:48: error: anchor already defined: "dupNestedMethod" - * dupNestedMethod + * dupNestedMethod ^ 6 errors diff --git a/test/langtools/tools/doclint/anchorTests/p/package-info.java b/test/langtools/tools/doclint/anchorTests/p/package-info.java index 9a586ad6af0..75915015506 100644 --- a/test/langtools/tools/doclint/anchorTests/p/package-info.java +++ b/test/langtools/tools/doclint/anchorTests/p/package-info.java @@ -1,5 +1,5 @@ /* @test /nodynamiccopyright/ - * @bug 8025246 + * @bug 8025246 8247957 * @summary doclint is showing error on anchor already defined when it's not * @library ../.. * @modules jdk.javadoc/jdk.javadoc.internal.doclint @@ -9,8 +9,10 @@ */ /** - * here - * here again + * here + * here again + * obsolete anchor + * obsolete anchor again */ package p; diff --git a/test/langtools/tools/doclint/anchorTests/p/package-info.javac.out b/test/langtools/tools/doclint/anchorTests/p/package-info.javac.out index f6b8948560d..6edee352de8 100644 --- a/test/langtools/tools/doclint/anchorTests/p/package-info.javac.out +++ b/test/langtools/tools/doclint/anchorTests/p/package-info.javac.out @@ -1,2 +1,4 @@ package-info.java:13:7: compiler.err.proc.messager: anchor already defined: "here" -1 error +package-info.java:14:7: compiler.err.proc.messager: attribute not supported in HTML5: name +package-info.java:15:7: compiler.err.proc.messager: attribute not supported in HTML5: name +3 errors diff --git a/test/langtools/tools/doclint/anchorTests/p/package-info.out b/test/langtools/tools/doclint/anchorTests/p/package-info.out index 4eaa98adc9c..1594f466538 100644 --- a/test/langtools/tools/doclint/anchorTests/p/package-info.out +++ b/test/langtools/tools/doclint/anchorTests/p/package-info.out @@ -1,4 +1,10 @@ package-info.java:13: error: anchor already defined: "here" - * here again + * here again ^ -1 error +package-info.java:14: error: attribute not supported in HTML5: name + * obsolete anchor + ^ +package-info.java:15: error: attribute not supported in HTML5: name + * obsolete anchor again + ^ +3 errors diff --git a/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.java b/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.java index 21da610ff31..4e699232de2 100644 --- a/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.java +++ b/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.java @@ -1,14 +1,11 @@ /* * @test /nodynamiccopyright/ - * @bug 8072945 + * @bug 8072945 8247957 * @summary test tags and attributes specific to the output HTML version * @library .. * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester - * @run main DocLintTester -XhtmlVersion:html5 -ref HtmlVersionTagsAttrsTestHtml5.out HtmlVersionTagsAttrsTest.java - * @run main DocLintTester -XhtmlVersion:html4 -ref HtmlVersionTagsAttrsTestHtml4.out HtmlVersionTagsAttrsTest.java - * @run main DocLintTester -badargs -XhtmlVersion: HtmlVersionTagsAttrsTest.java - * @run main DocLintTester -ref HtmlVersionTagsAttrsTestHtml4.out HtmlVersionTagsAttrsTest.java + * @run main DocLintTester -Xmaxerrs 200 -ref HtmlVersionTagsAttrsTest.out HtmlVersionTagsAttrsTest.java */ /** @@ -73,7 +70,7 @@ public class HtmlVersionTagsAttrsTest { * Test border * */ - public void SupportedAttrs_in_html4_not_in_html5() { } + public void notSupportedAttrs_html5() { } /** *
          @@ -88,7 +85,7 @@ public void SupportedAttrs_in_html4_not_in_html5() { } *

          Label test

          *
      */ - public void SupportedAttrs_in_html5_not_in_html4() { } + public void SupportedAttrs_html5() { } /** *

      Bigger text test

      @@ -156,7 +153,7 @@ public void notSupportedTags_html5() { } *

      Test current time is at night

      *

      Test WBR text

      */ - public void SupportedTags_in_html5_not_in_html4() { } + public void SupportedTags_html5() { } /** *
      diff --git a/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTestHtml5.out b/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.out similarity index 65% rename from test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTestHtml5.out rename to test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.out index 9c51141bd5a..69b31d53831 100644 --- a/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTestHtml5.out +++ b/test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.out @@ -1,299 +1,314 @@ -HtmlVersionTagsAttrsTest.java:19: error: attribute not supported in HTML5: rev +HtmlVersionTagsAttrsTest.java:16: error: attribute not supported in HTML5: rev * Help Page ^ -HtmlVersionTagsAttrsTest.java:20: error: attribute not supported in HTML5: charset +HtmlVersionTagsAttrsTest.java:17: error: attribute not supported in HTML5: charset * Test page ^ -HtmlVersionTagsAttrsTest.java:21: error: attribute not supported in HTML5: shape +HtmlVersionTagsAttrsTest.java:18: error: attribute not supported in HTML5: shape * Location ^ -HtmlVersionTagsAttrsTest.java:21: error: attribute not supported in HTML5: coords +HtmlVersionTagsAttrsTest.java:18: error: attribute not supported in HTML5: coords * Location ^ -HtmlVersionTagsAttrsTest.java:22: error: attribute not supported in HTML5: name +HtmlVersionTagsAttrsTest.java:19: error: attribute not supported in HTML5: name * alt ^ -HtmlVersionTagsAttrsTest.java:24: error: attribute not supported in HTML5: axis +HtmlVersionTagsAttrsTest.java:21: error: attribute not supported in HTML5: axis * Description ^ -HtmlVersionTagsAttrsTest.java:25: error: attribute not supported in HTML5: axis +HtmlVersionTagsAttrsTest.java:22: error: attribute not supported in HTML5: axis * Axis_Test ^ -HtmlVersionTagsAttrsTest.java:25: error: attribute not supported in HTML5: abbr +HtmlVersionTagsAttrsTest.java:22: error: attribute not supported in HTML5: abbr * Axis_Test ^ -HtmlVersionTagsAttrsTest.java:25: error: attribute not supported in HTML5: scope +HtmlVersionTagsAttrsTest.java:22: error: attribute not supported in HTML5: scope * Axis_Test ^ -HtmlVersionTagsAttrsTest.java:26: error: no summary or caption for table +HtmlVersionTagsAttrsTest.java:23: error: no caption for table * ^ -HtmlVersionTagsAttrsTest.java:27: error: attribute not supported in HTML5: summary +HtmlVersionTagsAttrsTest.java:24: error: attribute not supported in HTML5: summary *
      Test Row
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: bgcolor +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: bgcolor *
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: cellpadding +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: cellpadding *
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: cellspacing +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: cellspacing *
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: frame +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: frame *
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: rules +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: rules *
      ^ -HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:26: error: attribute not supported in HTML5: width *
      ^ -HtmlVersionTagsAttrsTest.java:30: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:27: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:32: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:32: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:32: error: attribute not supported in HTML5: valign +HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: valign * ^ -HtmlVersionTagsAttrsTest.java:32: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: width * ^ -HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:30: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: valign +HtmlVersionTagsAttrsTest.java:30: error: attribute not supported in HTML5: valign * ^ -HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:30: error: attribute not supported in HTML5: width * ^ -HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:31: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:31: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:31: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:36: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:36: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:36: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:37: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:33: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:37: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:37: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:37: error: attribute not supported in HTML5: bgcolor +HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: bgcolor * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:34: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: bgcolor +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: bgcolor * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: height +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: height * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: width * ^ -HtmlVersionTagsAttrsTest.java:38: error: attribute not supported in HTML5: nowrap +HtmlVersionTagsAttrsTest.java:35: error: attribute not supported in HTML5: nowrap * ^ -HtmlVersionTagsAttrsTest.java:42: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:39: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:42: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:39: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:42: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:39: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:48: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:39: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:45: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:48: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:45: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:48: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:45: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:45: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: align * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: char +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: char * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: charoff +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: charoff * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: bgcolor +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: bgcolor * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: height +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: height * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: valign + * + ^ +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: width * ^ -HtmlVersionTagsAttrsTest.java:50: error: attribute not supported in HTML5: nowrap +HtmlVersionTagsAttrsTest.java:47: error: attribute not supported in HTML5: nowrap * ^ -HtmlVersionTagsAttrsTest.java:55: error: attribute not supported in HTML5: clear +HtmlVersionTagsAttrsTest.java:52: error: attribute not supported in HTML5: clear *
      ^ -HtmlVersionTagsAttrsTest.java:56: error: attribute not supported in HTML5: compact +HtmlVersionTagsAttrsTest.java:53: error: attribute not supported in HTML5: compact *
        ^ -HtmlVersionTagsAttrsTest.java:60: error: attribute not supported in HTML5: type +HtmlVersionTagsAttrsTest.java:57: error: attribute not supported in HTML5: type *
          ^ -HtmlVersionTagsAttrsTest.java:60: error: attribute not supported in HTML5: compact +HtmlVersionTagsAttrsTest.java:57: error: attribute not supported in HTML5: compact *
            ^ -HtmlVersionTagsAttrsTest.java:61: error: attribute not supported in HTML5: type +HtmlVersionTagsAttrsTest.java:58: error: attribute not supported in HTML5: type *
          • Test list
          • ^ -HtmlVersionTagsAttrsTest.java:64: error: attribute not supported in HTML5: compact +HtmlVersionTagsAttrsTest.java:61: error: attribute not supported in HTML5: compact *
            ^ -HtmlVersionTagsAttrsTest.java:68: error: attribute not supported in HTML5: hspace +HtmlVersionTagsAttrsTest.java:65: error: attribute not supported in HTML5: hspace * imgTest ^ -HtmlVersionTagsAttrsTest.java:68: error: attribute not supported in HTML5: vspace +HtmlVersionTagsAttrsTest.java:65: error: attribute not supported in HTML5: vspace * imgTest ^ -HtmlVersionTagsAttrsTest.java:68: error: attribute not supported in HTML5: border +HtmlVersionTagsAttrsTest.java:65: error: attribute not supported in HTML5: border * imgTest ^ -HtmlVersionTagsAttrsTest.java:69: error: attribute not supported in HTML5: size +HtmlVersionTagsAttrsTest.java:66: error: attribute not supported in HTML5: size *
            ^ -HtmlVersionTagsAttrsTest.java:69: error: attribute not supported in HTML5: noshade +HtmlVersionTagsAttrsTest.java:66: error: attribute not supported in HTML5: noshade *
            ^ -HtmlVersionTagsAttrsTest.java:70: error: attribute not supported in HTML5: width +HtmlVersionTagsAttrsTest.java:67: error: attribute not supported in HTML5: width *
            Test Pre
            ^ -HtmlVersionTagsAttrsTest.java:71: error: attribute not supported in HTML5: name +HtmlVersionTagsAttrsTest.java:68: error: attribute not supported in HTML5: name * Anchor Test ^ -HtmlVersionTagsAttrsTest.java:72: error: attribute border for table only accepts "" or "1", use CSS instead: BORDER +HtmlVersionTagsAttrsTest.java:69: error: attribute "border" for table only accepts "" or "1": BORDER *
      Test table, caption, col, colgroup, tbody, ^ -HtmlVersionTagsAttrsTest.java:32: error: attribute not supported in HTML5: align +HtmlVersionTagsAttrsTest.java:29: error: attribute not supported in HTML5: align *
      HeadCol1HeadCol1HeadCol1HeadCol1HeadCol1HeadCol1HeadCol1HeadCol1
      BodyCol1BodyCol1BodyCol1BodyCol1BodyCol1BodyCol1BodyCol1BodyCol1
      ^ -HtmlVersionTagsAttrsTest.java:74: error: no summary or caption for table +HtmlVersionTagsAttrsTest.java:71: error: no caption for table *
      ^ -HtmlVersionTagsAttrsTest.java:94: error: tag not supported in the generated HTML version: big +HtmlVersionTagsAttrsTest.java:91: error: tag not supported in HTML5: big *

      Bigger text test

      ^ -HtmlVersionTagsAttrsTest.java:94: warning: empty

      tag +HtmlVersionTagsAttrsTest.java:91: warning: empty

      tag *

      Bigger text test

      ^ -HtmlVersionTagsAttrsTest.java:95: error: tag not supported in the generated HTML version: center +HtmlVersionTagsAttrsTest.java:92: error: tag not supported in HTML5: center *
      Center text test
      ^ -HtmlVersionTagsAttrsTest.java:96: error: tag not supported in the generated HTML version: font +HtmlVersionTagsAttrsTest.java:93: error: tag not supported in HTML5: font * Font test ^ -HtmlVersionTagsAttrsTest.java:96: error: attribute not supported in HTML5: size - * Font test - ^ -HtmlVersionTagsAttrsTest.java:97: error: tag not supported in the generated HTML version: strike +HtmlVersionTagsAttrsTest.java:94: error: tag not supported in HTML5: strike *

      Text strike

      ^ -HtmlVersionTagsAttrsTest.java:98: error: tag not supported in the generated HTML version: tt +HtmlVersionTagsAttrsTest.java:95: error: tag not supported in HTML5: tt *

      Teletype text

      ^ -HtmlVersionTagsAttrsTest.java:98: warning: empty

      tag +HtmlVersionTagsAttrsTest.java:95: warning: empty

      tag *

      Teletype text

      ^ -HtmlVersionTagsAttrsTest.java:100: error: unknown tag: hgroup +HtmlVersionTagsAttrsTest.java:97: error: unknown tag: hgroup *
      ^ -HtmlVersionTagsAttrsTest.java:103: error: unknown tag: hgroup +HtmlVersionTagsAttrsTest.java:100: error: unknown tag: hgroup *
      ^ -HtmlVersionTagsAttrsTest.java:106: error: unknown tag: details +HtmlVersionTagsAttrsTest.java:103: error: unknown tag: details *
      ^ -HtmlVersionTagsAttrsTest.java:107: error: unknown tag: summary +HtmlVersionTagsAttrsTest.java:104: error: unknown tag: summary * Summary ^ -HtmlVersionTagsAttrsTest.java:107: error: unknown tag: summary +HtmlVersionTagsAttrsTest.java:104: error: unknown tag: summary * Summary ^ -HtmlVersionTagsAttrsTest.java:109: error: unknown tag: details +HtmlVersionTagsAttrsTest.java:106: error: unknown tag: details *
      ^ -HtmlVersionTagsAttrsTest.java:132: error: element not allowed in documentation comments:
      +HtmlVersionTagsAttrsTest.java:129: error: element not allowed in documentation comments:
      *
      ^ -HtmlVersionTagsAttrsTest.java:164: error: heading not found for
      +HtmlVersionTagsAttrsTest.java:161: error: heading not found for
      *
      ^ -HtmlVersionTagsAttrsTest.java:167: error: heading not found for +HtmlVersionTagsAttrsTest.java:164: error: heading not found for * ^ -HtmlVersionTagsAttrsTest.java:169: error: tag not allowed here:
      +HtmlVersionTagsAttrsTest.java:166: error: tag not allowed here:
      *
      ^ -HtmlVersionTagsAttrsTest.java:172: error: tag not allowed here: