@@ -260,6 +260,10 @@ testMapUpdateHook =
260
260
result <- runUpdate [Fixture. functionKMapWithOneItemAndRest, keyG, value2]
261
261
let expected = mapWith [(keyG, value2)] (Just restVar)
262
262
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
263
267
, testCase " cannot update map with symbolic rest if key not present" $ do
264
268
result <- runUpdate [Fixture. concreteKMapWithOneItemAndRest, key2, value2]
265
269
Nothing @=? result
@@ -376,6 +380,9 @@ testMapRemoveHook =
376
380
Just Fixture. emptyKMap @=? result
377
381
result2 <- runRemove [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |]]
378
382
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
379
386
, testCase " no result when map has non-concrete syntactically different keys" $ do
380
387
result <- runRemove [Fixture. functionKMapWithOneItem, key]
381
388
Nothing @=? result
@@ -449,6 +456,10 @@ testMapLookupHook =
449
456
, testCase " returns item for a non-evaluated key when present" $ do
450
457
result <- runLookup [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |]]
451
458
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
452
463
, testCase " no result if map has non-evaluated keys when key not found" $ do
453
464
result <- runLookup [Fixture. functionKMapWithOneItem, notAKey]
454
465
Nothing @=? result
@@ -494,6 +505,10 @@ testMapLookupOrDefaultHook =
494
505
, testCase " returns item for a non-evaluated key when present" $ do
495
506
result <- runLookup [Fixture. functionKMapWithOneItemAndRest, [trm | g{}() |], defItem]
496
507
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
497
512
, testCase " no result if map has non-evaluated keys and key not found" $ do
498
513
result <- runLookup [Fixture. functionKMapWithOneItemAndRest, notAKey, defItem]
499
514
Nothing @=? result
@@ -532,11 +547,20 @@ testMapInKeysHook =
532
547
Just (Builtin. boolTerm True ) === result
533
548
result2 <- runInKeys [key, mapWith assocs (Just restVar)]
534
549
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
535
555
, testCase " no result if unevaluated map keys present" $ do
536
556
result <- runInKeys [notAKey, Fixture. functionKMapWithOneItem]
537
557
Nothing @=? result
538
558
result2 <- runInKeys [notAKey, Fixture. functionKMapWithOneItemAndRest]
539
559
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
540
564
]
541
565
where
542
566
runInKeys :: MonadFail m => [Term ] -> m (Maybe Term )
0 commit comments