diff options
Diffstat (limited to 'gcc/testsuite/gdc.test/runnable/class_opCmp.d')
-rw-r--r-- | gcc/testsuite/gdc.test/runnable/class_opCmp.d | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/runnable/class_opCmp.d b/gcc/testsuite/gdc.test/runnable/class_opCmp.d new file mode 100644 index 0000000..43f31ac --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/class_opCmp.d @@ -0,0 +1,25 @@ +class A +{ + int x; + this(int a) { x = a; } + + alias opCmp = Object.opCmp; + alias opCmp = my_cmp; + + final int my_cmp(A a) + { + return x - a.x; + } +} + +void main() +{ + auto a1 = new A(1); + auto a2 = new A(2); + A a_null = null; + assert(a1 > a_null); + assert(a_null < a1); + assert(!(a1 < a1)); + assert(a1 < a2); + assert(a2 > a1); +} |