Beispiel
Handle invalid keys in CanonicalizedMap when isValidKey is configured
sha256:e0368138deaa5543fd8c32462b0bf325847128438b1e712d85acb689585e8feb
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Handle invalid keys in CanonicalizedMap when isValidKey is configured HOW
- Pakete
- collection 1.19.1
- Umgebung
- dart
- Erstellt
- 2026-08-17T02:04:25Z
Häufige Annahme
Assigning a value to an invalid key on a CanonicalizedMap throws an ArgumentError, and putIfAbsent rejects invalid keys identically.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- 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.
Dateien
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9