Skip to content

Commit b7123aa

Browse files
committed
C#: Add viable callable testcases for regular and checked operators.
1 parent b3602a5 commit b7123aa

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

csharp/ql/test/library-tests/dispatch/CallGraph.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,7 @@
238238
| ViableCallable.cs:458:10:458:14 | M5<> | ViableCallable.cs:444:23:444:27 | M2<> |
239239
| ViableCallable.cs:475:10:475:12 | Run | ViableCallable.cs:468:10:468:11 | M2 |
240240
| ViableCallable.cs:475:10:475:12 | Run | ViableCallable.cs:473:17:473:18 | M1 |
241+
| ViableCallable.cs:492:10:492:12 | Run | ViableCallable.cs:487:32:487:32 | + |
242+
| ViableCallable.cs:492:10:492:12 | Run | ViableCallable.cs:488:40:488:40 | checked + |
243+
| ViableCallable.cs:492:10:492:12 | Run | ViableCallable.cs:489:28:489:35 | explicit conversion |
244+
| ViableCallable.cs:492:10:492:12 | Run | ViableCallable.cs:490:28:490:35 | checked explicit conversion |

csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,7 @@
471471
| ViableCallable.cs:461:9:461:30 | call to method M2<T> | C17.M2<T>(Func<T>) |
472472
| ViableCallable.cs:478:9:478:14 | call to method M1 | C18.M1() |
473473
| ViableCallable.cs:481:9:481:14 | call to method M2 | I2.M2() |
474+
| ViableCallable.cs:495:18:495:22 | call to operator + | C19.+(C19, C19) |
475+
| ViableCallable.cs:498:26:498:30 | call to operator checked + | C19.checked +(C19, C19) |
476+
| ViableCallable.cs:501:18:501:23 | call to operator explicit conversion | C19.explicit conversion(C19) |
477+
| ViableCallable.cs:504:26:504:31 | call to operator checked explicit conversion | C19.checked explicit conversion(C19) |

csharp/ql/test/library-tests/dispatch/ViableCallable.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,4 +480,27 @@ void Run(I2 i)
480480
// Viable callables: I2.M2()
481481
i.M2();
482482
}
483+
}
484+
485+
class C19
486+
{
487+
public static C19 operator +(C19 x, C19 y) => throw null;
488+
public static C19 operator checked +(C19 x, C19 y) => throw null;
489+
public static explicit operator int(C19 x) => throw null;
490+
public static explicit operator checked int(C19 x) => throw null;
491+
492+
void Run(C19 c)
493+
{
494+
// Viable callables: C19.op_Addition()
495+
var c1 = c + c;
496+
497+
// Viable callables: C19.op_CheckedAddition()
498+
var c2 = checked(c + c);
499+
500+
// Viable callables: C19.op_Explicit()
501+
var n1 = (int)c;
502+
503+
// Viable callables: C19.op_CheckedExplicit()
504+
var n2 = checked((int)c);
505+
}
483506
}

csharp/ql/test/library-tests/dispatch/viableCallable.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,7 @@
268268
| ViableCallable.cs:423:9:423:21 | call to method M<String> | M<> | A5 |
269269
| ViableCallable.cs:478:9:478:14 | call to method M1 | M1 | C18 |
270270
| ViableCallable.cs:481:9:481:14 | call to method M2 | M2 | I2 |
271+
| ViableCallable.cs:495:18:495:22 | call to operator + | + | C19 |
272+
| ViableCallable.cs:498:26:498:30 | call to operator checked + | checked + | C19 |
273+
| ViableCallable.cs:501:18:501:23 | call to operator explicit conversion | explicit conversion | C19 |
274+
| ViableCallable.cs:504:26:504:31 | call to operator checked explicit conversion | checked explicit conversion | C19 |

0 commit comments

Comments
 (0)