サンプル
Handle invalid keys in CanonicalizedMap when isValidKey is configured
sha256:e0368138deaa5543fd8c32462b0bf325847128438b1e712d85acb689585e8feb
PUBLISHED
L3_CONTRACT_PASS
MIT-0
ケース
- ゴール
- Handle invalid keys in CanonicalizedMap when isValidKey is configured HOW
- パッケージ
- collection 1.19.1
- 環境
- dart
- 作成日
- 2026-08-17T02:04:25Z
よくある思い込み
Assigning a value to an invalid key on a CanonicalizedMap throws an ArgumentError, and putIfAbsent rejects invalid keys identically.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- CanonicalizedMap operator []= silently discards assignments for keys rejected by isValidKey without throwing an ArgumentError, leaving map length at 0 and containsKey returning false.
- CanonicalizedMap operator [] returns null and containsKey returns false for invalid keys without executing the canonicalize callback.
- CanonicalizedMap putIfAbsent bypasses isValidKey validation entirely, incrementing length to 1 and storing the value in values while operator [] and containsKey continue to report the key as absent.
- CanonicalizedMap remove on an invalid key returns null and fails to delete entries previously inserted through putIfAbsent from the underlying storage.
- CanonicalizedMap addAll silently filters out invalid keys while inserting valid keys, and update throws ArgumentError for a missing key rather than rejecting an invalid key.
ファイル
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9