@@ -1311,6 +1311,49 @@ got args:
1311
1311
want args:
1312
1312
regexp
1313
1313
` ,
1314
+ }, {
1315
+ about : "ErrorMatches: match with pre-compiled regexp" ,
1316
+ checker : qt .ErrorMatches ,
1317
+ got : errBadWolf ,
1318
+ args : []interface {}{regexp .MustCompile ("bad (wolf|dog)" )},
1319
+ expectedNegateFailure : `
1320
+ error:
1321
+ unexpected success
1322
+ got error:
1323
+ bad wolf
1324
+ file:line
1325
+ regexp:
1326
+ s"bad (wolf|dog)"
1327
+ ` ,
1328
+ }, {
1329
+ about : "ErrorMatches: match with pre-compiled multi-line regexp" ,
1330
+ checker : qt .ErrorMatches ,
1331
+ got : errBadWolfMultiLine ,
1332
+ args : []interface {}{regexp .MustCompile (`bad (wolf|dog)\nfaulty (logic|statement)` )},
1333
+ expectedNegateFailure : `
1334
+ error:
1335
+ unexpected success
1336
+ got error:
1337
+ bad wolf
1338
+ faulty logic
1339
+ file:line
1340
+ regexp:
1341
+ s"bad (wolf|dog)\\nfaulty (logic|statement)"
1342
+ ` ,
1343
+ }, {
1344
+ about : "ErrorMatches: mismatch with pre-compiled regexp" ,
1345
+ checker : qt .ErrorMatches ,
1346
+ got : errBadWolf ,
1347
+ args : []interface {}{regexp .MustCompile ("good (wolf|dog)" )},
1348
+ expectedCheckFailure : `
1349
+ error:
1350
+ error does not match regexp
1351
+ got error:
1352
+ bad wolf
1353
+ file:line
1354
+ regexp:
1355
+ s"good (wolf|dog)"
1356
+ ` ,
1314
1357
}, {
1315
1358
about : "PanicMatches: perfect match" ,
1316
1359
checker : qt .PanicMatches ,
@@ -1428,6 +1471,51 @@ panic value:
1428
1471
regexp:
1429
1472
nil
1430
1473
` ,
1474
+ }, {
1475
+ about : "PanicMatches: match with pre-compiled regexp" ,
1476
+ checker : qt .PanicMatches ,
1477
+ got : func () { panic ("error: bad wolf" ) },
1478
+ args : []interface {}{regexp .MustCompile ("error: bad (wolf|dog)" )},
1479
+ expectedNegateFailure : `
1480
+ error:
1481
+ unexpected success
1482
+ panic value:
1483
+ "error: bad wolf"
1484
+ function:
1485
+ func() {...}
1486
+ regexp:
1487
+ s"error: bad (wolf|dog)"
1488
+ ` ,
1489
+ }, {
1490
+ about : "PanicMatches: match with pre-compiled multi-line regexp" ,
1491
+ checker : qt .PanicMatches ,
1492
+ got : func () { panic ("error: bad wolf\n faulty logic" ) },
1493
+ args : []interface {}{regexp .MustCompile (`error: bad (wolf|dog)\nfaulty (logic|statement)` )},
1494
+ expectedNegateFailure : `
1495
+ error:
1496
+ unexpected success
1497
+ panic value:
1498
+ "error: bad wolf\nfaulty logic"
1499
+ function:
1500
+ func() {...}
1501
+ regexp:
1502
+ s"error: bad (wolf|dog)\\nfaulty (logic|statement)"
1503
+ ` ,
1504
+ }, {
1505
+ about : "PanicMatches: mismatch with pre-compiled regexp" ,
1506
+ checker : qt .PanicMatches ,
1507
+ got : func () { panic ("error: bad wolf" ) },
1508
+ args : []interface {}{regexp .MustCompile ("good (wolf|dog)" )},
1509
+ expectedCheckFailure : `
1510
+ error:
1511
+ panic value does not match regexp
1512
+ panic value:
1513
+ "error: bad wolf"
1514
+ function:
1515
+ func() {...}
1516
+ regexp:
1517
+ s"good (wolf|dog)"
1518
+ ` ,
1431
1519
}, {
1432
1520
about : "PanicMatches: not a function" ,
1433
1521
checker : qt .PanicMatches ,
0 commit comments