Success.hx 633 B

123456789101112131415161718192021222324252627
  1. class Success {
  2. static var fail = false;
  3. static function main() {
  4. test('a', 'b', 's', [1, 2]);
  5. if(fail) Sys.exit(1);
  6. }
  7. static function test<T:String>(a:T, b:T, s:String, arr:Array<Int>) {
  8. check(true, a < b);
  9. check(true, a < s);
  10. check(true, s > a);
  11. check('sa', s + a);
  12. check('ab', a + b);
  13. check('as', a + s);
  14. check('sa', s + a);
  15. check('a[1,2]', a + arr);
  16. check('[1,2]a', arr + a);
  17. }
  18. static function check<T>(expected:T, actual:T, ?p:haxe.PosInfos) {
  19. if( expected != actual) {
  20. fail = true;
  21. Sys.stderr().writeString('${p.fileName}:${p.lineNumber}: $expected expected, but got $actual\n');
  22. }
  23. }
  24. }