diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 9b36f8e7a3..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -cache: - - C:\Users\appveyor\.m2 -> **\pom.xml - -install: - - mkdir .jdk - - curl -L "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?jdk_version=17&ext=zip&os=windows&arch=x86&hw_bitness=64&javafx=false&bundle_type=jdk" -o .jdk/jdk.zip - - unzip -d .jdk .jdk/jdk.zip - - mv .jdk/*/* .jdk - - .jdk\bin\java -version - - SET JAVA_HOME=%CD%\.jdk - -build_script: - # generation of Javadocs requires Java <= 6 (https://github.com/jacoco/jacoco/issues/110) - - mvn -V -B -e verify -Djdk.version=6 -Dbytecode.version=5 --toolchains=.travis\appveyor-toolchains.xml - -artifacts: - - path: jacoco\target\*.zip diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index da3f52c61f..f9ca32e443 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -40,15 +40,26 @@ jobs: JDK_VERSION: 19 JDK 20: JDK_VERSION: 20 - JDK 20 with ECJ: - JDK_VERSION: 20 - ECJ: true JDK 21: JDK_VERSION: 21 + JDK 21 with ECJ: + JDK_VERSION: 21 + ECJ: true JDK 22: JDK_VERSION: 22 + JDK 23: + JDK_VERSION: 23 + JDK 23 with ECJ: + JDK_VERSION: 23 + ECJ: true + JDK 24: + JDK_VERSION: 24 + JDK 25: + JDK_VERSION: 25 + JDK 26: + JDK_VERSION: 26 pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-24.04' steps: - bash: | set -e @@ -73,12 +84,6 @@ jobs: " > toolchains.xml displayName: Setup JDK - - bash: | - set -e - mkdir .maven - curl -L "https://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz" -o .maven/maven.tar.gz - tar -xzf .maven/maven.tar.gz -C .maven --strip-components 1 - displayName: Setup Maven - bash: | if [[ "$JDK_VERSION" -ge "17" ]]; then export JAVA_HOME=$PWD/.jdk @@ -86,17 +91,17 @@ jobs: export JAVA_HOME=$JAVA_HOME_17_X64 fi if [[ "$BUILD_SOURCEBRANCH" == "refs/heads/master" && "$JDK_VERSION" == "5" ]]; then - .maven/bin/mvn -V -B -e -f org.jacoco.build \ + ./mvnw -V -B -e --no-transfer-progress -f org.jacoco.build \ verify -Djdk.version=$JDK_VERSION -Dbytecode.version=$JDK_VERSION \ deploy:deploy -DdeployAtEnd \ --toolchains=toolchains.xml --settings=.azure-pipelines/maven-settings.xml elif [[ "$BUILD_SOURCEBRANCH" == "refs/heads/master" && "$JDK_VERSION" == "11" ]]; then - .maven/bin/mvn -V -B -e -f org.jacoco.build \ + ./mvnw -V -B -e --no-transfer-progress -f org.jacoco.build \ verify -Djdk.version=$JDK_VERSION -Dbytecode.version=$JDK_VERSION \ - sonar:sonar \ + sonar:sonar -Dsonar.scanner.skipJreProvisioning \ --toolchains=toolchains.xml --settings=.azure-pipelines/maven-settings.xml else - .maven/bin/mvn -V -B -e \ + ./mvnw -V -B -e --no-transfer-progress \ verify -Djdk.version=$JDK_VERSION -Dbytecode.version=$JDK_VERSION -Decj=${ECJ:-} \ --toolchains=toolchains.xml fi diff --git a/.azure-pipelines/maven-settings.xml b/.azure-pipelines/maven-settings.xml index dbce384964..2b7c4b2ab9 100644 --- a/.azure-pipelines/maven-settings.xml +++ b/.azure-pipelines/maven-settings.xml @@ -13,7 +13,7 @@ https://sonarcloud.io/ default - ${env.SONARQUBE_TOKEN} + ${env.SONARQUBE_TOKEN} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..db72d0172c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,66 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "component: build" + - package-ecosystem: "maven" + directory: "/org.jacoco.build" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "component: build" + allow: + - dependency-name: "org.apache.maven.plugins:*" + - dependency-name: "org.codehaus.mojo:*" + - dependency-name: "com.diffplug.spotless:*" + - dependency-name: "org.apache.felix:*" + - dependency-name: "org.sonarsource.scanner.maven:*" + ignore: + # It is known that upgrade from current version requires additional changes: + - dependency-name: "org.apache.maven.plugins:maven-plugin-plugin" + # Because of + # https://github.com/apache/maven-compiler-plugin/blob/maven-compiler-plugin-3.13.0/pom.xml#L71 + # https://github.com/codehaus-plexus/plexus-compiler/blob/plexus-compiler-2.15.0/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java#L149-L163 + # requires javac version to be at least 6: + - dependency-name: "org.apache.maven.plugins:maven-compiler-plugin" + versions: ">=3.13.0" + # Requires tests to be executed with Java 6: + - dependency-name: "org.apache.maven.plugins:maven-surefire-plugin" + versions: ">=2.20.0" + - package-ecosystem: "maven" + directory: "/org.jacoco.core" + schedule: + interval: "daily" + labels: + - "dependencies" + - "component: core" + allow: + - dependency-name: "org.ow2.asm:*" + - package-ecosystem: "maven" + directory: "/org.jacoco.core.test.validation.kotlin" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "component: test" + - "language: Kotlin" + allow: + - dependency-name: "org.jetbrains.kotlin:*" + - package-ecosystem: "maven" + directory: "/org.jacoco.core.test.validation.groovy" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "component: test" + - "language: Groovy" + allow: + - dependency-name: "org.codehaus.groovy:*" + ignore: + - dependency-name: "org.codehaus.groovy:*" + versions: ">=4.0.0" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..56de7f2ce4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,99 @@ +name: CI +on: + - push + - pull_request +jobs: + Linux: + strategy: + fail-fast: false + matrix: + include: + - jdk: 8 + - jdk: 8 + ecj: true + - jdk: 11 + - jdk: 11 + ecj: true + - jdk: 17 + - jdk: 17 + ecj: true + - jdk: 21 + - jdk: 21 + ecj: true + name: JDK ${{ matrix.jdk }}${{ matrix.ecj && ' with ECJ' || ''}} + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: 'zulu' + java-version: | + ${{ matrix.jdk }} + 17 + - name: 'Generate toolchains.xml' + env: + JDK_VERSION: ${{ matrix.jdk }} + JDK_HOME_VARIABLE_NAME: JAVA_HOME_${{ matrix.jdk }}_X64 + run: | + echo " + + + jdk + + $JDK_VERSION + $JDK_VERSION + + + ${!JDK_HOME_VARIABLE_NAME} + + + + " > toolchains.xml + - name: 'Build' + run: | + ./mvnw -V -B -e --no-transfer-progress \ + verify -Djdk.version=${{ matrix.jdk }} -Dbytecode.version=${{ matrix.jdk }} \ + ${{ matrix.ecj && '-Decj' || ''}} \ + --toolchains=toolchains.xml + Windows: + runs-on: windows-2022 + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: 'zulu' + java-version: | + 6 + 17 + - name: 'Generate toolchains.xml' + env: + JDK_VERSION: 6 + JDK_HOME_VARIABLE_NAME: JAVA_HOME_6_X64 + shell: bash + run: | + echo " + + + jdk + + $JDK_VERSION + $JDK_VERSION + + + ${!JDK_HOME_VARIABLE_NAME} + + + + " > toolchains.xml + - name: 'Build' + shell: bash + run: | + ./mvnw -V -B -e --no-transfer-progress \ + verify -Djdk.version=6 -Dbytecode.version=5 \ + --toolchains=toolchains.xml + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + id: artifact-upload-step + with: + name: jacoco + path: jacoco/target/*.zip + if-no-files-found: error diff --git a/.idea/codeInsightSettings.xml b/.idea/codeInsightSettings.xml new file mode 100644 index 0000000000..62ce4d17bd --- /dev/null +++ b/.idea/codeInsightSettings.xml @@ -0,0 +1,8 @@ + + + + + jdk.internal.* + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000..a74a84d3a0 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000..79ee123c2b --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/eclipseCodeFormatter.xml b/.idea/eclipseCodeFormatter.xml new file mode 100644 index 0000000000..992c75f5c6 --- /dev/null +++ b/.idea/eclipseCodeFormatter.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml new file mode 100644 index 0000000000..0502dcf71c --- /dev/null +++ b/.idea/externalDependencies.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..222cba3baf --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,4 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +distributionSha256Sum=0d7125e8c91097b36edb990ea5934e6c68b4440eef4ea96510a0f6815e7eeadb diff --git a/.travis/appveyor-toolchains.xml b/.travis/appveyor-toolchains.xml deleted file mode 100644 index 79fae7dd98..0000000000 --- a/.travis/appveyor-toolchains.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - jdk - - java16 - 6 - oracle - - - C:\Program Files\Java\jdk1.6.0 - - - - diff --git a/LICENSE.md b/LICENSE.md index 757dbf4afb..50688de56c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ License ======= -Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors +Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors The JaCoCo Java Code Coverage Library and all included documentation is made available by Mountainminds GmbH & Co. KG, Munich. Except indicated below, the diff --git a/README.md b/README.md index d2886deb6a..03681b257f 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,15 @@ JaCoCo Java Code Coverage Library ================================= [![Build Status](https://dev.azure.com/jacoco-org/JaCoCo/_apis/build/status/JaCoCo?branchName=master)](https://dev.azure.com/jacoco-org/JaCoCo/_build/latest?definitionId=1&branchName=master) -[![Build status](https://ci.appveyor.com/api/projects/status/g28egytv4tb898d7/branch/master?svg=true)](https://ci.appveyor.com/project/JaCoCo/jacoco/branch/master) [![Maven Central](https://img.shields.io/maven-central/v/org.jacoco/jacoco.svg)](http://search.maven.org/#search|ga|1|g%3Aorg.jacoco) JaCoCo is a free Java code coverage library distributed under the Eclipse Public -License. Check the [project homepage](http://www.jacoco.org/jacoco) -for downloads, documentation and feedback. +License. -Please use our [mailing list](https://groups.google.com/forum/?fromgroups=#!forum/jacoco) -for questions regarding JaCoCo which are not already covered by the -[extensive documentation](http://www.jacoco.org/jacoco/trunk/doc/). +## Starting Points -Note: We do not answer general questions in the project's issue tracker. Please use our [mailing list](https://groups.google.com/forum/?fromgroups=#!forum/jacoco) for this. -------------------------------------------------------------------------- +* I want to use JaCoCo → [Download](https://www.jacoco.org/jacoco/), [Maven](https://www.jacoco.org/jacoco/trunk/doc/maven.html), [Ant](https://www.jacoco.org/jacoco/trunk/doc/ant.html), [CLI](https://www.jacoco.org/jacoco/trunk/doc/cli.html), [Other](https://www.jacoco.org/jacoco/trunk/doc/integrations.html) +* I want to know how JaCoCo works → [Documentation](http://www.jacoco.org/jacoco/trunk/doc/) +* I have a question → [FAQ](http://www.jacoco.org/jacoco/trunk/doc/faq.html), [Documentation](http://www.jacoco.org/jacoco/trunk/doc/), [User Forum](https://groups.google.com/forum/?fromgroups=#!forum/jacoco) +* I found a bug → [Bug Report](https://github.com/jacoco/jacoco/issues/new/choose) +* I have an idea → [User Forum](https://groups.google.com/forum/?fromgroups=#!forum/jacoco), [Feature Request](https://github.com/jacoco/jacoco/issues/new/choose) diff --git a/jacoco-maven-plugin.test/it/it-check-fails-halt/pom.xml b/jacoco-maven-plugin.test/it/it-check-fails-halt/pom.xml index c7221a1eac..81656f0df3 100644 --- a/jacoco-maven-plugin.test/it/it-check-fails-halt/pom.xml +++ b/jacoco-maven-plugin.test/it/it-check-fails-halt/pom.xml @@ -1,6 +1,6 @@ - - - - - - - - diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/CreateExecFiles.java b/org.jacoco.ant.test/src/org/jacoco/ant/CreateExecFiles.java index ea8d5e0384..e1518f0afb 100644 --- a/org.jacoco.ant.test/src/org/jacoco/ant/CreateExecFiles.java +++ b/org.jacoco.ant.test/src/org/jacoco/ant/CreateExecFiles.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/DumpExecClassNames.java b/org.jacoco.ant.test/src/org/jacoco/ant/DumpExecClassNames.java index 227408315d..d86382f355 100644 --- a/org.jacoco.ant.test/src/org/jacoco/ant/DumpExecClassNames.java +++ b/org.jacoco.ant.test/src/org/jacoco/ant/DumpExecClassNames.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.java index 8a8e89ceba..44c2d11828 100644 --- a/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.java +++ b/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.xml index 6527da8936..8cc3a87dec 100644 --- a/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.xml +++ b/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskTest.xml @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/TestTarget.java b/org.jacoco.ant.test/src/org/jacoco/ant/TestTarget.java index c1b08d105f..9a65edd69a 100644 --- a/org.jacoco.ant.test/src/org/jacoco/ant/TestTarget.java +++ b/org.jacoco.ant.test/src/org/jacoco/ant/TestTarget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -21,8 +21,7 @@ /** * Simple test target for Java applications ant JUnit4 tests. To assert - * execution it creates an empty file target.txt in the working - * directory. + * execution it prints "Target executed". */ public class TestTarget { diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/empty.xml b/org.jacoco.ant.test/src/org/jacoco/ant/empty.xml new file mode 100644 index 0000000000..7a0414be50 --- /dev/null +++ b/org.jacoco.ant.test/src/org/jacoco/ant/empty.xml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/org.jacoco.ant/pom.xml b/org.jacoco.ant/pom.xml index 0cb2c10269..0913762486 100644 --- a/org.jacoco.ant/pom.xml +++ b/org.jacoco.ant/pom.xml @@ -1,6 +1,6 @@ - 9.6 + 9.9 1.9.16 2.0.28 - 4.13.1 + 4.13.2 20100721 @@ -237,7 +237,7 @@ org.apache.ant ant-antunit - 1.4 + 1.4.1 args4j @@ -302,61 +302,58 @@ org.apache.maven.plugins maven-assembly-plugin - 3.6.0 + 3.7.1 org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.5.0 org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + + 3.12.1 org.apache.maven.plugins maven-dependency-plugin - 3.6.0 + 3.9.0 org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.4 org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 + 3.6.1 org.apache.maven.plugins maven-install-plugin - 3.1.1 + 3.1.4 org.apache.maven.plugins maven-invoker-plugin - 2.0.0 + 3.9.1 org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.8 org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 org.apache.maven.plugins maven-javadoc-plugin - - 3.0.1 + 3.11.2 true false @@ -365,20 +362,12 @@ org.apache.maven.plugins maven-plugin-plugin - 3.6.0 - - - - org.ow2.asm - asm - 7.1 - - + 3.6.4 org.apache.maven.plugins maven-release-plugin - 2.1 + 3.1.1 true forked-path @@ -398,12 +387,12 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.0 + 3.6.0 org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 org.apache.maven.plugins @@ -414,28 +403,28 @@ org.apache.maven.plugins maven-site-plugin - 3.3 + 3.12.1 org.apache.maven.plugins maven-toolchains-plugin - 3.1.0 + 3.2.0 org.codehaus.mojo animal-sniffer-maven-plugin - 1.23 + 1.24 org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.1 org.codehaus.mojo buildnumber-maven-plugin - 3.1.0 + 3.2.1 org.codehaus.mojo @@ -445,7 +434,7 @@ org.codehaus.mojo exec-maven-plugin - 3.1.0 + 3.5.1 @@ -456,12 +445,17 @@ org.apache.felix maven-bundle-plugin - 3.5.1 + 6.0.0 com.diffplug.spotless spotless-maven-plugin - 2.37.0 + 3.0.0 + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 5.2.0.4988 @@ -526,8 +520,7 @@ 17 - - [3.5.4,3.8.2),(3.8.2,) + 3.9.11 The rules for repo1.maven.org are that pom.xml files should not include repository definitions. @@ -554,9 +547,13 @@ src/**/*.java - 4.28 + 4.30 ../org.jacoco.core/.settings/org.eclipse.jdt.core.prefs + + java,javax,org,com, + true + @@ -608,7 +605,7 @@ - + @@ -752,13 +749,61 @@ maven-jdk12 - [12,) + [12,20) 7 + + + maven-jdk20 + + [20,) + + + 8 + + + + + maven-jdk23 + + [23,) + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + + + + + + + + + intellij + + + idea.maven.embedder.version + + + + 5 + + + integration-tests @@ -794,134 +839,139 @@ - java14-bytecode + java18-bytecode bytecode.version - 14 + 18 - 13 - 13 + 17 + 17 - java15-bytecode + java19-bytecode bytecode.version - 15 + 19 - 13 - 13 + 17 + 17 - java16-bytecode + java20-bytecode bytecode.version - 16 + 20 - 13 - 13 + 17 + 17 - java17-bytecode + java21-bytecode bytecode.version - 17 + 21 - 13 - 13 + 17 + 17 - java18-bytecode + java22-bytecode bytecode.version - 18 + 22 - 13 - 13 + 17 + 17 - java19-bytecode + java23-bytecode bytecode.version - 19 + 23 - 13 - 13 + 17 + 17 - java20-bytecode + java24-bytecode bytecode.version - 20 + 24 - 13 - 13 + 17 + 17 - java21-bytecode + java25-bytecode bytecode.version - 21 + 25 - 13 - 13 + 17 + 17 - java22-bytecode + java26-bytecode bytecode.version - 22 + 26 - 13 - 13 + 17 + 17 @@ -931,6 +981,7 @@ ecj + true @@ -945,7 +996,7 @@ org.eclipse.jdt ecj - 3.34.0 + 3.41.0 org.codehaus.plexus @@ -1053,6 +1104,30 @@ + + jdk23 + + + jdk.version + 23 + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + + + + + + sources diff --git a/org.jacoco.cli.test/pom.xml b/org.jacoco.cli.test/pom.xml index 71e110325d..6243516031 100644 --- a/org.jacoco.cli.test/pom.xml +++ b/org.jacoco.cli.test/pom.xml @@ -1,6 +1,6 @@ + 3.0.25 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoCloneClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoCloneClassTest.java index 854429474c..fe6d25be72 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoCloneClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoCloneClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoExternalizeClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoExternalizeClassTest.java index 6af74993ea..d4f0e14c06 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoExternalizeClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyAutoExternalizeClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBindableClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBindableClassTest.java index ba17173094..cb63e40c8a 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBindableClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBindableClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBuilderClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBuilderClassTest.java index 3114641450..d99e0c8345 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBuilderClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyBuilderClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyCanonicalClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyCanonicalClassTest.java index 31da221b06..a8a6c509ee 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyCanonicalClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyCanonicalClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyDelegateClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyDelegateClassTest.java index a08dfcbb20..973475bcd9 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyDelegateClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyDelegateClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyImmutableClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyImmutableClassTest.java index f350a3907b..0a82f39caf 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyImmutableClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyImmutableClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyIndexPropertyClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyIndexPropertyClassTest.java index 970d558316..923bbc5aa5 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyIndexPropertyClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyIndexPropertyClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovySortableClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovySortableClassTest.java index 45d97f8b62..81cb462e98 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovySortableClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovySortableClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyVetoableClassTest.java b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyVetoableClassTest.java index 25e50d6a39..9812f5629c 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyVetoableClassTest.java +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/GroovyVetoableClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoCloneClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoCloneClassTarget.groovy index 97506d7d99..bcb40c65df 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoCloneClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoCloneClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoExternalizeClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoExternalizeClassTarget.groovy index 941e2ef6ed..d8d44a8dac 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoExternalizeClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyAutoExternalizeClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBindableClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBindableClassTarget.groovy index b375eb9b8c..74c9a43eed 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBindableClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBindableClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBuilderClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBuilderClassTarget.groovy index d3a5d9476d..f09a4983b6 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBuilderClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyBuilderClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyCanonicalClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyCanonicalClassTarget.groovy index 49de2eb762..6fcfa76361 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyCanonicalClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyCanonicalClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyDelegateClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyDelegateClassTarget.groovy index d020464699..5ff944655b 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyDelegateClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyDelegateClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyImmutableClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyImmutableClassTarget.groovy index 72131742da..654287c95c 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyImmutableClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyImmutableClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyIndexPropertyClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyIndexPropertyClassTarget.groovy index bac02bf3ed..2d0bbb759e 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyIndexPropertyClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyIndexPropertyClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovySortableClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovySortableClassTarget.groovy index 6ba9685353..56bfc3976e 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovySortableClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovySortableClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyVetoableClassTarget.groovy b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyVetoableClassTarget.groovy index 70820b2fe9..c63d1a312a 100644 --- a/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyVetoableClassTarget.groovy +++ b/org.jacoco.core.test.validation.groovy/src/org/jacoco/core/test/validation/groovy/targets/GroovyVetoableClassTarget.groovy @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.java14/pom.xml b/org.jacoco.core.test.validation.java14/pom.xml index 3eb2fc43a4..9dd3da4dfd 100644 --- a/org.jacoco.core.test.validation.java14/pom.xml +++ b/org.jacoco.core.test.validation.java14/pom.xml @@ -1,6 +1,6 @@ + 2.2.20 @@ -41,7 +42,12 @@ org.jetbrains.kotlinx kotlinx-coroutines-core - 1.0.1 + 1.8.0 + + + org.jetbrains.kotlinx + kotlinx-serialization-core-jvm + 1.6.3 @@ -58,8 +64,27 @@ compile + + + + -jvm-default + disable + + + + + kotlinx-serialization + + + + + org.jetbrains.kotlin + kotlin-maven-serialization + ${kotlin.version} + + diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCallableReferenceTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCallableReferenceTest.java index bdd998d658..ff9476f7c7 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCallableReferenceTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCallableReferenceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinControlStructuresTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinControlStructuresTest.java index cdafc126bc..bcc243fa4c 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinControlStructuresTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinControlStructuresTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineCallbackTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineCallbackTest.java new file mode 100644 index 0000000000..d779f14b44 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineCallbackTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinCoroutineCallbackTarget; + +/** + * Test of code coverage in {@link KotlinCoroutineCallbackTarget}. + */ +public class KotlinCoroutineCallbackTest extends ValidationTestBase { + + public KotlinCoroutineCallbackTest() { + super(KotlinCoroutineCallbackTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineInlineValueClassTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineInlineValueClassTest.java new file mode 100644 index 0000000000..f84c7ea5d4 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineInlineValueClassTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinCoroutineInlineValueClassTarget; + +/** + * Test of code coverage in {@link KotlinCoroutineInlineValueClassTarget}. + */ +public class KotlinCoroutineInlineValueClassTest extends ValidationTestBase { + + public KotlinCoroutineInlineValueClassTest() { + super(KotlinCoroutineInlineValueClassTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineSuspendingLambdaTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineSuspendingLambdaTest.java new file mode 100644 index 0000000000..3eebad5556 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineSuspendingLambdaTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinCoroutineSuspendingLambdaTarget; + +/** + * Test of code coverage in {@link KotlinCoroutineSuspendingLambdaTarget}. + */ +public class KotlinCoroutineSuspendingLambdaTest extends ValidationTestBase { + + public KotlinCoroutineSuspendingLambdaTest() { + super(KotlinCoroutineSuspendingLambdaTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineTest.java index 5cc865250f..74cd180bf1 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCoroutineTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCrossinlineTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCrossinlineTest.java new file mode 100644 index 0000000000..df788970de --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinCrossinlineTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import java.util.Arrays; +import java.util.Collection; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinCrossinlineTarget; + +/** + * Test of code coverage in {@link KotlinCrossinlineTarget}. + */ +public class KotlinCrossinlineTest extends ValidationTestBase { + + public KotlinCrossinlineTest() { + super(KotlinCrossinlineTarget.class); + } + + @Override + protected Collection additionalClassesForAnalysis() { + // Analyze SMAPs in non executed classes: + return Arrays.asList( + "org.jacoco.core.test.validation.kotlin.targets.KotlinCrossinlineTarget$example$1", + "org.jacoco.core.test.validation.kotlin.targets.KotlinCrossinlineTarget$example$1$1"); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDataClassTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDataClassTest.java index 7f0514e11d..64c7013eef 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDataClassTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDataClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java index 775f00a03b..dc6e49afd5 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultMethodsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultMethodsTest.java index 1a9b2224af..07363760b2 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultMethodsTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultMethodsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -24,10 +24,4 @@ public KotlinDefaultMethodsTest() { super(KotlinDefaultMethodsTarget.class); } - @Override - public void all_missed_instructions_should_have_line_number() { - // instructions without line numbers - // corresponding to non-executed default implementations - } - } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDelegatesTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDelegatesTest.java index 65750cc522..5c873c84b5 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDelegatesTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDelegatesTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinElvisOperatorTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinElvisOperatorTest.java index aaa6cbff81..5b53e642e9 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinElvisOperatorTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinElvisOperatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -16,7 +16,7 @@ import org.jacoco.core.test.validation.kotlin.targets.KotlinElvisOperatorTarget; /** - * Test of elvis operator. + * Test of code coverage in {@link KotlinElvisOperatorTarget}. */ public class KotlinElvisOperatorTest extends ValidationTestBase { diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinEnumTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinEnumTest.java new file mode 100644 index 0000000000..04630afa73 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinEnumTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinEnumTarget; + +/** + * Test of code coverage in {@link KotlinEnumTarget}. + */ +public class KotlinEnumTest extends ValidationTestBase { + + public KotlinEnumTest() { + super(KotlinEnumTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinExceptionsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinExceptionsTest.java new file mode 100644 index 0000000000..69f7e1b78e --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinExceptionsTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinExceptionsTarget; + +/** + * Test of code coverage in {@link KotlinExceptionsTarget}. + */ +public class KotlinExceptionsTest extends ValidationTestBase { + + public KotlinExceptionsTest() { + super(KotlinExceptionsTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineClassTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineClassTest.java new file mode 100644 index 0000000000..32c8a02fc0 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineClassTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinInlineClassTarget; + +/** + * Test of code coverage in {@link KotlinInlineClassTarget}. + */ +public class KotlinInlineClassTest extends ValidationTestBase { + + public KotlinInlineClassTest() { + super(KotlinInlineClassTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineReifiedTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineReifiedTest.java new file mode 100644 index 0000000000..16810585b4 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineReifiedTest.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashSet; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinInlineReifiedTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinInlineReifiedTarget}. + */ +public class KotlinInlineReifiedTest extends ValidationTestBase { + + public KotlinInlineReifiedTest() { + super(KotlinInlineReifiedTarget.class); + } + + @Test + public void compiler_should_generate_synthetic_method() { + final HashSet names = new HashSet(); + for (final Method method : KotlinInlineReifiedTarget.class + .getDeclaredMethods()) { + if (method.isSynthetic()) { + names.add(method.getName()); + } + } + + assertEquals(Collections.singleton("example"), names); + } + + @Test + public void test_method_count() { + assertMethodCount(2); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineTest.java index 0cb6fcc5b1..b28764113d 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -24,9 +24,4 @@ public KotlinInlineTest() { super(KotlinInlineTargetKt.class); } - @Override - public void all_missed_instructions_should_have_line_number() { - // missed instructions without line number in inline function - } - } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmNameTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmNameTest.java new file mode 100644 index 0000000000..4117fab294 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmNameTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinJvmNameTarget; + +/** + * Test of code coverage in {@link KotlinJvmNameTarget}. + */ +public class KotlinJvmNameTest extends ValidationTestBase { + + public KotlinJvmNameTest() { + super(KotlinJvmNameTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmOverloadsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmOverloadsTest.java new file mode 100644 index 0000000000..566135ab2f --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmOverloadsTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinJvmOverloadsTarget; + +/** + * Test of code coverage in {@link KotlinJvmOverloadsTarget}. + */ +public class KotlinJvmOverloadsTest extends ValidationTestBase { + + public KotlinJvmOverloadsTest() { + super(KotlinJvmOverloadsTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmSyntheticTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmSyntheticTest.java new file mode 100644 index 0000000000..686c56569e --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinJvmSyntheticTest.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashSet; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinJvmSyntheticTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinJvmSyntheticTarget}. + */ +public class KotlinJvmSyntheticTest extends ValidationTestBase { + + public KotlinJvmSyntheticTest() { + super(KotlinJvmSyntheticTarget.class); + } + + @Test + public void compiler_should_generate_synthetic_method() { + final HashSet names = new HashSet(); + for (final Method method : KotlinJvmSyntheticTarget.class + .getDeclaredMethods()) { + if (method.isSynthetic()) { + names.add(method.getName()); + } + } + + assertEquals(Collections.singleton("example"), names); + } + + @Test + public void test_method_count() { + assertMethodCount(2); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaExpressionsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaExpressionsTest.java index 5783febb8c..5b82e9c18b 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaExpressionsTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaExpressionsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaSerializableTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaSerializableTest.java new file mode 100644 index 0000000000..945e8a0e24 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaSerializableTest.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashSet; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinLambdaSerializableTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinLambdaSerializableTarget}. + */ +public class KotlinLambdaSerializableTest extends ValidationTestBase { + + public KotlinLambdaSerializableTest() { + super(KotlinLambdaSerializableTarget.class); + } + + @Test + public void compiler_should_generate_synthetic_deserializeLambda() { + final HashSet names = new HashSet(); + for (final Method method : KotlinLambdaSerializableTarget.class + .getDeclaredMethods()) { + if (method.isSynthetic()) { + names.add(method.getName()); + } + } + + assertEquals(Collections.singleton("$deserializeLambda$"), names); + } + + @Test + public void test_method_count() { + assertMethodCount(/* main + lambda */ 2); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLateinitTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLateinitTest.java index 468cf7b2a5..afb714cf8c 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLateinitTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLateinitTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -16,7 +16,7 @@ import org.jacoco.core.test.validation.kotlin.targets.KotlinLateinitTarget; /** - * Test of lateinit properties. + * Test of code coverage in {@link KotlinLateinitTarget}. */ public class KotlinLateinitTest extends ValidationTestBase { diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinNotNullOperatorTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinNotNullOperatorTest.java index b14f1d2cd2..dc79431a60 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinNotNullOperatorTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinNotNullOperatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCallOperatorTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCallOperatorTest.java index 4b1a6ab9fd..40ec55195f 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCallOperatorTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCallOperatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -16,7 +16,7 @@ import org.jacoco.core.test.validation.kotlin.targets.KotlinSafeCallOperatorTarget; /** - * Test of safe call operator. + * Test of code coverage in {@link KotlinSafeCallOperatorTarget}. */ public class KotlinSafeCallOperatorTest extends ValidationTestBase { diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCastTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCastTest.java index c239a3b072..002e1af66f 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCastTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSafeCastTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -13,7 +13,6 @@ package org.jacoco.core.test.validation.kotlin; import org.jacoco.core.test.validation.ValidationTestBase; -import org.jacoco.core.test.validation.kotlin.targets.KotlinElvisOperatorTarget; import org.jacoco.core.test.validation.kotlin.targets.KotlinSafeCastTarget; /** diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableEnumTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableEnumTest.java new file mode 100644 index 0000000000..4b32bee0d2 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableEnumTest.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableEnumTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinSerializableEnumTarget}. + */ +public class KotlinSerializableEnumTest extends ValidationTestBase { + + public KotlinSerializableEnumTest() { + super(KotlinSerializableEnumTarget.class); + } + + @Test + public void test_method_count() { + assertMethodCount(/* main + static initializer */2); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableObjectTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableObjectTest.java new file mode 100644 index 0000000000..5d42a805b2 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableObjectTest.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableObjectTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinSerializableObjectTarget}. + */ +public class KotlinSerializableObjectTest extends ValidationTestBase { + + public KotlinSerializableObjectTest() { + super(KotlinSerializableObjectTarget.class); + } + + @Test + public void test_method_count() { + assertMethodCount(/* main + static initializer */2); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableSealedTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableSealedTest.java new file mode 100644 index 0000000000..a4374ca2d3 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableSealedTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import java.util.Collection; +import java.util.Collections; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableSealedTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinSerializableSealedTarget}. + */ +public class KotlinSerializableSealedTest extends ValidationTestBase { + + public KotlinSerializableSealedTest() { + super(KotlinSerializableSealedTarget.class); + } + + @Override + protected Collection additionalClassesForAnalysis() { + return Collections.singletonList( + "org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableSealedTarget$Sealed$A$$serializer"); + } + + @Test + public void test_method_count() { + assertMethodCount( + /* main + static initializer + constructor + getter */4); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableTest.java new file mode 100644 index 0000000000..e6131254a6 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSerializableTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import java.util.Collection; +import java.util.Collections; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinSerializableTarget}. + */ +public class KotlinSerializableTest extends ValidationTestBase { + + public KotlinSerializableTest() { + super(KotlinSerializableTarget.class); + } + + @Override + protected Collection additionalClassesForAnalysis() { + return Collections.singletonList( + "org.jacoco.core.test.validation.kotlin.targets.KotlinSerializableTarget$Example$$serializer"); + } + + @Test + public void test_method_count() { + assertMethodCount( + /* main + 3 constructors + 3 getters + 1 method in companion */8); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSynchronizedTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSynchronizedTest.java new file mode 100644 index 0000000000..fbb79cda3e --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSynchronizedTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSynchronizedTarget; + +/** + * Test of code coverage in {@link KotlinSynchronizedTarget} + */ +public class KotlinSynchronizedTest extends ValidationTestBase { + + public KotlinSynchronizedTest() { + super(KotlinSynchronizedTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSyntheticAccessorsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSyntheticAccessorsTest.java new file mode 100644 index 0000000000..53e0e5d86b --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinSyntheticAccessorsTest.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashSet; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinSyntheticAccessorsTarget; +import org.junit.Test; + +/** + * Test of code coverage in {@link KotlinSyntheticAccessorsTarget}. + */ +public class KotlinSyntheticAccessorsTest extends ValidationTestBase { + + public KotlinSyntheticAccessorsTest() { + super(KotlinSyntheticAccessorsTarget.class); + } + + @Test + public void compiler_should_generate_synthetic_accessors() { + final HashSet names = new HashSet(); + for (final Method method : KotlinSyntheticAccessorsTarget.Outer.class + .getDeclaredMethods()) { + if (method.isSynthetic()) { + names.add(method.getName()); + } + } + + assertEquals(new HashSet( + Arrays.asList("access$getX", "access$getX$p", "access$setX$p")), + names); + } + + @Test + public void test_method_count() { + assertMethodCount(/* main + 2 in Outer + 2 in Inner */ 5); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java index 848eb51247..79ff96cf0c 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinUnsafeCastOperatorTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinUnsafeCastOperatorTest.java index 223e66c867..b55cc0a690 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinUnsafeCastOperatorTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinUnsafeCastOperatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenEnumTest.java similarity index 70% rename from org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java rename to org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenEnumTest.java index b0fb37a2ea..12083c70cd 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenEnumTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -13,15 +13,15 @@ package org.jacoco.core.test.validation.kotlin; import org.jacoco.core.test.validation.ValidationTestBase; -import org.jacoco.core.test.validation.kotlin.targets.KotlinWhenExpressionTarget; +import org.jacoco.core.test.validation.kotlin.targets.KotlinWhenEnumTarget; /** - * Test of when expressions. + * Test of code coverage in {@link KotlinWhenEnumTarget}. */ -public class KotlinWhenExpressionTest extends ValidationTestBase { +public class KotlinWhenEnumTest extends ValidationTestBase { - public KotlinWhenExpressionTest() { - super(KotlinWhenExpressionTarget.class); + public KotlinWhenEnumTest() { + super(KotlinWhenEnumTarget.class); } } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenSealedTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenSealedTest.java new file mode 100644 index 0000000000..7e35970cb8 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenSealedTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinWhenSealedTarget; + +/** + * Test of code coverage in {@link KotlinWhenSealedTarget}. + */ +public class KotlinWhenSealedTest extends ValidationTestBase { + + public KotlinWhenSealedTest() { + super(KotlinWhenSealedTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenStringTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenStringTest.java new file mode 100644 index 0000000000..a775b08b5f --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenStringTest.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinWhenStringTarget; + +/** + * Test of code coverage in {@link KotlinWhenStringTarget}. + */ +public class KotlinWhenStringTest extends ValidationTestBase { + + public KotlinWhenStringTest() { + super(KotlinWhenStringTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCallableReferenceTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCallableReferenceTarget.kt index e6df882495..3806a20a65 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCallableReferenceTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCallableReferenceTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinControlStructuresTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinControlStructuresTarget.kt index 6e0780c999..4574c4d999 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinControlStructuresTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinControlStructuresTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -112,6 +112,16 @@ object KotlinControlStructuresTarget { } + private fun whenImplicitElseNotExecuted(i: Int) { + + when (i) { // assertFullyCovered(1, 3) + 0 -> nop() // assertFullyCovered() + 1 -> nop() // assertFullyCovered() + 2 -> nop() // assertFullyCovered() + } + + } + private fun breakStatement() { while (true) { @@ -156,6 +166,9 @@ object KotlinControlStructuresTarget { missedForEachBlock() executedForEachBlock() whenExpression() + whenImplicitElseNotExecuted(0) + whenImplicitElseNotExecuted(1) + whenImplicitElseNotExecuted(2) breakStatement() continueStatement() implicitReturn() diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineCallbackTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineCallbackTarget.kt new file mode 100644 index 0000000000..5ec8d243b7 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineCallbackTarget.kt @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.coroutines.runBlocking +import org.jacoco.core.test.validation.targets.Stubs.nop +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine + +/** + * Test target containing invocations of [kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn] intrinsic + * inlined from [suspendCoroutine] which provides a way to + * [wrap any callback into a Kotlin suspending function](https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0164-coroutines.md#wrapping-callbacks). + * + * @see [kotlinx.coroutines.suspendCancellableCoroutine] + */ +object KotlinCoroutineCallbackTarget { + + suspend fun example() = + suspendCoroutine { continuation -> // assertFullyCovered() + continuation.resume(Unit) // assertFullyCovered() + } // assertFullyCovered() + + suspend fun withoutTailCallOptimization() { + suspendCoroutine { continuation -> // assertFullyCovered() + continuation.resume(Unit) // assertFullyCovered() + } // assertFullyCovered() + nop("tail") // assertFullyCovered() + } + + @JvmStatic + fun main(args: Array) { + runBlocking { + example() + withoutTailCallOptimization() + } + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineInlineValueClassTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineInlineValueClassTarget.kt new file mode 100644 index 0000000000..bca7c92d5c --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineInlineValueClassTarget.kt @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.coroutines.runBlocking +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target with invocation of suspending function that returns inline value class. + */ +object KotlinCoroutineInlineValueClassTarget { + + suspend fun suspensionPointReturningInlineValueClass() = InlineValueClass("") + + @JvmInline + value class InlineValueClass(val value: String) + + @JvmStatic + fun main(args: Array) { + runBlocking { // assertFullyCovered() + nop(suspensionPointReturningInlineValueClass()) // assertFullyCovered() + } // assertFullyCovered() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineSuspendingLambdaTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineSuspendingLambdaTarget.kt new file mode 100644 index 0000000000..a803f7f43b --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineSuspendingLambdaTarget.kt @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.coroutines.runBlocking + +/** + * Test target containing suspending lambdas. + */ +object KotlinCoroutineSuspendingLambdaTarget { + + private fun withParameter() { + fun exec(block: suspend (p: String) -> Unit): Unit = runBlocking { block("") } + fun noexec(block: suspend (p: String) -> Unit) = Unit + suspend fun suspensionPoint(p: String) = Unit + + exec { p -> // assertFullyCovered() + suspensionPoint(p) // assertFullyCovered() + } // assertFullyCovered() + + noexec { p -> // assertFullyCovered() + suspensionPoint(p) // assertNotCovered() + } // assertNotCovered() + + noexec { p -> suspensionPoint(p) } // assertPartlyCovered() + } + + @JvmStatic + fun main(args: Array) { + withParameter() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineTarget.kt index 9dad31cbcd..997229931c 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCoroutineTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -34,6 +34,12 @@ object KotlinCoroutineTarget { nop() // assertFullyCovered() } + private fun suspendingLambdaWithoutSuspensionPoints() { + runBlocking { // assertFullyCovered() + nop() // assertFullyCovered() + } // assertFullyCovered() + } + @JvmStatic fun main(args: Array) { @@ -45,6 +51,7 @@ object KotlinCoroutineTarget { suspendingFunctionWithTailCallOptimization() } // assertFullyCovered() + suspendingLambdaWithoutSuspensionPoints() } } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCrossinlineTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCrossinlineTarget.kt new file mode 100644 index 0000000000..fdd8cc18f9 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinCrossinlineTarget.kt @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target for `crossinline`. + */ +object KotlinCrossinlineTarget { + + inline fun example(crossinline lambda: () -> Unit): () -> Unit { // assertEmpty() + return { // assertFullyCovered() + requireCrossinline { lambda() } // assertFullyCovered() + } // assertFullyCovered() + } // assertEmpty() + + fun requireCrossinline(lambda: () -> Unit) = lambda() + + @JvmStatic + fun main(args: Array) { + + example { // assertFullyCovered() + nop() // assertFullyCovered() + }() // assertFullyCovered() + + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDataClassTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDataClassTarget.kt index 72833e601a..c459f1a06f 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDataClassTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDataClassTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt index d619bc3443..6001f0c048 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -35,6 +35,42 @@ object KotlinDefaultArgumentsTarget { constructor(a: Boolean, b: String = if (a) "a" else "b") : this() // assertFullyCovered(0, 2) } + class MoreThan32Parameters( // assertFullyCovered() + p1: String, // assertEmpty() + p2: String, // assertEmpty() + p3: String, // assertEmpty() + p4: String, // assertEmpty() + p5: String, // assertEmpty() + p6: String, // assertEmpty() + p7: String, // assertEmpty() + p8: String, // assertEmpty() + p9: String, // assertEmpty() + p10: String, // assertEmpty() + p11: String, // assertEmpty() + p12: String, // assertEmpty() + p13: String, // assertEmpty() + p14: String, // assertEmpty() + p15: String, // assertEmpty() + p16: String, // assertEmpty() + p17: String, // assertEmpty() + p18: String, // assertEmpty() + p19: String, // assertEmpty() + p20: String, // assertEmpty() + p21: String, // assertEmpty() + p22: String, // assertEmpty() + p23: String, // assertEmpty() + p24: String, // assertEmpty() + p25: String, // assertEmpty() + p26: String, // assertEmpty() + p27: String, // assertEmpty() + p28: String, // assertEmpty() + p29: String, // assertEmpty() + p30: String, // assertEmpty() + p31: String, // assertEmpty() + p32: String = "", // assertFullyCovered() + p33: String = "", // assertFullyCovered() + ) // assertFullyCovered() + @JvmStatic fun main(args: Array) { f(a = "a") @@ -52,6 +88,13 @@ object KotlinDefaultArgumentsTarget { Constructor(false) Constructor(true) + + MoreThan32Parameters( + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", + "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", + "31", + ) } } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultMethodsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultMethodsTarget.kt index 87fe4d2cec..782ff31535 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultMethodsTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultMethodsTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDelegatesTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDelegatesTarget.kt index 8895c023b2..fc70e4188a 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDelegatesTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDelegatesTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinElvisOperatorTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinElvisOperatorTarget.kt index ddc53a2c33..ee7b30d2e8 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinElvisOperatorTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinElvisOperatorTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -13,18 +13,57 @@ package org.jacoco.core.test.validation.kotlin.targets /** - * Test target for elvis operator. + * Test target for [elvis operator (`?:`)](https://kotlinlang.org/docs/null-safety.html#elvis-operator). */ object KotlinElvisOperatorTarget { - private fun example(x: String?): String { - return x ?: "" // assertFullyCovered(0, 2) + private fun elvis() { + fun nullOnly(a: String?): String = + a ?: "" // assertFullyCovered(1, 1) + + fun nonNullOnly(a: String?): String = + a ?: "" // assertPartlyCovered(1, 1) + + fun fullCoverage(a: String?): String = + a ?: "" // assertFullyCovered(0, 2) + + nullOnly(null) + nonNullOnly("") + fullCoverage(null) + fullCoverage("") + } + + private fun elvisChain() { + fun bothNull(a: String?, b: String?): String = + a ?: b ?: "" // assertFullyCovered(2, 2) + + fun secondNonNull(a: String?, b: String?): String = + a ?: b ?: "" // assertPartlyCovered(2, 2) + + fun firstNonNull(a: String?, b: String?): String = + a ?: b ?: "" // assertPartlyCovered(3, 1) + + fun firstOrSecondNonNull(a: String?, b: String?): String = + a ?: b ?: "" // assertPartlyCovered(1, 3) + + fun fullCoverage(a: String?, b: String?): String = + a ?: b ?: "" // assertFullyCovered(0, 4) + + bothNull(null, null) + secondNonNull(null, "") + firstNonNull("", null) + firstNonNull("", "") + firstOrSecondNonNull("", null) + firstOrSecondNonNull(null, "") + fullCoverage(null, null) + fullCoverage("", null) + fullCoverage(null, "") } @JvmStatic fun main(args: Array) { - example("") - example(null) + elvis() + elvisChain() } } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinEnumTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinEnumTarget.kt new file mode 100644 index 0000000000..5887eab348 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinEnumTarget.kt @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target for `enum class`. + */ +object KotlinEnumTarget { + + private enum class EnumClass { // assertEmpty() + E // assertFullyCovered() + } // assertEmpty() + + @JvmStatic + fun main(args: Array) { + nop(EnumClass.E) + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinExceptionsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinExceptionsTarget.kt new file mode 100644 index 0000000000..d07cec560a --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinExceptionsTarget.kt @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.* + +/** + * Test target with exception based control flow examples. + */ +object KotlinExceptionsTarget { + + private fun implicitArrayIndexOutOfBoundsException(a: Array) { + nop() // assertNotCovered() + a[0] // assertNotCovered() + nop() // assertNotCovered() + } + + private fun implicitException() { + nop() // assertFullyCovered() + ex() // assertNotCovered() + nop() // assertNotCovered() + } + + private fun explicitException() { + nop() // assertFullyCovered() + throw StubException() // assertFullyCovered() + } + + private fun noExceptionTryCatch() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + } catch (e: StubException) { // assertNotCovered() + nop() // assertNotCovered() + } // assertEmpty() + } + + private fun implicitExceptionTryCatch() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + ex() // assertNotCovered() + nop() // assertNotCovered() + } catch (e: StubException) { // assertFullyCovered() + nop() // assertFullyCovered() + } // assertEmpty() + } + + private fun explicitExceptionTryCatch() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + throw StubException() // assertFullyCovered() + } catch (e: StubException) { // assertFullyCovered() + nop() // assertFullyCovered() + } // assertEmpty() + } + + private fun noExceptionFinally() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + } finally { // assertEmpty() + nop() // assertFullyCovered() + } // assertEmpty() + } + + private fun implicitExceptionFinally() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + ex() // assertNotCovered() + nop() // assertNotCovered() + } finally { // assertEmpty() + nop() // assertFullyCovered() + } // assertEmpty() + } + + private fun explicitExceptionFinally() { + nop() // assertFullyCovered() + try { // assertFullyCovered() + nop() // assertFullyCovered() + throw StubException() // assertFullyCovered() + } finally { // assertEmpty() + nop() // assertFullyCovered() + } + } + + @JvmStatic + fun main(args: Array) { + try { + implicitArrayIndexOutOfBoundsException(arrayOf()) + } catch (_: ArrayIndexOutOfBoundsException) { + } + try { + implicitException() + } catch (_: StubException) { + } + try { + explicitException() + } catch (_: StubException) { + } + noExceptionTryCatch() + try { + implicitExceptionTryCatch() + } catch (_: StubException) { + } + try { + explicitExceptionTryCatch() + } catch (_: StubException) { + } + noExceptionFinally() + try { + implicitExceptionFinally() + } catch (_: StubException) { + } + try { + explicitExceptionFinally() + } catch (_: StubException) { + } + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineClassTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineClassTarget.kt new file mode 100644 index 0000000000..649c3b6cea --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineClassTarget.kt @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target for `inline class`. + */ +object KotlinInlineClassTarget { + + interface Base { + fun base() + } + + @JvmInline + value class I1(val value: String) : Base { // assertEmpty() + + init { // assertEmpty() + nop() // assertFullyCovered() + } // assertEmpty() + + constructor() : this("") { // assertFullyCovered() + nop() // assertFullyCovered() + } // assertEmpty() + + val length: Int // assertEmpty() + get() = value.length // assertFullyCovered() + + fun f(p: String) { // assertEmpty() + nop(p) // assertFullyCovered() + } // assertFullyCovered() + + fun f(p: I1) { // assertEmpty() + nop(p) // assertFullyCovered() + } // assertFullyCovered() + + override fun base() { // assertEmpty() + nop() // assertFullyCovered() + } // assertFullyCovered() + + } // assertEmpty() + + @JvmInline + value class I2(val value: String) { // assertEmpty() + + override fun toString(): String { // assertEmpty() + return "Value: $value" // assertNotCovered() + } // assertEmpty() + + } // assertEmpty() + + @JvmStatic + fun main(args: Array) { + val i = I1() + i.value + i.length + i.f("") + i.f(i) + i.base() + + I2("") + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineReifiedTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineReifiedTarget.kt new file mode 100644 index 0000000000..6b82357b9c --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineReifiedTarget.kt @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target containing `inline` function with + * [`reified` type parameter](https://kotlinlang.org/docs/inline-functions.html#reified-type-parameters). + */ +object KotlinInlineReifiedTarget { + + private inline fun example() { // assertEmpty() + nop(T::class) // assertFullyCovered() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + example() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineTarget.kt index 47f7131090..0adb2cd552 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -22,15 +22,15 @@ fun main(args: Array) { KotlinInlineTarget.main(args) } -inline fun inlined_top_level() { - nop() // assertNotCovered() -} +inline fun inlined_top_level() { // assertEmpty() + nop() // assertFullyCovered() +} // assertFullyCovered() object KotlinInlineTarget { - inline fun inlined() { - nop() // assertNotCovered() - } + inline fun inlined() { // assertEmpty() + nop() // assertFullyCovered() + } // assertFullyCovered() @JvmStatic fun main(args: Array) { diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmNameTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmNameTarget.kt new file mode 100644 index 0000000000..b647a2a27e --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmNameTarget.kt @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +@file:JvmName("KotlinJvmNameTarget") + +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +fun main(args: Array) { + nop() // assertFullyCovered() +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmOverloadsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmOverloadsTarget.kt new file mode 100644 index 0000000000..749ad7099a --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmOverloadsTarget.kt @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target containing [JvmOverloads]. + */ +object KotlinJvmOverloadsTarget { + + @JvmOverloads // assertEmpty() + fun example(p1: String = "p1", p2: String = "p2") { // assertFullyCovered() + nop(p1 + p2) // assertFullyCovered() + } // assertFullyCovered() + + private fun use() { // assertEmpty() + example() // assertFullyCovered() + } // assertFullyCovered() + + private fun useOneliner() = example() // assertFullyCovered() + + class Example @JvmOverloads constructor(p1: String = "p1", p2: String = "p2") { // assertFullyCovered() + constructor(p: Any) : this() // assertFullyCovered() + } + + @JvmStatic + fun main(args: Array) { + example() + example("") + example("", "") + + use() + useOneliner() + + Example() + Example("") + Example("", "") + + Example(Any()) + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmSyntheticTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmSyntheticTarget.kt new file mode 100644 index 0000000000..d96efc4833 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinJvmSyntheticTarget.kt @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target containing [JvmSynthetic] function. + */ +object KotlinJvmSyntheticTarget { + + @JvmSynthetic + private fun example() { // assertEmpty() + nop() // assertFullyCovered() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + example() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaExpressionsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaExpressionsTarget.kt index 53f8a9e0fc..9c668f6ece 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaExpressionsTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaExpressionsTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaSerializableTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaSerializableTarget.kt new file mode 100644 index 0000000000..3c6660aeef --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaSerializableTarget.kt @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.execSerializable +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target with [java.io.Serializable] lambda. + */ +object KotlinLambdaSerializableTarget { + + @JvmStatic + fun main(args: Array) { + + execSerializable { + nop() // assertFullyCovered() + } + + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLateinitTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLateinitTarget.kt index 950231a3d9..087d901be4 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLateinitTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLateinitTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -18,11 +18,35 @@ import org.jacoco.core.test.validation.targets.Stubs.nop * This test target is `lateinit` property. */ object KotlinLateinitTarget { - private lateinit var x: String + + class Example { + lateinit var publicMember: String // assertFullyCovered() + lateinit var publicGenericMember: T // assertFullyCovered() + private lateinit var privateMember: String // assertEmpty() + private lateinit var privateGenericMember: T // assertEmpty() + + fun init(value: T) { + publicMember = "" + publicGenericMember = value + privateMember = "" + privateGenericMember = value + } + + fun read() { + nop(publicMember) // assertFullyCovered() + nop(publicGenericMember) // assertFullyCovered() + nop(privateMember) // assertFullyCovered() + nop(privateGenericMember) // assertFullyCovered() + } + } @JvmStatic fun main(args: Array) { - x = "" - nop(x) // assertFullyCovered() + val e = Example() + e.init("") + e.read() + e.publicMember // assertFullyCovered() + e.publicGenericMember // assertFullyCovered() } + } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinNotNullOperatorTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinNotNullOperatorTarget.kt index dcea851f99..2e01c854da 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinNotNullOperatorTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinNotNullOperatorTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCallOperatorTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCallOperatorTarget.kt index a1b46130a0..a637175f24 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCallOperatorTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCallOperatorTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 @@ -12,19 +12,194 @@ *******************************************************************************/ package org.jacoco.core.test.validation.kotlin.targets +import org.jacoco.core.test.validation.targets.Stubs.nop +import org.jacoco.core.test.validation.targets.Stubs.StubException +import org.jacoco.core.test.validation.targets.Stubs.ex + /** - * Test target for safe call operator. + * Test target for [safe call operator (`?.`)](https://kotlinlang.org/docs/null-safety.html#safe-call-operator). */ object KotlinSafeCallOperatorTarget { - private fun example(x: String?): Int? { - return x?.length // assertFullyCovered(0, 2) + data class A(val b: B) + data class B(val c: String) + + private fun safeCall() { + fun nullOnly(b: B?): String? = + b?.c // assertPartlyCovered(1, 1) + + fun nonNullOnly(b: B?): String? = + b?.c // assertPartlyCovered(1, 1) + + fun fullCoverage(b: B?): String? = + b?.c // assertFullyCovered(0, 2) + + nullOnly(null) + nonNullOnly(B("")) + fullCoverage(null) + fullCoverage(B("")) + } + + private fun safeCallChain() { + fun nullOnly(a: A?): String? = + a?.b?.c // assertPartlyCovered(2, 2) + + fun nonNullOnly(a: A?): String? = + a?.b?.c // assertPartlyCovered(2, 2) + + fun fullCoverage(a: A?): String? = + a?.b?.c // assertFullyCovered(0, 4) + + nullOnly(null) + nonNullOnly(A(B(""))) + fullCoverage(null) + fullCoverage(A(B(""))) + } + + private fun safeCallChainMultiline() { + fun nullOnly(a: A?): String? = + a // assertNotCovered() + ?.b // assertPartlyCovered(1, 1) + ?.c // assertPartlyCovered(1, 1) + + fun nonNullOnly(a: A?): String? = + a // assertFullyCovered() + ?.b // assertPartlyCovered(1, 1) + ?.c // assertFullyCovered(1, 1) + + fun fullCoverage(a: A?): String? = + a // assertFullyCovered() + ?.b // assertFullyCovered(0, 2) + ?.c // assertFullyCovered(0, 2) + + nullOnly(null) + nonNullOnly(A(B(""))) + fullCoverage(null) + fullCoverage(A(B(""))) + } + + private fun safeCallChainMultiline2() { + fun nullOnly(a: A?): String? = + a?.also { // assertPartlyCovered(1, 1) + nop(it) // assertNotCovered() + }?.b?.c // assertPartlyCovered(1, 1) + + fun nonNullOnly(a: A?): String? = + a?.also { // assertPartlyCovered(1, 1) + nop(it) // assertFullyCovered() + }?.b?.c // assertFullyCovered(1, 1) + + fun fullCoverage(a: A?): String? = + a?.also { // assertFullyCovered(0, 2) + nop(it) // assertFullyCovered() + }?.b?.c // assertFullyCovered(0, 2) + + nullOnly(null) + nonNullOnly(A(B(""))) + fullCoverage(null) + fullCoverage(A(B(""))) + } + + private fun safeCallChainException() { + fun example(a: A?): String? = + a?.also { ex() }?.b?.c // assertPartlyCovered(3, 1) + + try { + example(A(B(""))) + } catch (_: StubException) { + } + } + + private fun safeCallFollowedByElvis() { + fun nullOnly(b: B?): String = + b?.c ?: "" // assertPartlyCovered(2, 2) + + fun nonNullOnly(b: B?): String = + b?.c ?: "" // assertPartlyCovered(2, 2) + + fun fullCoverage(b: B?): String = + b?.c ?: "" // assertFullyCovered(0, 4) + + nullOnly(null) + nonNullOnly(B("")) + fullCoverage(null) + fullCoverage(B("")) + } + + private fun safeCallFollowedByElvisMultiline() { + fun nullOnly(b: B?): String = + b // assertPartlyCovered(1, 1) + ?.c // assertPartlyCovered(1, 1) + ?: "" // assertFullyCovered() + + fun nonNullOnly(b: B?): String = + b // assertFullyCovered(1, 1) + ?.c // assertFullyCovered(1, 1) + ?: "" // assertPartlyCovered() + + fun fullCoverage(b: B?): String = + b // assertFullyCovered(0, 2) + ?.c // assertFullyCovered(0, 2) + ?: "" // assertFullyCovered() + + nullOnly(null) + nonNullOnly(B("")) + fullCoverage(null) + fullCoverage(B("")) + } + + private fun safeCallChainFollowedByElvis() { + fun nullOnly(a: A?): String = + a?.b?.c ?: "" // assertPartlyCovered(3, 3) + + fun nonNullOnly(a: A?): String = + a?.b?.c ?: "" // assertPartlyCovered(3, 3) + + fun fullCoverage(a: A?): String = + a?.b?.c ?: "" // assertFullyCovered(0, 6) + + nullOnly(null) + nonNullOnly(A(B(""))) + fullCoverage(null) + fullCoverage(A(B(""))) + } + + private fun safeCallChainFollowedByElvisMultiline() { + fun nullOnly(a: A?): String = + a // assertPartlyCovered(1, 1) + ?.b // assertPartlyCovered(1, 1) + ?.c // assertPartlyCovered(1, 1) + ?: "" // assertFullyCovered() + + fun nonNullOnly(a: A?): String = + a // assertFullyCovered(1, 1) + ?.b // assertFullyCovered(1, 1) + ?.c // assertFullyCovered(1, 1) + ?: "" // assertPartlyCovered() + + fun fullCoverage(a: A?): String = + a // assertFullyCovered(0, 2) + ?.b // assertFullyCovered(0, 2) + ?.c // assertFullyCovered(0, 2) + ?: "" // assertFullyCovered() + + nullOnly(null) + nonNullOnly(A(B(""))) + fullCoverage(null) + fullCoverage(A(B(""))) } @JvmStatic fun main(args: Array) { - example("") - example(null) + safeCall() + safeCallChain() + safeCallChainMultiline() + safeCallChainMultiline2() + safeCallChainException() + safeCallFollowedByElvis() + safeCallFollowedByElvisMultiline() + safeCallChainFollowedByElvis() + safeCallChainFollowedByElvisMultiline() } } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCastTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCastTarget.kt index 98a40e9d21..7a55eb2f49 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCastTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSafeCastTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableEnumTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableEnumTarget.kt new file mode 100644 index 0000000000..5cad0e605a --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableEnumTarget.kt @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.serialization.Serializable + +/** + * Test target with [Serializable] `enum class`. + */ +object KotlinSerializableEnumTarget { + + @Serializable // assertFullyCovered() + enum class E { // assertEmpty() + V // assertFullyCovered() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + E.V + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableObjectTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableObjectTarget.kt new file mode 100644 index 0000000000..72effef81c --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableObjectTarget.kt @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.serialization.Serializable + +/** + * Test target with [Serializable] `object`. + */ +object KotlinSerializableObjectTarget { + + @Serializable // assertFullyCovered() + private object Example { // assertEmpty() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + Example.toString() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableSealedTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableSealedTarget.kt new file mode 100644 index 0000000000..ce04755339 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableSealedTarget.kt @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.serialization.Serializable + +/** + * Test target with [Serializable] `sealed class`. + */ +object KotlinSerializableSealedTarget { + + @Serializable // assertFullyCovered() + private sealed class Sealed { // assertEmpty() + @Serializable // assertFullyCovered() + data class A( // assertFullyCovered() + val data: String // assertFullyCovered() + ): Sealed() // assertEmpty() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + Sealed.A("").data + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableTarget.kt new file mode 100644 index 0000000000..717e4ca325 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSerializableTarget.kt @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Test target with [Serializable] class. + */ +object KotlinSerializableTarget { + + @Serializable // assertFullyCovered() + data class Example( // assertFullyCovered() + @SerialName("d") val data: String // assertFullyCovered() + ) // assertEmpty() + + @Serializable(with = CustomSerializer::class) // assertFullyCovered() + data class ExampleWithCustomSerializer( // assertFullyCovered() + val data: String // assertFullyCovered() + ) // assertEmpty() + + object CustomSerializer : KSerializer { + override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Example", PrimitiveKind.STRING) + override fun serialize(encoder: Encoder, value: ExampleWithCustomSerializer) = encoder.encodeString(value.data) + override fun deserialize(decoder: Decoder): ExampleWithCustomSerializer = + ExampleWithCustomSerializer(decoder.decodeString()) + } + + data class ExampleWithHandWrittenCompanion( + val data: String + ) { + companion object { + fun serializer(): KSerializer = CustomSerializer // assertNotCovered() + } + } + + @JvmStatic + fun main(args: Array) { + Example("").data + ExampleWithCustomSerializer("").data + ExampleWithHandWrittenCompanion("") + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSynchronizedTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSynchronizedTarget.kt new file mode 100644 index 0000000000..6c697fe863 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSynchronizedTarget.kt @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.* + +/** + * Test target with [synchronized] block. + */ +object KotlinSynchronizedTarget { + + private val lock = Any(); + + private fun normal() { + synchronized(lock) { // assertFullyCovered() + nop() // assertFullyCovered() + } // assertFullyCovered() + } + + private fun explicitException() { + synchronized(lock) { // assertFullyCovered() + throw StubException() // assertFullyCovered() + } // assertEmpty() + } + + private fun implicitException() { + synchronized(lock) { // assertPartlyCovered() + ex() // assertNotCovered() + } // assertNotCovered() + } + + @JvmStatic + fun main(args: Array) { + normal() + + try { + explicitException() + } catch (_: StubException) { + } + + try { + implicitException() + } catch (_: StubException) { + } + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSyntheticAccessorsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSyntheticAccessorsTarget.kt new file mode 100644 index 0000000000..6972d8dfe7 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinSyntheticAccessorsTarget.kt @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +/** + * Test target with synthetic accessor methods. + */ +object KotlinSyntheticAccessorsTarget { + + class Outer { // assertFullyCovered() + private var x = 42 + + private fun getX(): Int { + return x + } + + inner class Inner { // assertFullyCovered() + /** + * Access to private field and function of outer class causes creation of synthetic methods in it. + * Those methods refer to the line of outer class definition. + */ + @Suppress("unused") + fun accessOuter() { + x += 1 // assertNotCovered() + getX() + } + } + } + + @JvmStatic + fun main(args: Array) { + Outer().Inner() + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt index 9889588a36..fe482647c9 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinUnsafeCastOperatorTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinUnsafeCastOperatorTarget.kt index eef5e176f5..af0b70e364 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinUnsafeCastOperatorTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinUnsafeCastOperatorTarget.kt @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenEnumTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenEnumTarget.kt new file mode 100644 index 0000000000..3b04102903 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenEnumTarget.kt @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +/** + * Test target with `when` expressions with subject of type `enum class`. + */ +object KotlinWhenEnumTarget { + + private enum class Enum { + A, B + } + + private fun whenEnum(p: Enum): Int = when (p) { // assertFullyCovered(0, 2) + Enum.A -> 1 // assertFullyCovered() + Enum.B -> 2 // assertFullyCovered() + } // assertFullyCovered() + + @Suppress("REDUNDANT_ELSE_IN_WHEN") + private fun whenEnumRedundantElse(p: Enum): Int = when (p) { // assertFullyCovered(0, 2) + Enum.A -> 1 // assertFullyCovered() + Enum.B -> 2 // assertFullyCovered() + else -> throw NoWhenBranchMatchedException() // assertEmpty() + } // assertFullyCovered() + + private fun whenByNullableEnumWithNullCaseAndWithoutElse(e: Enum?): String = + when (e) { // assertFullyCovered(0, 3) + Enum.A -> "a" // assertFullyCovered() + Enum.B -> "b" // assertFullyCovered() + null -> "null" // assertFullyCovered() + } // assertFullyCovered() + + private fun whenByNullableEnumWithoutNullCaseAndWithElse(e: Enum?): String = + when (e) { // assertFullyCovered(0, 3) + Enum.A -> "a" // assertFullyCovered() + Enum.B -> "b" // assertFullyCovered() + else -> "else" // assertFullyCovered() + } // assertFullyCovered() + + private fun whenByNullableEnumWithNullAndElseCases(e: Enum?): String = + when (e) { // assertFullyCovered(0, 3) + Enum.A -> "a" // assertFullyCovered() + null -> "null" // assertFullyCovered() + else -> "else" // assertFullyCovered() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + whenEnum(Enum.A) + whenEnum(Enum.B) + + whenEnumRedundantElse(Enum.A) + whenEnumRedundantElse(Enum.B) + + whenByNullableEnumWithNullCaseAndWithoutElse(Enum.A) + whenByNullableEnumWithNullCaseAndWithoutElse(Enum.B) + whenByNullableEnumWithNullCaseAndWithoutElse(null) + + whenByNullableEnumWithoutNullCaseAndWithElse(Enum.A) + whenByNullableEnumWithoutNullCaseAndWithElse(Enum.B) + whenByNullableEnumWithoutNullCaseAndWithElse(null) + + whenByNullableEnumWithNullAndElseCases(Enum.A) + whenByNullableEnumWithNullAndElseCases(Enum.B) + whenByNullableEnumWithNullAndElseCases(null) + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt deleted file mode 100644 index faf9bff95f..0000000000 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Evgeny Mandrikov - initial API and implementation - * - *******************************************************************************/ -package org.jacoco.core.test.validation.kotlin.targets - -/** - * This test target is `when` expression. - */ -object KotlinWhenExpressionTarget { - - private sealed class Sealed { - object Sealed1 : Sealed() - object Sealed2 : Sealed() - } - - private fun whenSealed(p: Sealed): Int = when (p) { // assertFullyCovered() - is Sealed.Sealed1 -> 1 // assertFullyCovered(0, 2) - is Sealed.Sealed2 -> 2 // assertFullyCovered() - } // assertFullyCovered() - - @Suppress("REDUNDANT_ELSE_IN_WHEN") - private fun whenSealedRedundantElse(p: Sealed): Int = when (p) { // assertFullyCovered() - is Sealed.Sealed1 -> 1 // assertFullyCovered(0, 2) - is Sealed.Sealed2 -> 2 // assertFullyCovered(0, 0) - else -> throw NoWhenBranchMatchedException() // assertEmpty() - } // assertFullyCovered() - - private enum class Enum { - A, B - } - - private fun whenEnum(p: Enum): Int = when (p) { // assertFullyCovered(0, 2) - Enum.A -> 1 // assertFullyCovered() - Enum.B -> 2 // assertFullyCovered() - } // assertFullyCovered() - - @Suppress("REDUNDANT_ELSE_IN_WHEN") - private fun whenEnumRedundantElse(p: Enum): Int = when (p) { // assertFullyCovered(0, 2) - Enum.A -> 1 // assertFullyCovered() - Enum.B -> 2 // assertFullyCovered() - else -> throw NoWhenBranchMatchedException() // assertEmpty() - } // assertFullyCovered() - - private fun whenString(p: String): Int = when (p) { // assertFullyCovered(0, 7) - "a" -> 1 // assertFullyCovered() - "b" -> 2 // assertFullyCovered() - "c" -> 3 // assertFullyCovered() - "\u0000a" -> 4 // assertFullyCovered() - "\u0000b" -> 5 // assertFullyCovered() - "\u0000c" -> 6 // assertFullyCovered() - else -> 7 // assertFullyCovered() - } // assertFullyCovered() - - /** - * Unlike [whenString] - * in this example first case is the only case with biggest hashCode value. - */ - private fun whenStringBiggestHashCodeFirst(p: String): Int = when (p) { // assertFullyCovered(0, 6) - "c" -> 1 // assertFullyCovered() - "b" -> 2 // assertFullyCovered() - "\u0000b" -> 3 // assertFullyCovered() - "a" -> 4 // assertFullyCovered() - "\u0000a" -> 5 // assertFullyCovered() - else -> 6 // assertFullyCovered() - } // assertFullyCovered() - - @JvmStatic - fun main(args: Array) { - whenSealed(Sealed.Sealed1) - whenSealed(Sealed.Sealed2) - - whenSealedRedundantElse(Sealed.Sealed1) - whenSealedRedundantElse(Sealed.Sealed2) - - whenEnum(Enum.A) - whenEnum(Enum.B) - - whenEnumRedundantElse(Enum.A) - whenEnumRedundantElse(Enum.B) - - whenString("") - whenString("a") - whenString("b") - whenString("c") - whenString("\u0000a") - whenString("\u0000b") - whenString("\u0000c") - - whenStringBiggestHashCodeFirst("") - whenStringBiggestHashCodeFirst("a") - whenStringBiggestHashCodeFirst("b") - whenStringBiggestHashCodeFirst("c") - whenStringBiggestHashCodeFirst("\u0000a") - whenStringBiggestHashCodeFirst("\u0000b") - } - -} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenSealedTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenSealedTarget.kt new file mode 100644 index 0000000000..3c6c3e335c --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenSealedTarget.kt @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop + +/** + * Test target with `when` expressions and statements with subject of type `sealed class`. + */ +object KotlinWhenSealedTarget { + + private sealed class Sealed { + object Sealed1 : Sealed() + object Sealed2 : Sealed() + } + + private fun expression(sealed: Sealed): String = + when (sealed) { // assertFullyCovered() + is Sealed.Sealed1 -> "case 1" // assertFullyCovered(0, 2) + is Sealed.Sealed2 -> "case 2" // assertFullyCovered() + } // assertFullyCovered() + + @Suppress("REDUNDANT_ELSE_IN_WHEN") + private fun expressionWithRedundantElse(sealed: Sealed): String = + when (sealed) { // assertFullyCovered() + is Sealed.Sealed1 -> "case 1" // assertFullyCovered(0, 2) + is Sealed.Sealed2 -> "case 2" // assertFullyCovered(0, 0) + else -> throw NoWhenBranchMatchedException() // assertEmpty() + } // assertFullyCovered() + + /** + * Since Kotlin 1.7 `when` statement with subject of type `sealed class` + * must be exhaustive (error otherwise, warning in 1.6), however + * Kotlin compiler prior to version 2.0 was generating bytecode + * indistinguishable from [nonSealedWhen] and [nonSealedIf] + * that do not have coverage for the case of [NonSealed.NonSealed3]. + */ + private fun statement(sealed: Sealed) { // assertEmpty() + when (sealed) { // assertFullyCovered() + is Sealed.Sealed1 -> nop("case 1") // assertFullyCovered(0, 2) + is Sealed.Sealed2 -> nop("case 2") // assertFullyCovered() + } // assertEmpty() + } // assertFullyCovered() + + private abstract class NonSealed { + class NonSealed1 : NonSealed() + class NonSealed2 : NonSealed() + class NonSealed3 : NonSealed() + } + + private fun nonSealedWhen(nonSealed: NonSealed) { // assertEmpty() + when (nonSealed) { // assertFullyCovered() + is NonSealed.NonSealed1 -> nop("case 1") // assertFullyCovered(0, 2) + is NonSealed.NonSealed2 -> nop("case 2") // assertFullyCovered(1, 1) + /* missing is NonSealed.NonSealed3 */ + } // assertEmpty() + } // assertFullyCovered() + + private fun nonSealedIf(nonSealed: NonSealed) { // assertEmpty() + if (nonSealed is NonSealed.NonSealed1) nop("case 1") // assertFullyCovered(0, 2) + else if (nonSealed is NonSealed.NonSealed2) nop("case 2") // assertFullyCovered(1, 1) + /* missing is NonSealed.NonSealed3 */ + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + expression(Sealed.Sealed1) + expression(Sealed.Sealed2) + + expressionWithRedundantElse(Sealed.Sealed1) + expressionWithRedundantElse(Sealed.Sealed2) + + statement(Sealed.Sealed1) + statement(Sealed.Sealed2) + + nonSealedWhen(NonSealed.NonSealed1()) + nonSealedWhen(NonSealed.NonSealed2()) + + nonSealedIf(NonSealed.NonSealed1()) + nonSealedIf(NonSealed.NonSealed2()) + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenStringTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenStringTarget.kt new file mode 100644 index 0000000000..9aec8a767a --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenStringTarget.kt @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2009, 2025 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.kotlin.targets + +import org.jacoco.core.test.validation.targets.Stubs.nop +import org.jacoco.core.test.validation.targets.Stubs.string + +/** + * Test target with `when` expressions and statements with subject of type `String`. + */ +object KotlinWhenStringTarget { + + private fun whenString(p: String): Int = when (p) { // assertFullyCovered(0, 7) + "a" -> 1 // assertFullyCovered() + "b" -> 2 // assertFullyCovered() + "c" -> 3 // assertFullyCovered() + "\u0000a" -> 4 // assertFullyCovered() + "\u0000b" -> 5 // assertFullyCovered() + "\u0000c" -> 6 // assertFullyCovered() + else -> 7 // assertFullyCovered() + } // assertFullyCovered() + + private fun whenStringNullableDefault(p: String?): String = + when (p) { // assertFullyCovered(0, 4) + "a" -> "case a" // assertFullyCovered() + "b" -> "case b" // assertFullyCovered() + "c" -> "case c" // assertFullyCovered() + else -> "else" // assertFullyCovered() + } // assertFullyCovered() + + private fun whenStringNullableCase(p: String?): String = + when (p) { // assertFullyCovered(0, 5) + "a" -> "case a" // assertFullyCovered() + "b" -> "case b" // assertFullyCovered() + "c" -> "case c" // assertFullyCovered() + null -> "null" // assertFullyCovered() + else -> "else" // assertFullyCovered() + } // assertFullyCovered() + + /** + * @see KotlinControlStructuresTarget.whenImplicitElseNotExecuted + */ + private fun implicitElseNotExecuted(s: String) { + when (s) { // assertFullyCovered(1, 3) + "a" -> nop("case a") // assertFullyCovered() + "b" -> nop("case b") // assertFullyCovered() + "c" -> nop("case c") // assertFullyCovered() + } // assertEmpty() + } // assertFullyCovered() + + private fun executedWithSameHashCodeAsFirstCase() { + when (string("\u0000a")) { // assertFullyCovered(3, 1) + "a" -> nop("case a") // assertNotCovered() + "b" -> nop("case b") // assertNotCovered() + "c" -> nop("case c") // assertNotCovered() + else -> nop("else") // assertFullyCovered() + } // assertEmpty() + } // assertFullyCovered() + + /** + * Unlike [whenString] + * in this example first case is the only case with biggest hashCode value. + * FIXME https://github.com/jacoco/jacoco/issues/1295 + */ + private fun whenStringBiggestHashCodeFirst(p: String): Int = when (p) { // assertPartlyCovered(3, 11) + "c" -> 1 // assertFullyCovered() + "b" -> 2 // assertFullyCovered() + "\u0000b" -> 3 // assertFullyCovered() + "a" -> 4 // assertFullyCovered() + "\u0000a" -> 5 // assertFullyCovered() + else -> 6 // assertFullyCovered() + } // assertFullyCovered() + + @JvmStatic + fun main(args: Array) { + whenString("") + whenString("a") + whenString("b") + whenString("c") + whenString("\u0000a") + whenString("\u0000b") + whenString("\u0000c") + + whenStringNullableDefault("a") + whenStringNullableDefault("b") + whenStringNullableDefault("c") + whenStringNullableDefault("") + + whenStringNullableCase("a") + whenStringNullableCase("b") + whenStringNullableCase("c") + whenStringNullableCase(null) + whenStringNullableCase("") + + implicitElseNotExecuted("a") + implicitElseNotExecuted("b") + implicitElseNotExecuted("c") + + executedWithSameHashCodeAsFirstCase() + + whenStringBiggestHashCodeFirst("") + whenStringBiggestHashCodeFirst("a") + whenStringBiggestHashCodeFirst("b") + whenStringBiggestHashCodeFirst("c") + whenStringBiggestHashCodeFirst("\u0000a") + whenStringBiggestHashCodeFirst("\u0000b") + } + +} diff --git a/org.jacoco.core.test.validation.scala/pom.xml b/org.jacoco.core.test.validation.scala/pom.xml index 5e4162fa8e..391f4bada0 100644 --- a/org.jacoco.core.test.validation.scala/pom.xml +++ b/org.jacoco.core.test.validation.scala/pom.xml @@ -1,6 +1,6 @@ - 1.6 1.8 @@ -68,10 +67,8 @@ - 1.6 - ../org.jacoco.core.test.validation.kotlin @@ -84,7 +81,6 @@ - ../org.jacoco.core.test.validation.kotlin @@ -97,11 +93,8 @@ - - 1.6 - ../org.jacoco.core.test.validation.kotlin ../org.jacoco.core.test.validation.java7 @@ -115,7 +108,6 @@ - ../org.jacoco.core.test.validation.kotlin ../org.jacoco.core.test.validation.java7 @@ -125,6 +117,9 @@ true + + 1.8 + ../org.jacoco.core.test.validation.kotlin ../org.jacoco.core.test.validation.java7 @@ -237,6 +232,30 @@ + + java13-bytecode + + + bytecode.version + 13 + + + + 13 + 13 + + 13 + 13 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.groovy + ../org.jacoco.core.test.validation.scala + + + java14-bytecode @@ -322,8 +341,7 @@ - - 16 + 17 17 17 @@ -349,9 +367,8 @@ - - 16 - + 18 + 16 18 @@ -377,9 +394,8 @@ - - 16 - + 19 + 16 19 @@ -405,9 +421,8 @@ - - 16 - + 20 + 16 20 @@ -433,9 +448,8 @@ - - 16 - + 21 + 16 21 @@ -449,9 +463,7 @@ ../org.jacoco.core.test.validation.java16 ../org.jacoco.core.test.validation.java21 ../org.jacoco.core.test.validation.groovy - @@ -464,9 +476,8 @@ - - 16 - + 22 + 16 22 @@ -479,12 +490,126 @@ ../org.jacoco.core.test.validation.java14 ../org.jacoco.core.test.validation.java16 ../org.jacoco.core.test.validation.java21 - + 16 + + 23 + 23 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.java14 + ../org.jacoco.core.test.validation.java16 + ../org.jacoco.core.test.validation.java21 + ../org.jacoco.core.test.validation.groovy + ../org.jacoco.core.test.validation.scala + + + + + java24-bytecode + + + bytecode.version + 24 + + + + 24 + + 16 + + 24 + 24 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.java14 + ../org.jacoco.core.test.validation.java16 + ../org.jacoco.core.test.validation.java21 + - + 24 + + 16 + + 25 + 25 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.java14 + ../org.jacoco.core.test.validation.java16 + ../org.jacoco.core.test.validation.java21 + ../org.jacoco.core.test.validation.groovy + ../org.jacoco.core.test.validation.scala + + + + + java26-bytecode + + + bytecode.version + 26 + + + + + 24 + + 16 + + 26 + 26 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.java14 + ../org.jacoco.core.test.validation.java16 + ../org.jacoco.core.test.validation.java21 + + ../org.jacoco.core.test.validation.scala diff --git a/org.jacoco.core.test/pom.xml b/org.jacoco.core.test/pom.xml index aa1ee56c73..769fe8ea66 100644 --- a/org.jacoco.core.test/pom.xml +++ b/org.jacoco.core.test/pom.xml @@ -1,6 +1,6 @@