/// /** * TEST PATTERN: $checked on computed results * * Claim: $checked binding only works on direct Cell maps, * not on computed results (which use read-only data URIs). * * Expected: ReadOnlyAddressError when using $checked on computed().map() */ import { computed, Default, NAME, pattern, UI } from "commontools"; interface Item { id: string; title: string; done: Default; active: Default; } interface Input { items: Default; } export default pattern(({ items }) => { // Computed: filter to only active items const activeItems = computed(() => items.filter((i) => i.active)); // Count for display const activeCount = computed(() => activeItems.length); const totalCount = computed(() => items.length); return { [NAME]: "TEST: $checked on Computed", [UI]: (

$checked on Computed Test

Testing if $checked works on computed results vs direct Cell maps

Active: {activeCount} / Total: {totalCount}
{/* TEST A: Direct Cell map - should work */}

A: Direct Cell Map (should work)

$checked on items.map() - direct Cell access

{items.map((item) => (
{item.title} {item.active ? "" : "(inactive)"}
))}
{/* TEST B: Computed map - claimed to fail */}

B: Computed Map (claimed to fail)

$checked on activeItems.map() - computed result. Superstition says this should cause ReadOnlyAddressError.

{activeItems.map((item) => (
{item.title}
))}
{/* Expected results */}

Expected Results

{`Section A: Checkboxes should toggle (direct Cell)
Section B: Should FAIL with ReadOnlyAddressError (if superstition is true)
          OR work fine (if superstition is wrong)`}
          
), items, }; });