@@ -260,6 +260,10 @@ testMapUpdateHook =
260260 result <- runUpdate [Fixture. functionKMapWithOneItemAndRest, keyG, value2]
261261 let expected = mapWith [(keyG, value2)] (Just restVar)
262262 Just expected @=? result
263+ , testCase " cannot update map at unevaluated key if key not syntactically present" $ do
264+ let keyG = [trm | g{}() |]
265+ result <- runUpdate [Fixture. concreteKMapWithTwoItems, keyG, value2]
266+ Nothing @=? result
263267 , testCase " cannot update map with symbolic rest if key not present" $ do
264268 result <- runUpdate [Fixture. concreteKMapWithOneItemAndRest, key2, value2]
265269 Nothing @=? result
@@ -376,6 +380,9 @@ testMapRemoveHook =
376380 Just Fixture. emptyKMap @=? result
377381 result2 <- runRemove [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |]]
378382 Just restVar @=? result2
383+ , testCase " no result if removing non-concrete keys not syntactically equal" $ do
384+ result <- runRemove [Fixture. concreteKMapWithTwoItems, [trm | g{}() |]]
385+ Nothing @=? result
379386 , testCase " no result when map has non-concrete syntactically different keys" $ do
380387 result <- runRemove [Fixture. functionKMapWithOneItem, key]
381388 Nothing @=? result
@@ -449,6 +456,10 @@ testMapLookupHook =
449456 , testCase " returns item for a non-evaluated key when present" $ do
450457 result <- runLookup [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |]]
451458 Just [trm | \dv{SortTestKMapItem{}}("value") |] @=? result
459+ , testProperty " no result for an unevaluated key not syntactically present" . property $ do
460+ assocs <- forAll $ genAssocs (Range. linear 0 10 )
461+ result <- runLookup [mapWith assocs Nothing , [trm | g{}() |]]
462+ Nothing === result
452463 , testCase " no result if map has non-evaluated keys when key not found" $ do
453464 result <- runLookup [Fixture. functionKMapWithOneItem, notAKey]
454465 Nothing @=? result
@@ -494,6 +505,10 @@ testMapLookupOrDefaultHook =
494505 , testCase " returns item for a non-evaluated key when present" $ do
495506 result <- runLookup [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |], defItem]
496507 Just [trm | \dv{SortTestKMapItem{}}("value") |] @=? result
508+ , testProperty " no result for an unevaluated key not syntactically present" . property $ do
509+ assocs <- forAll $ genAssocs (Range. linear 0 10 )
510+ result <- runLookup [mapWith assocs Nothing , [trm | g{}() |], defItem]
511+ Nothing === result
497512 , testCase " no result if map has non-evaluated keys and key not found" $ do
498513 result <- runLookup [Fixture. functionKMapWithOneItemAndRest, notAKey, defItem]
499514 Nothing @=? result
@@ -532,11 +547,20 @@ testMapInKeysHook =
532547 Just (Builtin. boolTerm True ) === result
533548 result2 <- runInKeys [key, mapWith assocs (Just restVar)]
534549 Just (Builtin. boolTerm True ) === result2
550+ , testCase " returns true when key syntactically present" $ do
551+ result <- runInKeys [[trm | g{}() |], Fixture. functionKMapWithOneItem]
552+ Just (Builtin. boolTerm True ) @=? result
553+ result2 <- runInKeys [[trm | g{}() |], Fixture. functionKMapWithOneItemAndRest]
554+ Just (Builtin. boolTerm True ) @=? result2
535555 , testCase " no result if unevaluated map keys present" $ do
536556 result <- runInKeys [notAKey, Fixture. functionKMapWithOneItem]
537557 Nothing @=? result
538558 result2 <- runInKeys [notAKey, Fixture. functionKMapWithOneItemAndRest]
539559 Nothing @=? result2
560+ , testProperty " no result for an unevaluated key not present" . property $ do
561+ assocs <- forAll $ genAssocs (Range. linear 0 42 )
562+ result <- runInKeys [[trm | g{}() |], mapWith assocs Nothing ]
563+ Nothing === result
540564 ]
541565 where
542566 runInKeys :: MonadFail m => [Term ] -> m (Maybe Term )
0 commit comments