You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java
+277
Original file line number
Diff line number
Diff line change
@@ -316,6 +316,52 @@ public void testTypeChecked6882() {
316
316
runConformTest(sources, "CC");
317
317
}
318
318
319
+
@Test
320
+
publicvoidtestTypeChecked6912() {
321
+
//@formatter:off
322
+
String[] sources = {
323
+
"Main.groovy",
324
+
"@groovy.transform.TypeChecked\n" +
325
+
"void test() {\n" +
326
+
" def a = []\n" +
327
+
" assert a instanceof List\n" +
328
+
" List b = []\n" +
329
+
" assert b instanceof List\n" +
330
+
" Object c = []\n" +
331
+
" assert c instanceof List\n" +
332
+
" Iterable d = []\n" +
333
+
" assert d instanceof Iterable\n" +
334
+
" ArrayList e = []\n" +
335
+
" assert e instanceof ArrayList\n" +
336
+
"}\n" +
337
+
"test()\n",
338
+
};
339
+
//@formatter:on
340
+
341
+
runConformTest(sources, "");
342
+
}
343
+
344
+
@Test
345
+
publicvoidtestTypeChecked6912a() {
346
+
//@formatter:off
347
+
String[] sources = {
348
+
"Main.groovy",
349
+
"@groovy.transform.TypeChecked\n" +
350
+
"void test() {\n" +
351
+
" Set a = []\n" +
352
+
" assert a instanceof Set\n" +
353
+
" HashSet b = []\n" +
354
+
" assert b instanceof HashSet\n" +
355
+
" LinkedHashSet c = []\n" +
356
+
" assert c instanceof LinkedHashSet\n" +
357
+
"}\n" +
358
+
"test()\n",
359
+
};
360
+
//@formatter:on
361
+
362
+
runConformTest(sources, "");
363
+
}
364
+
319
365
@Test
320
366
publicvoidtestTypeChecked6938() {
321
367
//@formatter:off
@@ -357,6 +403,151 @@ public void testTypeChecked6938() {
357
403
runConformTest(sources, "null");
358
404
}
359
405
406
+
@Test
407
+
publicvoidtestTypeChecked7106() {
408
+
//@formatter:off
409
+
String[] sources = {
410
+
"Main.groovy",
411
+
"void m(Map<String,Object> map) {\n" +
412
+
"}\n" +
413
+
"@groovy.transform.TypeChecked\n" +
414
+
"void test() {\n" +
415
+
" ['x'].each {\n" +
416
+
" m([(it): it.toLowerCase()])\n" +
417
+
" }\n" +
418
+
"}\n" +
419
+
"test()\n",
420
+
};
421
+
//@formatter:on
422
+
423
+
runConformTest(sources, "");
424
+
}
425
+
426
+
@Test
427
+
publicvoidtestTypeChecked7128() {
428
+
//@formatter:off
429
+
String[] sources = {
430
+
"Main.groovy",
431
+
"@groovy.transform.TypeChecked\n" +
432
+
"void test() {\n" +
433
+
" List<Number> list = [1,2,3]\n" +
434
+
" Set<Number> set = [1,2,3,3]\n" +
435
+
"}\n" +
436
+
"test()\n",
437
+
};
438
+
//@formatter:on
439
+
440
+
runConformTest(sources, "");
441
+
}
442
+
443
+
@Test
444
+
publicvoidtestTypeChecked7128a() {
445
+
//@formatter:off
446
+
String[] sources = {
447
+
"Main.groovy",
448
+
"@groovy.transform.TypeChecked\n" +
449
+
"void test() {\n" +
450
+
" def a = [:]\n" +
451
+
" assert a instanceof Map\n" +
452
+
" Map b = [:]\n" +
453
+
" assert b instanceof Map\n" +
454
+
" Object c = [:]\n" +
455
+
" assert c instanceof Map\n" +
456
+
" HashMap d = [:]\n" +
457
+
" assert d instanceof HashMap\n" +
458
+
" LinkedHashMap e = [:]\n" +
459
+
" assert e instanceof LinkedHashMap\n" +
460
+
"}\n" +
461
+
"test()\n",
462
+
};
463
+
//@formatter:on
464
+
465
+
runConformTest(sources, "");
466
+
}
467
+
468
+
@Test
469
+
publicvoidtestTypeChecked7128b() {
470
+
for (Stringspec : newString[] {"CharSequence,Integer", "String,Number", "CharSequence,Number"}) {
471
+
//@formatter:off
472
+
String[] sources = {
473
+
"Main.groovy",
474
+
"@groovy.transform.TypeChecked\n" +
475
+
"void test() {\n" +
476
+
" Map<" + spec + "> map = [a:1,b:2,c:3]\n" +
477
+
" assert map.size() == 3\n" +
478
+
" assert map['c'] == 3\n" +
479
+
" assert !('x' in map)\n" +
480
+
"}\n" +
481
+
"test()\n",
482
+
};
483
+
//@formatter:on
484
+
485
+
runConformTest(sources, "");
486
+
}
487
+
}
488
+
489
+
@Test
490
+
publicvoidtestTypeChecked7128c() {
491
+
//@formatter:off
492
+
String[] sources = {
493
+
"Main.groovy",
494
+
"@groovy.transform.TypeChecked\n" +
495
+
"void test() {\n" +
496
+
" Map<String,Integer> map = [1:2]\n" +
497
+
"}\n" +
498
+
"test()\n",
499
+
};
500
+
//@formatter:on
501
+
502
+
runNegativeTest(sources,
503
+
"----------\n" +
504
+
"1. ERROR in Main.groovy (at line 3)\n" +
505
+
"\tMap<String,Integer> map = [1:2]\n" +
506
+
"\t ^^^^^\n" +
507
+
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign java.util.LinkedHashMap <java.lang.Integer, java.lang.Integer> to: java.util.Map <String, Integer>\n" +
508
+
"----------\n");
509
+
}
510
+
511
+
@Test
512
+
publicvoidtestTypeChecked7128d() {
513
+
//@formatter:off
514
+
String[] sources = {
515
+
"Main.groovy",
516
+
"class A<B,C> {\n" +
517
+
" int x\n" +
518
+
" int y\n" +
519
+
"}\n" +
520
+
"@groovy.transform.TypeChecked\n" +
521
+
"void test() {\n" +
522
+
" A<Number,String> a = [x:100, y:200]\n" +
523
+
" assert a.x == 100\n" +
524
+
" assert a.y == 200\n" +
525
+
"}\n" +
526
+
"test()\n",
527
+
};
528
+
//@formatter:on
529
+
530
+
runConformTest(sources, "");
531
+
}
532
+
533
+
@Test
534
+
publicvoidtestTypeChecked7274() {
535
+
//@formatter:off
536
+
String[] sources = {
537
+
"Main.groovy",
538
+
"void m(Map<String,Object> map) {\n" +
539
+
"}\n" +
540
+
"@groovy.transform.TypeChecked\n" +
541
+
"void test() {\n" +
542
+
" m([d:new Date(), i:1, s:''])\n" +
543
+
"}\n" +
544
+
"test()\n",
545
+
};
546
+
//@formatter:on
547
+
548
+
runConformTest(sources, "");
549
+
}
550
+
360
551
@Test
361
552
publicvoidtestTypeChecked7333() {
362
553
//@formatter:off
@@ -437,6 +628,28 @@ public void testTypeChecked7945() {
437
628
"----------\n");
438
629
}
439
630
631
+
@Test
632
+
publicvoidtestTypeChecked8001() {
633
+
//@formatter:off
634
+
String[] sources = {
635
+
"Main.groovy",
636
+
"class C {\n" +
637
+
" Map<String,Object> map\n" +
638
+
"}\n" +
639
+
"@groovy.transform.TypeChecked\n" +
640
+
"void test() {\n" +
641
+
" int value = 42\n" +
642
+
" def c = new C()\n" +
643
+
" c.map = [key:\"$value\"]\n" +
644
+
" print c.map\n" +
645
+
"}\n" +
646
+
"test()\n",
647
+
};
648
+
//@formatter:on
649
+
650
+
runConformTest(sources, "[key:42]");
651
+
}
652
+
440
653
@Test
441
654
publicvoidtestTypeChecked8034() {
442
655
//@formatter:off
@@ -510,6 +723,49 @@ public void testTypeChecked8103() {
510
723
runNegativeTest(sources, "");
511
724
}
512
725
726
+
@Test
727
+
publicvoidtestTypeChecked8909() {
728
+
//@formatter:off
729
+
String[] sources = {
730
+
"Main.groovy",
731
+
"void m(List<Object> list) {\n" +
732
+
" assert list.size() == 3\n" +
733
+
"}\n" +
734
+
"@groovy.transform.TypeChecked\n" +
735
+
"void test() {\n" +
736
+
" m([1,2,3])\n" +
737
+
"}\n" +
738
+
"test()\n",
739
+
};
740
+
//@formatter:on
741
+
742
+
runConformTest(sources, "");
743
+
}
744
+
745
+
@Test
746
+
publicvoidtestTypeChecked8909a() {
747
+
//@formatter:off
748
+
String[] sources = {
749
+
"Main.groovy",
750
+
"void m(Set<Integer> set) {\n" +
751
+
"}\n" +
752
+
"@groovy.transform.TypeChecked\n" +
753
+
"void test() {\n" +
754
+
" m([1,2,3])\n" +
755
+
"}\n" +
756
+
"test()\n",
757
+
};
758
+
//@formatter:on
759
+
760
+
runNegativeTest(sources,
761
+
"----------\n" +
762
+
"1. ERROR in Main.groovy (at line 5)\n" +
763
+
"\tm([1,2,3])\n" +
764
+
"\t^^^^^^^^^^\n" +
765
+
"Groovy:[Static type checking] - Cannot find matching method Main#m(java.util.List <java.lang.Integer>). Please check if the declared type is correct and if the method exists.\n" +
766
+
"----------\n");
767
+
}
768
+
513
769
@Test
514
770
publicvoidtestTypeChecked9460() {
515
771
//@formatter:off
@@ -785,6 +1041,27 @@ public void testTypeChecked9822() {
0 commit comments