Skip to content

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

Merged
shai-almog merged 1 commit intomasterfrom
codex/expand-tests-for-streams-implementation-osz1hw
Mar 16, 2026
Merged

Add broader Stream API unit tests and VM integration test for edge cases#4616
shai-almog merged 1 commit intomasterfrom
codex/expand-tests-for-streams-implementation-osz1hw

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

@github-actions
Copy link

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 16, 2026

Compared 32 screenshots: 32 matched.

Native Android coverage

  • 📊 Line coverage: 7.44% (3790/50950 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.84% (18719/320311), branch 2.78% (865/31131), complexity 3.48% (1037/29780), method 6.16% (855/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% (3790/50950 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.84% (18719/320311), branch 2.78% (865/31131), complexity 3.48% (1037/29780), method 6.16% (855/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: 9292 ms

  • Hotspots (Top 20 sampled methods):

    • 21.04% java.lang.String.indexOf (347 samples)
    • 19.65% com.codename1.tools.translator.Parser.isMethodUsed (324 samples)
    • 15.59% com.codename1.tools.translator.Parser.addToConstantPool (257 samples)
    • 9.52% java.util.ArrayList.indexOf (157 samples)
    • 3.76% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (62 samples)
    • 3.46% java.lang.Object.hashCode (57 samples)
    • 3.03% java.lang.System.identityHashCode (50 samples)
    • 2.91% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (48 samples)
    • 1.33% com.codename1.tools.translator.BytecodeMethod.optimize (22 samples)
    • 1.33% sun.nio.fs.UnixNativeDispatcher.open0 (22 samples)
    • 1.27% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (21 samples)
    • 1.21% java.lang.StringBuilder.append (20 samples)
    • 1.09% com.codename1.tools.translator.Parser.cullMethods (18 samples)
    • 0.85% com.codename1.tools.translator.ByteCodeClass.markDependent (14 samples)
    • 0.85% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (14 samples)
    • 0.79% java.io.FileOutputStream.writeBytes (13 samples)
    • 0.61% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (10 samples)
    • 0.49% java.io.FileOutputStream.open0 (8 samples)
    • 0.42% org.objectweb.asm.ClassReader.readUTF8 (7 samples)
    • 0.42% java.lang.StringCoding.encode (7 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: 100 seconds

Detailed Performance Metrics

Metric Duration
Simulator Boot 0 ms
Simulator Boot (Run) 0 ms
App Install 4000 ms
App Launch 4000 ms
Test Execution 145000 ms

@shai-almog shai-almog merged commit 9f2b86e into master Mar 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant