@@ -1436,6 +1436,91 @@ DictionaryTestSuite.test("COW.Fast.KeysAccessDoesNotReallocate") {
1436
1436
}
1437
1437
}
1438
1438
1439
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Insertion " ) {
1440
+ var d = getCOWSlowEquatableDictionary ( )
1441
+
1442
+ d [ TestKeyTy ( 40 ) ] = TestEquatableValueTy ( 1040 )
1443
+ expectEqual ( TestEquatableValueTy ( 1040 ) , d [ TestKeyTy ( 40 ) ] )
1444
+
1445
+ // Note: Leak tests are done in tearDown.
1446
+ }
1447
+
1448
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Mutation " ) {
1449
+ var d = getCOWSlowEquatableDictionary ( )
1450
+
1451
+ d [ TestKeyTy ( 10 ) ] = TestEquatableValueTy ( 2010 )
1452
+ expectEqual ( TestEquatableValueTy ( 2010 ) , d [ TestKeyTy ( 10 ) ] )
1453
+
1454
+ // Note: Leak tests are done in tearDown.
1455
+ }
1456
+
1457
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Removal " ) {
1458
+ var d = getCOWSlowEquatableDictionary ( )
1459
+
1460
+ d [ TestKeyTy ( 10 ) ] = nil
1461
+ expectNil ( d [ TestKeyTy ( 10 ) ] )
1462
+
1463
+ // Note: Leak tests are done in tearDown.
1464
+ }
1465
+
1466
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Noop " ) {
1467
+ var d = getCOWSlowEquatableDictionary ( )
1468
+
1469
+ d [ TestKeyTy ( 40 ) ] = nil
1470
+ expectNil ( d [ TestKeyTy ( 40 ) ] )
1471
+
1472
+ // Note: Leak tests are done in tearDown.
1473
+ }
1474
+
1475
+ extension Optional {
1476
+ @inline ( never)
1477
+ mutating func setWrapped( to value: Wrapped ) {
1478
+ self = . some( value)
1479
+ }
1480
+
1481
+ @inline ( never)
1482
+ mutating func clear( ) {
1483
+ self = . none
1484
+ }
1485
+ }
1486
+
1487
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Insertion_modify " ) {
1488
+ var d = getCOWSlowEquatableDictionary ( )
1489
+
1490
+ d [ TestKeyTy ( 40 ) ] . setWrapped ( to: TestEquatableValueTy ( 1040 ) )
1491
+ expectEqual ( TestEquatableValueTy ( 1040 ) , d [ TestKeyTy ( 40 ) ] )
1492
+
1493
+ // Note: Leak tests are done in tearDown.
1494
+ }
1495
+
1496
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Mutation_modify " ) {
1497
+ var d = getCOWSlowEquatableDictionary ( )
1498
+
1499
+ d [ TestKeyTy ( 10 ) ] . setWrapped ( to: TestEquatableValueTy ( 2010 ) )
1500
+ expectEqual ( TestEquatableValueTy ( 2010 ) , d [ TestKeyTy ( 10 ) ] )
1501
+
1502
+ // Note: Leak tests are done in tearDown.
1503
+ }
1504
+
1505
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Removal_modify " ) {
1506
+ var d = getCOWSlowEquatableDictionary ( )
1507
+
1508
+ d [ TestKeyTy ( 10 ) ] . clear ( )
1509
+ expectNil ( d [ TestKeyTy ( 10 ) ] )
1510
+
1511
+ // Note: Leak tests are done in tearDown.
1512
+ }
1513
+
1514
+ DictionaryTestSuite . test ( " COW.Slow.SubscriptWithKeys_Noop_modify " ) {
1515
+ var d = getCOWSlowEquatableDictionary ( )
1516
+
1517
+ d [ TestKeyTy ( 40 ) ] . clear ( )
1518
+ expectNil ( d [ TestKeyTy ( 40 ) ] )
1519
+
1520
+ // Note: Leak tests are done in tearDown.
1521
+ }
1522
+
1523
+
1439
1524
//===---
1440
1525
// Native dictionary tests.
1441
1526
//===---
0 commit comments