Changeset 817
- Timestamp:
- 12/24/10 05:24:25 (14 years ago)
- Files:
-
- trunk/test/Makefile (modified) (1 diff)
- trunk/test/runnable/interpret.d (modified) (3 diffs)
- trunk/test/runnable/template1.d (modified) (7 diffs)
- trunk/test/runnable/test11.d (modified) (2 diffs)
- trunk/test/runnable/test23.d (modified) (3 diffs)
- trunk/test/runnable/test28.d (modified) (2 diffs)
- trunk/test/runnable/test8.d (modified) (1 diff)
- trunk/test/runnable/testaa2.d (modified) (1 diff)
- trunk/test/runnable/testthread2.d (modified) (1 diff)
- trunk/test/runnable/xtest46.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/Makefile
r815 r817 79 79 export ARGS=-inline -release -gc -O -unittest -fPIC 80 80 export DMD=../src/dmd 81 81 export EXE= 82 82 export OBJ=.o 83 83 export DSEP=/ 84 84 export SEP=/ 85 85 endif 86 86 87 87 runnable_tests=$(wildcard runnable/*.d) $(wildcard runnable/*.html) $(wildcard runnable/*.sh) 88 88 runnable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(runnable_tests))) 89 89 90 90 compilable_tests=$(wildcard compilable/*.d) 91 91 compilable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(compilable_tests))) 92 92 93 93 fail_compilation_tests=$(wildcard fail_compilation/*.d) 94 94 fail_compilation_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(fail_compilation_tests))) 95 95 96 96 all: run_tests 97 97 98 98 ifeq ($(MODEL),64) 99 DISABLED_TESTS = \ 100 a20 \ 101 argufilem \ 102 arrayop \ 103 builtin \ 104 complex \ 105 constfold \ 106 cov2 \ 107 delegate \ 108 dhry \ 109 eh2 \ 110 foreach4 \ 111 foreach5 \ 112 hello-profile \ 113 hospital \ 114 ifti \ 115 implicit \ 116 inner \ 117 integrate \ 118 interpret2 \ 119 interpret \ 120 lazy \ 121 mixin1 \ 122 mixin2 \ 123 nested \ 124 pi \ 125 printargs \ 126 s2ir \ 127 sieve \ 128 statictor \ 129 stress \ 130 template1 \ 131 template4 \ 132 template6 \ 133 template9 \ 134 test11 \ 135 test12 \ 136 test16 \ 137 test19 \ 138 test20 \ 139 test22 \ 140 test23 \ 141 test28 \ 142 test34 \ 143 test36 \ 144 test37 \ 145 test42 \ 146 test4 \ 147 test52 \ 148 test60 \ 149 test7 \ 150 test8 \ 151 testaa2 \ 152 testaa \ 153 testarray \ 154 testconst \ 155 testdate \ 156 testdstress \ 157 testformat \ 158 testgc2 \ 159 testgc3 \ 160 testline \ 161 testmath \ 162 testmmfile \ 163 testregexp2 \ 164 testsignals \ 165 testfile \ 166 testswitch \ 167 testthread2 \ 168 testtypeid \ 169 testzip \ 170 traits \ 171 untag \ 172 variadic \ 173 wc2 \ 174 wc3 \ 175 wc \ 176 xtest46 \ 177 xtest55 99 DISABLED_TESTS = a20 100 DISABLED_TESTS += cov2 101 DISABLED_TESTS += hello-profile 102 DISABLED_TESTS += sieve 103 # coverage / tracing is broken 104 105 DISABLED_TESTS += arrayop 106 # value isn't making it into the runtime library call for some reason 107 108 DISABLED_TESTS += builtin 109 DISABLED_TESTS += integrate 110 DISABLED_TESTS += testmath 111 # needs std.math 112 113 DISABLED_TESTS += delegate 114 # array literal with delegate 115 116 DISABLED_TESTS += eh2 117 DISABLED_TESTS += test4 118 DISABLED_TESTS += test12 119 DISABLED_TESTS += test42 120 DISABLED_TESTS += testsignals 121 DISABLED_TESTS += xtest46 122 # hangs at exit, somewhere in atomic code? 123 124 DISABLED_TESTS += foreach4 125 # iterate over dstring as char returning bad results 126 127 DISABLED_TESTS += hospital 128 # int vs long issues 129 130 DISABLED_TESTS += interpret 131 # array literal with struct 132 133 DISABLED_TESTS += s2ir 134 DISABLED_TESTS += test16 135 DISABLED_TESTS += test20 136 DISABLED_TESTS += test28 137 # -fPIC: transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against 138 139 DISABLED_TESTS += stress 140 # hangs off in the gc 141 142 DISABLED_TESTS += template4 143 # segv's off in an opCall, not clear why 144 145 DISABLED_TESTS += test11 146 # array append issues? test33 147 148 DISABLED_TESTS += test22 149 # has x86 specific asm code that needs translation 150 151 DISABLED_TESTS += test34 152 DISABLED_TESTS += testformat 153 # looks like lots of issues with std.format, at least array and aa formatting is borked.. 154 155 DISABLED_TESTS += test7 156 # interesting array manipulation test fails 157 158 DISABLED_TESTS += test8 159 # segv in rt.deh2.__eh_find_caller 160 161 DISABLED_TESTS += testaa2 162 # aa.values returns wrong data 163 164 DISABLED_TESTS += testaa 165 # segv in memcmp related to aa.keys 166 167 DISABLED_TESTS += testarray 168 # sensitive code checking a specific runtime bug 169 170 DISABLED_TESTS += testconst 171 # segv in a misleading place.. printfs around the functions in the backtrace 172 # not firing. More research needed. 173 174 DISABLED_TESTS += testgc2 175 DISABLED_TESTS += testgc3 176 DISABLED_TESTS += untag 177 DISABLED_TESTS += wc2 178 DISABLED_TESTS += wc3 179 DISABLED_TESTS += wc 180 # various gc related issues 181 182 DISABLED_TESTS += testmmfile 183 # mm issues, probably 184 185 DISABLED_TESTS += testregexp2 186 # needs std/regexp to be fixed first 187 188 DISABLED_TESTS += testthread2 189 # segv 190 191 DISABLED_TESTS += testzip 192 # zlib version error 178 193 179 194 $(addsuffix .d.out,$(addprefix $(RESULTS_DIR)/runnable/,$(DISABLED_TESTS))): $(RESULTS_DIR)/.created 180 195 $(QUIET) echo " ... $@ - disabled" 181 $(QUIET) touch $@182 196 183 197 $(RESULTS_DIR)/runnable/test2.sh.out: 184 198 $(QUIET) echo " ... $@ - disabled" 185 199 $(QUIET) touch $@ 186 200 187 201 $(RESULTS_DIR)/runnable/%.d.out: runnable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD) 188 202 $(QUIET) ./do_test.sh $(<D) $* d 189 203 190 204 $(RESULTS_DIR)/runnable/%.html.out: runnable/%.html $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD) 191 205 $(QUIET) ./do_test.sh $(<D) $* html 192 206 193 207 $(RESULTS_DIR)/runnable/%.sh.out: runnable/%.sh $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD) 194 208 $(QUIET) echo " ... $(<D)/$*.sh" 195 209 $(QUIET) ./$(<D)/$*.sh 196 210 197 211 $(RESULTS_DIR)/compilable/%.d.out: compilable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD) 198 212 $(QUIET) ./do_test.sh $(<D) $* d 199 213 200 214 $(RESULTS_DIR)/fail_compilation/%.d.out: fail_compilation/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD) 201 215 $(QUIET) ./do_test.sh $(<D) $* d trunk/test/runnable/interpret.d
r794 r817 1323 1323 } 1324 1324 1325 1325 /************************************************/ 1326 1326 1327 1327 int foo70(int[ string ] a) 1328 1328 { 1329 1329 a["world"] = 5; 1330 1330 auto x = (a["hello"] += 7); 1331 1331 assert(x == 10); 1332 1332 assert(x == a["hello"]); 1333 1333 return a["hello"] + a["betty"] + a["world"]; 1334 1334 } 1335 1335 1336 1336 void test70() 1337 1337 { 1338 1338 static assert(foo70( ["hello":3, "betty":4] ) == 19); 1339 1339 } 1340 1340 1341 1341 /************************************************/ 1342 1342 1343 int foo71(int[ string ] a)1343 size_t foo71(int[ string ] a) 1344 1344 { 1345 1345 return a.length; 1346 1346 } 1347 1347 1348 1348 void test71() 1349 1349 { 1350 1350 static assert(foo71( ["hello":3, "betty":4] ) == 2); 1351 1351 } 1352 1352 1353 1353 /************************************************/ 1354 1354 1355 1355 string[] foo72(int[ string ] a) 1356 1356 { 1357 1357 return a.keys; 1358 1358 } 1359 1359 1360 1360 void test72() 1361 1361 { 1362 1362 static assert(foo72( ["hello":3, "betty":4] ) == ["hello", "betty"]); 1363 1363 } … … 1600 1600 struct S84 { int a; } 1601 1601 1602 1602 int func84() 1603 1603 { 1604 1604 S84 [] s = [S84(7)]; 1605 1605 return s[0].a; // Error: cannot evaluate func() at compile time 1606 1606 } 1607 1607 1608 1608 void test84() 1609 1609 { 1610 1610 const int x = func84(); 1611 1611 assert(x == 7); 1612 1612 } 1613 1613 1614 1614 /************************************************/ 1615 1615 1616 1616 struct S85 { 1617 1617 int a; 1618 1618 } 1619 1619 1620 int func85()1620 size_t func85() 1621 1621 { 1622 1622 S85 [] s; 1623 1623 s ~= S85(7); 1624 1624 return s.length; 1625 1625 } 1626 1626 1627 1627 void test85() 1628 1628 { 1629 const int x = func85();1629 const size_t x = func85(); 1630 1630 assert(x == 1); 1631 1631 } 1632 1632 1633 1633 /************************************************/ 1634 1634 1635 1635 struct Bar86 1636 1636 { 1637 1637 int x; 1638 1638 char[] s; 1639 1639 } 1640 1640 1641 1641 char[] foo86() 1642 1642 { 1643 1643 Bar86 bar; 1644 1644 return bar.s; 1645 1645 } 1646 1646 1647 1647 void test86() 1648 1648 { 1649 1649 static x = foo86(); … … 2651 2651 int bug4052() { 2652 2652 int[] arr = new int[1]; 2653 2653 int s; 2654 2654 foreach (x; arr) 2655 2655 s += x; 2656 2656 foreach (x; arr) 2657 2657 s += x * x; 2658 2658 return 4052; 2659 2659 } 2660 2660 static assert(bug4052()==4052); 2661 2661 2662 2662 int bug4252() 2663 2663 { 2664 2664 char [] s = "abc".dup; 2665 2665 s[15] = 'd'; // Array bounds error 2666 2666 return 3; 2667 2667 } 2668 2668 2669 2669 static assert(!is(typeof( Compileable!(bug4252())))); 2670 2670 2671 int setlen1()2671 size_t setlen1() 2672 2672 { 2673 2673 int [] w = new int[4]; 2674 2674 w[] = 7; 2675 2675 w.length = 6; 2676 2676 return 21 + w.length; 2677 2677 } 2678 2678 2679 2679 static assert(setlen1()==27); 2680 2680 2681 int setlen2()2681 size_t setlen2() 2682 2682 { 2683 2683 int [] w; 2684 2684 w.length = 15; 2685 2685 assert(w[3]==0); 2686 2686 w[2]=8; 2687 2687 w[14]=7; 2688 2688 w.length = 12; // check shrinking 2689 2689 assert(w[2]==8); 2690 2690 return 2 + w.length; 2691 2691 } 2692 2692 2693 2693 static assert(setlen2()==14); 2694 2694 2695 2695 /************************************************/ 2696 2696 2697 2697 int bug4257(ref int x) { 2698 2698 return 3; 2699 2699 } 2700 2700 2701 2701 int bug4257c(int x) { trunk/test/runnable/template1.d
r713 r817 1 1 // REQUIRED_ARGS: -d 2 2 3 3 module template1; 4 4 5 import std.c.stdio; 5 import core.stdc.stdio : printf; 6 import core.vararg; 6 7 7 8 /******************************************/ 8 9 9 10 template TFoo1(T,U) 10 11 { 11 12 int foo(T t, U u) 12 13 { 13 14 return 3; 14 15 } 15 16 } 16 17 17 18 18 19 alias TFoo1!(int, char) Foo1; 19 20 20 21 21 22 void test1() 22 23 { 23 24 int i = Foo1.foo(1, 2); 24 25 assert(i == 3); 25 26 } … … 775 776 { 776 777 printf("Specialization\n"); 777 778 to = from; 778 779 } 779 780 } 780 781 781 782 void test30() 782 783 { 783 784 int i = 0; 784 785 float f = 0; 785 786 string s; 786 787 787 788 alias TCopy30!(int) copyint; 788 789 alias TCopy30!(string) copystr; 789 790 790 791 copyint.copy(i, 3); 791 792 printf("%d\n", i); 792 793 assert(i == 3); 793 794 794 795 copystr.copy(s, "Here it comes"); 795 printf("%.*s\n", s );796 printf("%.*s\n", s.length, s.ptr); 796 797 assert(s == "Here it comes"); 797 798 } 798 799 799 800 /******************************************/ 800 801 801 802 import std.string; 802 803 803 804 template Foo31(alias X) 804 805 { 805 806 alias X.toString y; 806 807 } 807 808 808 809 void test31() 809 810 { 810 811 alias Foo31!(std.string) bar; 811 812 } 812 813 813 814 814 815 /******************************************/ 815 816 … … 1371 1372 Bar55 a; 1372 1373 Foo55 b; 1373 1374 b.test(a); 1374 1375 Bar55.test(a); 1375 1376 } 1376 1377 1377 1378 /******************************************/ 1378 1379 1379 1380 template CT56(T) 1380 1381 { 1381 1382 class C 1382 1383 { 1383 1384 const char[][1] arrArr=["foo" ]; 1384 1385 } 1385 1386 } 1386 1387 1387 1388 void test56() 1388 1389 { 1389 1390 alias CT56!(int) Ct; 1390 1391 Ct.C c= new Ct.C(); 1391 printf("%.*s\n", c.arrArr[0] );1392 printf("%.*s\n", c.arrArr[0].length, c.arrArr[0].ptr); 1392 1393 assert(c.arrArr[0] == "foo"); 1393 1394 } 1394 1395 1395 1396 1396 1397 /******************************************/ 1397 1398 1398 1399 template foo57(T : int = int) 1399 1400 { 1400 1401 T x = 3; 1401 1402 } 1402 1403 1403 1404 void test57() 1404 1405 { 1405 1406 printf("%d\n", foo57!().x); 1406 1407 assert(foo57!().x == 3); 1407 1408 } 1408 1409 1409 1410 /******************************************/ 1410 1411 1411 1412 template Foo58(T, U = T) … … 1465 1466 {}; 1466 1467 } 1467 1468 1468 1469 void test60() 1469 1470 { 1470 1471 B60!(int, long).Thing thing1; 1471 1472 B60!(int).Thing thing2; 1472 1473 1473 1474 printf("thing1.sizeof: %u\n", thing1.sizeof); 1474 1475 printf("thing2.sizeof: %u\n", thing2.sizeof); 1475 1476 1476 1477 version (Win32) 1477 1478 assert(thing1.sizeof == 16); 1478 1479 else 1479 1480 assert(thing1.sizeof == 12); 1480 1481 assert(thing2.sizeof == 8); 1481 1482 1482 1483 C60!(int /*,A60*/ ).C60 container1; 1483 1484 1484 1485 printf("container1.sizeof: %u\n", container1.sizeof); 1485 assert(container1.sizeof == 4);1486 assert(container1.sizeof == (void*).sizeof); 1486 1487 } 1487 1488 1488 1489 /******************************************/ 1489 1490 1490 1491 struct Foo61 1491 1492 { 1492 1493 int a; 1493 1494 1494 1495 template Bar(T) 1495 1496 { 1496 1497 T abc() { return a; } 1497 1498 } 1498 1499 1499 1500 int def() { return 4; } 1500 1501 } 1501 1502 1502 1503 void test61() 1503 1504 { 1504 1505 Foo61 *f = new Foo61(); 1505 1506 int i; … … 1568 1569 static int opCall (qfloat x, qfloat y, qfloat z) { return 8; } 1569 1570 } 1570 1571 1571 1572 void test64() 1572 1573 { 1573 1574 int i; 1574 1575 i = XVector!(int)(1,2,3); 1575 1576 assert(i == 8); 1576 1577 i = XVector!(real).opCall(1,2,3); 1577 1578 assert(i == 8); 1578 1579 } 1579 1580 1580 1581 /******************************************/ 1581 1582 1582 1583 typedef int value_type; 1583 1584 1584 1585 struct Foo65 1585 1586 { 1586 1587 uint length() { return 47; } 1587 1588 1588 int test()1589 size_t test() 1589 1590 { 1590 1591 value_type[] e = new value_type[length]; 1591 1592 return e.length; 1592 1593 } 1593 1594 } 1594 1595 1595 1596 void test65() 1596 1597 { 1597 1598 Foo65 f; 1598 1599 1599 1600 assert(f.test() == 47); 1600 1601 } 1601 1602 1602 1603 /******************************************/ 1603 1604 1604 1605 class Thing66 1605 1606 { 1606 1607 template print(T2) 1607 1608 { 1608 1609 void print(T2 t) … … 1610 1611 printf("t = %d\n", t); 1611 1612 assert(t == 10); 1612 1613 } 1613 1614 } 1614 1615 } 1615 1616 1616 1617 1617 1618 void test66() 1618 1619 { 1619 1620 Thing66 thing = new Thing66; 1620 1621 1621 1622 thing.print!(int)(10); 1622 1623 } 1623 1624 1624 1625 /******************************************/ 1625 1626 1626 1627 template Foo67(alias T) 1627 1628 { 1628 1629 void Foo67() 1629 1630 { 1630 printf("T = '%.*s'\n", T );1631 printf("T = '%.*s'\n", T.length, T.ptr); 1631 1632 assert(T == "hello"); 1632 1633 } 1633 1634 } 1634 1635 1635 1636 void test67() 1636 1637 { 1637 1638 static string x = "hello"; 1638 1639 1639 1640 Foo67!(x)(); 1640 1641 } 1641 1642 1642 1643 1643 1644 /******************************************/ 1644 1645 1645 1646 template T68(int a) { 1646 1647 int vec[a]; 1647 1648 } 1648 1649 1649 1650 void test68() 1650 1651 { 1651 1652 int i; 1652 1653 1653 1654 i = T68!(4>1?4:1).vec[0]; 1654 1655 assert(i == 0); 1655 1656 i = T68!(4==1?1:(1==1?4:(4>1?1:4))).vec[0]; 1656 1657 assert(i == 0); 1657 1658 } 1658 1659 1659 1660 /******************************************/ 1660 1661 1661 int printx(string s)1662 { 1663 printf("s = '%.*s'\n", s );1662 size_t printx(string s) 1663 { 1664 printf("s = '%.*s'\n", s.length, s.ptr); 1664 1665 return s.length; 1665 1666 } 1666 1667 1667 int printx(int i)1668 size_t printx(int i) 1668 1669 { 1669 1670 printf("i = %d\n", i); 1670 1671 return 28; 1671 1672 } 1672 1673 1673 1674 template Foo69(alias T) 1674 1675 { 1675 int Foo69()1676 size_t Foo69() 1676 1677 { 1677 1678 return printx(T); 1678 1679 } 1679 1680 } 1680 1681 1681 1682 void test69() 1682 1683 { 1683 1684 static string x = "hello"; 1684 1685 static string z = "abc"; 1685 1686 static int y=100; 1686 int i;1687 size_t i; 1687 1688 1688 1689 alias Foo69!(x) foox; 1689 1690 alias Foo69!(y) fooy; 1690 1691 1691 1692 i = Foo69!(x)(); 1692 1693 assert(i == 5); 1693 1694 i = Foo69!(y)(); 1694 1695 assert(i == 28); 1695 1696 i = Foo69!(z)(); 1696 1697 assert(i == 3); 1697 1698 i = foox(); 1698 1699 assert(i == 5); 1699 1700 i = fooy(); 1700 1701 assert(i == 28); 1701 1702 } 1702 1703 1703 1704 /******************************************/ 1704 1705 1705 1706 template temptt70(alias func) 1706 1707 { … … 1740 1741 { 1741 1742 Aint71.AT a; 1742 1743 a.x = 3; 1743 1744 } 1744 1745 1745 1746 /******************************************/ 1746 1747 1747 1748 template foo72(T) 1748 1749 { 1749 1750 char[] foo72(T d) 1750 1751 { 1751 1752 uint sz = typeof(d[0]).sizeof * 2; 1752 1753 return null; 1753 1754 } 1754 1755 } 1755 1756 1756 1757 void test72() 1757 1758 { 1758 1759 static ulong[5] a = [0,1,2,3,4]; 1759 1760 static uint[5] b = [0,1,2,3,4]; 1760 printf("%.*s\n",foo72!(ulong[5])(a)); 1761 printf("%.*s\n",foo72!(uint[5])(b)); 1761 char[] r; 1762 r = foo72!(ulong[5])(a); printf("%.*s\n", r.length, r.ptr); 1763 r = foo72!(uint[5])(b); printf("%.*s\n", r.length, r.ptr); 1762 1764 } 1763 1765 1764 1766 1765 1767 /******************************************/ 1766 1768 1767 1769 typedef int Int73; 1768 1770 class Test73(T = Int73); 1769 1771 alias Test73!() Foo73; 1770 1772 1771 1773 void test73() 1772 1774 { 1773 1775 } 1774 1776 1775 1777 /******************************************/ 1776 1778 1777 1779 class A74 1778 1780 { 1779 1781 typedef A74 atype; 1780 1782 int x; 1781 1783 } trunk/test/runnable/test11.d
r749 r817 1 1 // for two uses of volatile 2 2 // REQUIRED_ARGS: -d 3 3 4 4 extern(C) int printf(const char*, ...); 5 5 extern(C) size_t strlen(const char*); 6 6 7 7 /**************************************/ 8 8 9 9 alias strlen foo1; 10 10 11 11 void test1() 12 12 { 13 13 const(char) *p = "bar"; 14 int i; 15 16 i = foo1(p); 14 size_t i = foo1(p); 17 15 assert(i == 3); 18 16 } 19 17 20 18 /**************************************/ 21 19 22 20 template Foo2(T) 23 21 { 24 22 alias T t; 25 23 } 26 24 27 25 alias Foo2!(int) t1; 28 26 alias Foo2!(int).t t2; 29 27 alias t1.t t3; 30 28 alias t2 t4; 31 29 alias Foo2!(int) t5; 32 30 33 31 void test2() 34 32 { 35 33 t1.t v1; 36 34 t2 v2; … … 66 64 67 65 debug(stdchar) 68 66 { 69 67 string line="It is a long line."; 70 68 string delimiter="is"; 71 69 } 72 70 73 71 debug(stdbyte) 74 72 { 75 73 byte[] line=cast(byte[])cast(string)"It is a long line."; 76 74 byte[] delimiter=cast(byte[])cast(string)"is"; 77 75 } 78 76 79 77 debug(stdwchar) 80 78 { 81 79 wstring line="It is a long line."; 82 80 wstring delimiter="is"; 83 81 } 84 82 int ptr=3; 85 83 86 int dl=delimiter.length;87 int pl=ptr+dl;84 size_t dl=delimiter.length; 85 size_t pl=ptr+dl; 88 86 89 87 assert(line[ptr..pl]==delimiter[]); 90 88 } 91 89 92 90 93 91 /**************************************/ 94 92 95 93 void test4() 96 94 { 97 95 byte* p; 98 96 99 assert(p.sizeof == 4); 97 version(X86) 98 assert(p.sizeof == 4); 99 else version(X86_64) 100 assert(p.sizeof == 8); 101 else 102 assert(false, "unknown platform"); 100 103 } 101 104 102 105 /**************************************/ 103 106 104 107 void test5a(int *j) 105 108 { 106 109 int i; 107 110 108 111 volatile i = *j; 109 112 volatile i = *j; 110 113 } 111 114 112 115 void test5() 113 116 { 114 117 int x; 115 118 116 119 test5a(&x); 117 120 } 118 121 119 122 trunk/test/runnable/test23.d
r749 r817 1 1 // REQUIRED_ARGS: -d 2 2 3 3 module test; 4 4 5 import core.vararg; 6 import core.stdc.stdlib; 5 7 import std.stdio; 6 import std.c.stdlib;7 8 import std.string; 8 9 9 10 10 11 /*******************************************/ 11 12 12 13 struct S 13 14 { 14 15 int opSliceAssign(int v, size_t i, size_t j) 15 16 { 16 17 assert(v == 5); 17 18 assert(i == 9); 18 19 assert(j == 10); 19 20 return 3; 20 21 } 21 22 22 23 int opSliceAssign(int v) 23 24 { 24 25 assert(v == 6); 25 26 return 11; 26 27 } … … 390 391 long b; 391 392 } 392 393 STRUCTB19 c; 393 394 } 394 395 395 396 struct STRUCTB19 396 397 { 397 398 int a; 398 399 } 399 400 400 401 void test19() 401 402 { 402 403 } 403 404 404 405 /*******************************************/ 405 406 406 407 class Foo20 407 408 { 408 409 void bar (void * src) 409 410 { 410 void baz (void function (void *, uint) xyz)411 void baz (void function (void *, size_t) xyz) 411 412 { 412 uint foo (void [] dst)413 size_t foo (void [] dst) 413 414 { 414 uint len = dst.length;415 size_t len = dst.length; 415 416 dst [0 .. len] = src [0 .. len]; 416 417 xyz (dst.ptr, len); 417 418 return len; 418 419 } 419 420 } 420 421 } 421 422 } 422 423 423 424 void test20() 424 425 { 425 426 } 426 427 427 428 /*******************************************/ 428 429 429 430 class Baz21 430 431 { 431 432 int opApply (int delegate(ref int) dg) 432 433 { 433 434 int i; 434 435 return dg(i); … … 751 752 union O_O { int a; } 752 753 class O_o { int a; } 753 754 754 755 struct Foo34 755 756 { 756 757 int ok; 757 758 o_O foo; 758 759 O_O bar; 759 760 O_o baz; 760 761 } 761 762 762 763 void test34() 763 764 { 764 765 int o1 = Foo34.ok.offsetof; 765 766 assert(o1 == 0); 766 767 int o2 = Foo34.foo.offsetof; 767 768 assert(o2 == 4); 768 769 int o3 = Foo34.bar.offsetof; 769 770 assert(o3 == 8); 770 771 int o4 = Foo34.baz.offsetof; 771 assert(o4 == 12); 772 assert((o4 % (void*).sizeof) == 0); 773 assert(o4 > o3); 772 774 } 773 775 774 776 /*******************************************/ 775 777 776 778 struct vegetarian 777 779 { 778 780 carrots areYummy; 779 781 } 780 782 781 783 typedef ptrdiff_t carrots; 782 784 783 785 void test35() 784 786 { 785 787 assert(vegetarian.sizeof == ptrdiff_t.sizeof); 786 788 } 787 789 788 790 /*******************************************/ 789 791 790 792 void test36() 791 793 { trunk/test/runnable/test28.d
r666 r817 1 1 module test; 2 2 3 import core.vararg; 3 4 import std.stdio; 4 5 import std.string; 5 6 6 7 extern(C) int printf(const char*, ...); 7 8 8 9 /*******************************************/ 9 10 10 11 struct S1 11 12 { 12 13 void* function(void*) fn; 13 14 } 14 15 15 16 template M1() 16 17 { 17 18 S1 s; 18 19 } 19 20 20 21 void test1() 21 22 { 22 23 S1 s2; … … 916 917 writefln("%s", MY_CONST_STRING); 917 918 } 918 919 } 919 920 920 921 void never_called44() 921 922 { 922 923 // This can be anything; there just needs to be a reference to 923 924 // A44.MY_CONST_STRING somewhere. 924 925 writefln("%s", A44.MY_CONST_STRING); 925 926 } 926 927 927 928 void test44() 928 929 { 929 930 A44 a = new A44(); 930 931 } 931 932 932 933 /*******************************************/ 933 934 934 935 class C45 935 936 { 936 void func(lazy uint x)937 void func(lazy size_t x) 937 938 { 938 939 (new C45).func(super.toHash()); 939 940 } 940 941 } 941 942 942 943 void test45() 943 944 { 944 945 } 945 946 946 947 /*******************************************/ 947 948 948 949 template T46(double v) 949 950 { 950 951 double T46 = v; 951 952 } 952 953 953 954 void test46() 954 955 { 955 956 double g = T46!(double.nan) + T46!(-double.nan); 956 957 } trunk/test/runnable/test8.d
r713 r817 828 828 class Node41 829 829 { 830 830 W41 v; 831 831 } 832 832 833 833 void test41() 834 834 { 835 835 Node41 n = new Node41; 836 836 837 837 printf("n.v.x == %d\n", n.v.x); 838 838 assert(n.v.x == 3); 839 839 } 840 840 841 841 842 842 /***********************************/ 843 843 844 844 int foo42(const(char) *x, ...) 845 845 { 846 846 va_list ap; 847 847 848 v a_start!(typeof(x))(ap, x);848 version(X86) va_start!(typeof(x))(ap, x); else va_start(ap, __va_argsave); 849 849 printf("&x = %p, ap = %p\n", &x, ap); 850 850 851 851 int i; 852 852 i = va_arg!(typeof(i))(ap); 853 853 printf("i = %d\n", i); 854 854 855 855 long l; 856 856 l = va_arg!(typeof(l))(ap); 857 857 printf("l = %lld\n", l); 858 858 859 859 uint k; 860 860 k = va_arg!(typeof(k))(ap); 861 861 printf("k = %u\n", k); 862 862 863 863 va_end(ap); 864 864 865 865 return cast(int)(i + l + k); 866 866 } 867 867 868 868 void test42() trunk/test/runnable/testaa2.d
r545 r817 1 1 // PERMUTE_ARGS: 2 2 3 3 extern(C) int printf(const char*, ...); 4 4 5 5 int main() 6 6 { 7 7 testaa(); 8 8 printf("Success\n"); 9 9 return 0; 10 10 } 11 11 12 12 void testaa() 13 { int i; 14 15 i = foo("abc"); 13 { 14 size_t i = foo("abc"); 16 15 printf("i = %d\n", i); 17 16 assert(i == 0); 18 17 19 18 foo2(); 20 19 } 21 20 22 21 int a[string]; 23 22 24 int foo(invariant char [3] s)23 size_t foo(invariant char [3] s) 25 24 { 26 25 printf("foo()\n"); 27 26 int b[string]; 28 27 string[] key; 29 28 int[] value; 30 29 printf("foo() 2\n"); 31 30 key = a.keys; 32 31 printf("foo() 3\n"); 33 32 value = a.values; 34 33 printf("foo() 4\n"); 35 34 return a.length + b.length; 36 35 } 37 36 38 37 void foo2() 39 38 { 40 39 int c[string]; 41 40 string[] key; 42 41 int[] value; 43 42 int i; 44 43 trunk/test/runnable/testthread2.d
r575 r817 41 41 42 42 void remove(K key) { 43 43 size_t i = 0; 44 44 for(; i < keys.length; i++) { 45 45 if(keys[i] == key) { 46 46 break; 47 47 } 48 48 } 49 49 50 50 assert(i < keys.length); 51 51 52 52 for(; i < keys.length - 1; i++) { 53 53 keys[i] = keys[i + 1]; 54 54 values[i] = values[i + 1]; 55 55 } 56 56 57 57 keys = keys[0..$ - 1]; 58 58 values = values[0..$ - 1]; 59 59 } 60 60 61 uint length() {61 size_t length() { 62 62 return values.length; 63 63 } 64 64 } 65 65 66 66 void main() { 67 67 foreach(iter; 0..10) { // Bug only happens after a few iterations. 68 68 writeln(iter); 69 uint[ uint] builtin;70 LinearAA!( uint, uint) linAA;69 uint[size_t] builtin; 70 LinearAA!(size_t, uint) linAA; 71 71 uint[] nums = new uint[100_000]; 72 72 foreach(ref num; nums) { 73 73 num = uniform(0U, uint.max); 74 74 } 75 75 76 76 foreach(i; 0..10_000) { 77 77 auto index = uniform(0, nums.length); 78 78 if(index in builtin) { 79 79 assert(index in linAA); 80 80 assert(builtin[index] == nums[index]); 81 81 assert(linAA[index] == nums[index]); 82 82 builtin.remove(index); 83 83 linAA.remove(index); 84 84 } else { 85 85 assert(!(index in linAA)); 86 86 builtin[index] = nums[index]; 87 87 linAA[index] = nums[index]; 88 88 } 89 89 } 90 90 trunk/test/runnable/xtest46.d
r755 r817 156 156 157 157 void test7() 158 158 { 159 159 C7 t = new C7(); 160 160 t.a = 4; 161 161 t.b = 5; 162 162 t.c = 6; 163 163 assert(t.a == 4); 164 164 assert(t.b == 5); 165 165 assert(t.c == 6); 166 166 assert(t.s.b == 0); 167 167 assert(t.sizeof == (void*).sizeof); 168 168 assert(t.init is null); 169 169 } 170 170 171 171 /***************************************************/ 172 172 173 173 void foo8(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__) 174 174 { 175 175 assert(n1 < n2); 176 printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s );176 printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s.length, s.ptr); 177 177 } 178 178 179 179 void test8() 180 180 { 181 181 foo8(); 182 182 } 183 183 184 184 /***************************************************/ 185 185 186 186 void foo9(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__)() 187 187 { 188 188 assert(n1 < n2); 189 printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s );189 printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s.length, s.ptr); 190 190 } 191 191 192 192 void test9() 193 193 { 194 194 foo9(); 195 195 } 196 196 197 197 /***************************************************/ 198 198 199 199 int foo10(char c) pure nothrow 200 200 { 201 201 return 1; 202 202 } 203 203 204 204 void test10() 205 205 { 206 206 int function(char c) fp; 207 207 int function(char c) pure nothrow fq; 208 208 209 209 fp = &foo10; … … 893 893 sort!((string a, string b) { return freqs[a] > freqs[b]; })(words); 894 894 //sort!(bool (a, b) { return freqs[a] > freqs[b]; })(words); 895 895 //sort!(function (a, b) { return freqs[a] > freqs[b]; })(words); 896 896 //sort!(function bool(a, b) { return freqs[a] > freqs[b]; })(words); 897 897 sort!(delegate bool(string a, string b) { return freqs[a] > freqs[b]; })(words); 898 898 899 899 } 900 900 901 901 void test48() 902 902 { 903 903 } 904 904 905 905 /***************************************************/ 906 906 907 907 struct S49 908 908 { 909 909 static void* p; 910 910 911 911 this( string name ) 912 912 { 913 printf( "(ctor) &%.*s.x = %p\n", name , &x );913 printf( "(ctor) &%.*s.x = %p\n", name.length, name.ptr, &x ); 914 914 p = cast(void*)&x; 915 915 } 916 916 917 917 invariant() {} 918 918 919 919 int x; 920 920 } 921 921 922 922 void test49() 923 923 { 924 924 auto s = new S49("s2"); 925 925 926 926 printf( "&s2.x = %p\n", &s.x ); 927 927 assert(cast(void*)&s.x == S49.p); 928 928 } 929 929 930 930 /***************************************************/ 931 931 932 932 auto max50(Ts...)(Ts args) 933 933 if (Ts.length >= 2 … … 1618 1618 void mouse(){ 1619 1619 Bulldog!(int).cat(0); 1620 1620 } 1621 1621 1622 1622 void test87() 1623 1623 { 1624 1624 double[] d1 = [ 6.0, 1.5, 2.4, 3 ]; 1625 1625 double[] d2 = [ 1.5, 2.4 ]; 1626 1626 assert(find(d1, d2) == d1[1 .. $]); 1627 1627 assert(find(d1, d2) == d1[1 .. $]); // Check for memory corruption 1628 1628 assert(max(4, 5) == 5); 1629 1629 assert(max(3, 4, 5) == 5); 1630 1630 } 1631 1631 1632 1632 /***************************************************/ 1633 1633 1634 1634 struct S88 1635 1635 { 1636 1636 void opDispatch(string s, T)(T i) 1637 1637 { 1638 printf("S.opDispatch('%.*s', %d)\n", s , i);1638 printf("S.opDispatch('%.*s', %d)\n", s.length, s.ptr, i); 1639 1639 } 1640 1640 } 1641 1641 1642 1642 class C88 1643 1643 { 1644 1644 void opDispatch(string s)(int i) 1645 1645 { 1646 printf("C.opDispatch('%.*s', %d)\n", s , i);1646 printf("C.opDispatch('%.*s', %d)\n", s.length, s.ptr, i); 1647 1647 } 1648 1648 } 1649 1649 1650 1650 struct D88 1651 1651 { 1652 1652 template opDispatch(string s) 1653 1653 { 1654 1654 enum int opDispatch = 8; 1655 1655 } 1656 1656 } 1657 1657 1658 1658 void test88() 1659 1659 { 1660 1660 S88 s; 1661 1661 s.opDispatch!("hello")(7); 1662 1662 s.foo(7); 1663 1663 1664 1664 auto c = new C88(); 1665 1665 c.foo(8); 1666 1666
