Skip to content

Add broader Stream API unit tests and VM integration test for edge cases#4615

Closed
shai-almog wants to merge 1 commit intomasterfrom
codex/expand-tests-for-streams-implementation
Closed

Add broader Stream API unit tests and VM integration test for edge cases#4615
shai-almog wants to merge 1 commit intomasterfrom
codex/expand-tests-for-streams-implementation

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Improve coverage of Stream API edge cases to ensure consistent behavior across the translator/VM and JavaSE, especially for distinct, skip, limit, toArray, empty-stream semantics, encounter order and null handling.
  • Add an integration test that compiles a small app, runs it on JavaSE, translates it for the native VM, builds and executes the translated binary, and verifies the outputs match.

Description

  • Extended StreamApiTest by adding multiple assertions that exercise distinct(), sorted(), skip(), limit(), toArray(), Stream.empty(), limit(0), skipping past the end, forEach encounter order, empty-stream anyMatch/allMatch/noneMatch semantics, and distinct() with null values, and added the required Consumer import.
  • Added StreamApiIntegrationTest (JUnit) under vm/tests which dynamically writes and compiles StreamEdgeApp.java, runs it on the host JVM, runs the translator, uses CMake to build the translated native executable, executes it, and compares the RESULT= line from both runs for equality.
  • Added the test resource StreamEdgeApp.java used by the integration test which performs a deterministic series of stream operations and prints a RESULT= checksum.

Testing

  • Ran the StreamApiTest unit tests in the hellocodenameone test suite and they completed successfully.
  • Executed the new StreamApiIntegrationTest which compiles StreamEdgeApp, runs it on JavaSE, translates and builds a native executable, and compared the RESULT= output from JavaSE and the native run; the integration test passed.

Codex Task

@shai-almog shai-almog closed this Mar 16, 2026
@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 16, 2026

Compared 32 screenshots: 32 matched.

Native Android coverage

  • 📊 Line coverage: 7.44% (3793/50950 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.84% (18722/320311), branch 2.79% (868/31131), complexity 3.49% (1040/29780), method 6.17% (857/13883), class 10.27% (189/1840)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.44% (3793/50950 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.84% (18722/320311), branch 2.79% (868/31131), complexity 3.49% (1040/29780), method 6.17% (857/13883), class 10.27% (189/1840)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

@github-actions
Copy link

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 138 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 9000 ms

  • Hotspots (Top 20 sampled methods):

    • 21.41% java.lang.String.indexOf (335 samples)
    • 20.77% com.codename1.tools.translator.Parser.isMethodUsed (325 samples)
    • 11.88% java.util.ArrayList.indexOf (186 samples)
    • 4.92% com.codename1.tools.translator.ByteCodeClass.markDependent (77 samples)
    • 4.73% java.lang.Object.hashCode (74 samples)
    • 3.96% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (62 samples)
    • 3.96% com.codename1.tools.translator.Parser.addToConstantPool (62 samples)
    • 3.51% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (55 samples)
    • 3.45% java.lang.System.identityHashCode (54 samples)
    • 1.85% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (29 samples)
    • 1.21% com.codename1.tools.translator.BytecodeMethod.optimize (19 samples)
    • 1.21% java.lang.StringBuilder.append (19 samples)
    • 0.89% sun.nio.ch.FileDispatcherImpl.write0 (14 samples)
    • 0.83% com.codename1.tools.translator.Parser.cullMethods (13 samples)
    • 0.83% sun.nio.fs.UnixNativeDispatcher.open0 (13 samples)
    • 0.70% java.io.UnixFileSystem.getBooleanAttributes0 (11 samples)
    • 0.70% java.lang.StringCoding.encode (11 samples)
    • 0.64% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (10 samples)
    • 0.58% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (9 samples)
    • 0.58% com.codename1.tools.translator.BytecodeMethod.equals (9 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 16, 2026

iOS screenshot updates

Compared 32 screenshots: 31 matched, 1 updated.

  • landscape — updated screenshot. Screenshot differs (2556x1179 px, bit depth 8).

    landscape
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 75 seconds

Detailed Performance Metrics

Metric Duration
Simulator Boot 1000 ms
Simulator Boot (Run) 0 ms
App Install 1000 ms
App Launch 2000 ms
Test Execution 152000 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant