Source

gdc / gdc.test / runnable / deprecate1.d

Full commit
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
// REQUIRED_ARGS: -d

// Test cases using deprecated features
module deprecate1;

import core.stdc.stdio : printf;
import std.traits;
import std.math : isNaN;


/**************************************
            volatile
**************************************/
void test5a(int *j)
{
    int i;

    volatile i = *j;
    volatile i = *j;
}

void test5()
{
    int x;

    test5a(&x);
}

// from test23
static int i2 = 1;

void test2()
{
    volatile { int i2 = 2; }
    assert(i2 == 1);
}

// bug 1200. Other tests in test42.d
void foo6e() {
        volatile debug {}
}


/**************************************
        octal literals
**************************************/

void test10()
{
    int b = 0b_1_1__1_0_0_0_1_0_1_0_1_0_;
    assert(b == 3626);

    b = 0_1_2_3_4_;
    printf("b = %d\n", b);
    assert(b == 668);
}

/**************************************
        backslash literals
**************************************/

// from lexer.d
void lexerTest7()
{
    auto str = \xDB;
    assert(str.length == 1);
}

/**************************************
            typedef
**************************************/

template func19( T )
{
    typedef T function () fp = &erf;
    T erf()
    {
	printf("erf()\n");
	return T.init;
    }
}

alias func19!( int ) F19;

F19.fp tc;

void test19()
{
    printf("tc = %p\n", tc);
    assert(tc() == 0);
}


/**************************************/

// http://www.digitalmars.com/d/archives/digitalmars/D/bugs/578.html

typedef void* T60;

class A60
{
     int  List[T60][int][uint];

     void GetMsgHandler(T60 h,uint Msg)
     {
         assert(Msg in List[h][0]);    //Offending line
     }
}

void test60()
{
}

/**************************************/
// http://www.digitalmars.com/d/archives/digitalmars/D/bugs/576.html

typedef ulong[3] BBB59;

template A59()
{
    void foo(BBB59 a)
    {
	printf("A.foo\n");
	bar(a);
    }
}

struct B59
{
    mixin A59!();

    void bar(BBB59 a)
    {
	printf("B.bar\n");
    }
}

void test59()
{
    ulong[3] aa;
    BBB59 a;
    B59 b;

    b.foo(a);
}

/***************************************/
// From variadic.d

template foo33(TA...)
{
  const TA[0] foo33=0;
}

template bar33(TA...)
{
  const TA[0..1][0] bar33=TA[0..1][0].init;
}

void test33()
{
    typedef int dummy33=0;
    typedef int myint=3;

    assert(foo33!(int)==0);
    assert(bar33!(int)==int.init);
    assert(bar33!(myint)==myint.init);
    assert(foo33!(int,dummy33)==0);
    assert(bar33!(int,dummy33)==int.init);
    assert(bar33!(myint,dummy33)==myint.init);
}

/***************************************/
// Bug 875  ICE(glue.c)

void test41()
{
    double bongos(int flux, string soup)
    {
        return 0.0;
    }

    auto foo = mk_future(& bongos, 99, "soup"[]);
}

int mk_future(A, B...)(A cmd, B args)
{
    typedef ReturnType!(A) TReturn;
    typedef ParameterTypeTuple!(A) TParams;
    typedef B TArgs;

    alias Foo41!(TReturn, TParams, TArgs) TFoo;

    return 0;
}

class Foo41(A, B, C) {
    this(A delegate(B), C)
    {
    }
}

// Typedef tests from test4.d
/* ================================ */

void test4_test26()
{
    typedef int foo = cast(foo)3;
    foo x;
    assert(x == cast(foo)3);

    typedef int bar = 4;
    bar y;
    assert(y == cast(bar)4);
}

/* ================================ */

struct Foo28
{
    int a;
    int b = 7;
}

void test4_test28()
{
  version (all)
  {
    int a;
    int b = 1;
    typedef int t = 2;
    t c;
    t d = cast(t)3;

    assert(int.init == 0);
    assert(a.init == 0);
    assert(b.init == 0);
    assert(t.init == cast(t)2);
    assert(c.init == cast(t)2);
    printf("d.init = %d\n", d.init);
    assert(d.init == cast(t)2);

    assert(Foo28.a.init == 0);
    assert(Foo28.b.init == 0);
  }
  else
  {
    int a;
    int b = 1;
    typedef int t = 2;
    t c;
    t d = cast(t)3;

    assert(int.init == 0);
    assert(a.init == 0);
    assert(b.init == 1);
    assert(t.init == cast(t)2);
    assert(c.init == cast(t)2);
    printf("d.init = %d\n", d.init);
    assert(d.init == cast(t)3);

    assert(Foo28.a.init == 0);
    assert(Foo28.b.init == 7);
  }
}

// from template4.d test 4
void template4_test4()
{
    typedef char Typedef;

    static if (is(Typedef Char == typedef))
    {
        static if (is(Char == char))
        { }
        else static assert(0);
    }
    else static assert(0);
}

// from structlit
typedef int myint10 = 4;

struct S10
{
    int i;
    union
    {	int x = 2;
	int y;
    }
    int j = 3;
    myint10 k;
}

void structlit_test10()
{
    S10 s = S10( 1 );
    assert(s.i == 1);
    assert(s.x == 2);
    assert(s.y == 2);
    assert(s.j == 3);
    assert(s.k == 4);

    static S10 t = S10( 1 );
    assert(t.i == 1);
    assert(t.x == 2);
    assert(t.y == 2);
    assert(t.j == 3);
    assert(t.k == 4);

    S10 u = S10( 1, 5 );
    assert(u.i == 1);
    assert(u.x == 5);
    assert(u.y == 5);
    assert(u.j == 3);
    assert(u.k == 4);

    static S10 v = S10( 1, 6 );
    assert(v.i == 1);
    assert(v.x == 6);
    assert(v.y == 6);
    assert(v.j == 3);
    assert(v.k == 4);
}

/******************************************/

void test15_test1()
{
    int i;
    bool[] b = new bool[10];
    for (i = 0; i < 10; i++)
	assert(b[i] == false);

    typedef bool tbit = true;
    tbit[] tb = new tbit[63];
    for (i = 0; i < 63; i++)
	assert(tb[i] == true);
}

void test15_test2()
{
    int i;
    byte[] b = new byte[10];
    for (i = 0; i < 10; i++)
    {	//printf("b[%d] = %d\n", i, b[i]);
	assert(b[i] == 0);
    }

    typedef byte tbyte = 0x23;
    tbyte[] tb = new tbyte[63];
    for (i = 0; i < 63; i++)
	assert(tb[i] == 0x23);
}


void test15_test3()
{
    int i;
    ushort[] b = new ushort[10];
    for (i = 0; i < 10; i++)
    {	//printf("b[%d] = %d\n", i, b[i]);
	assert(b[i] == 0);
    }

    typedef ushort tushort = 0x2345;
    tushort[] tb = new tushort[63];
    for (i = 0; i < 63; i++)
	assert(tb[i] == 0x2345);
}


void test15_test4()
{
    int i;
    float[] b = new float[10];
    for (i = 0; i < 10; i++)
    {	//printf("b[%d] = %d\n", i, b[i]);
	assert(isNaN(b[i]));
    }

    typedef float tfloat = 0.0;
    tfloat[] tb = new tfloat[63];
    for (i = 0; i < 63; i++)
	assert(tb[i] == cast(tfloat)0.0);
}

/************************************/
// failed to compile on DMD0.050, only with typedef (alias was OK)

typedef int[int] T11;
T11 a11;

void test15_test11()
{
    1 in a11;
}

/************************************/
// ICE(cgelem.c) on 0.050, alias was OK.
struct A12
{
    int x;
    int y;
    int x1;
    int x2;
}

typedef A12 B12;

template V12(T)
{
    T buf;

    T get()
    {
       return buf;
    }
}

alias V12!(B12) foo12;


void test15_test12()
{
    B12 b = foo12.get();
}

/************************************/
// test15_test13. Failed to compile DMD0.050, OK with alias.
typedef int[] T13;
static T13 a13=[1,2,3];

/************************************************/
// Failed to compile DMD0.050, OK with alias.

typedef int foo3;

foo3 [foo3] list3;

void testaa_test3()
{
    list3[cast(foo3)5] = cast(foo3)2;
    foo3 x = list3.keys[0]; // This line fails.
    assert(x == cast(foo3)5);
}


/*****************************************/

void test20_test32()
{
	typedef int Type = 12;
	static Type[5] var = [0:1, 3:2];

	assert(var[0] == 1);
	assert(var[1] == 12);
	assert(var[2] == 12);
	assert(var[3] == 2);
	assert(var[4] == 12);
}

/**************************************/

class A2
{
    T opCast(T)()
    {
        auto s = T.stringof;
        printf("A.opCast!(%.*s)\n", s.length, s.ptr);
        return T.init;
    }
}


void opover2_test2()
{
    auto a = new A2();

    auto x = cast(int)a;
    assert(x == 0);

    typedef int myint_BUG6712 = 7;
    auto y = cast(myint_BUG6712)a;
    assert(y == 7);
}

/**************************************/
// http://www.digitalmars.com/d/archives/10750.html
// test12.d, test7(). ICE(constfold.c)

template base7( T )
{
 void errfunc() { throw new Exception("no init"); }
 typedef T safeptr = cast(T)&errfunc;
}

alias int function(int) mfp;
alias base7!(mfp) I_V_fp;

typedef bool antibool = 1;
antibool[8] z21 = [ cast(antibool) 0, ];

void test12_test21()
{
    assert(z21[7]);
}

/**************************************/
// test12.d, test41.
// Might be related to this:
// http://www.digitalmars.com/d/archives/digitalmars/D/INVALID_HANDLE_VALUE_const_55633.html

typedef void* H41;

const H41 INVALID_H41_VALUE = cast(H41)-1;

/*******************************************/

struct Ranged(T)
{
    T value, min, max, range;
}

typedef Ranged!(float) Degree = {0f, 0f, 360f, 360f};

void test28_test5()
{
    static Degree a;
    assert(a.value == 0f);
    assert(a.min == 0f);
    assert(a.max == 360f);
    assert(a.range == 360f);
}

/*******************************************/

void test28_test6()
{
    struct Foo
    {
        void foo() { }
    }

    typedef Foo Bar;

    Bar a;
    a.foo();
}

/*******************************************/

typedef uint socket_t = -1u;

class Socket
{
    socket_t sock;

    void accept()
    {
	    socket_t newsock;
    }
}

void test28_test16()
{
}

/*******************************************/

typedef int Xint = 42;

void test28_test56()
{
    Xint[3][] x = new Xint[3][4];

    foreach(Xint[3] i; x) {
        foreach (Xint j; i)
            assert(j == 42);
    }
}

void test28_test57()
{
    Xint[3][] x = new Xint[3][4];
    x.length = 200;
    assert(x.length == 200);

    foreach(Xint[3] i; x) {
        foreach (Xint j; i)
            assert(j == 42);
    }
}
/******************************************/
// from runnable/traits.d
typedef int traits_myint;
static assert(__traits(isArithmetic, traits_myint) == true);
static assert(__traits(isScalar, traits_myint) == true);
static assert(__traits(isIntegral, traits_myint) == true);

mixin template Members6674()
{
    static int i1;
    static int i2;
    static int i3;  //comment out to make func2 visible
    static int i4;  //comment out to make func1 visible
}

class Test6674
{
    mixin Members6674;

    typedef void function() func1;
    typedef bool function() func2;
}

static assert([__traits(allMembers,Test6674)] == [
    "i1","i2","i3","i4",
    "func1","func2",
    "toString","toHash","opCmp","opEquals","Monitor","factory"]);

/***************************************************/
// Bug 1523. typedef only.

struct BaseStruct {
  int n;
  char c;
}

typedef BaseStruct MyStruct26;

void myFunction(MyStruct26) {}

void test42_test26()
{
  myFunction(MyStruct26(0, 'x'));
}

/***************************************************/
// typedef only

class Foo30
{
    int i;
}

typedef Foo30 Bar30;

void test42_test30()
{
    Bar30 testBar = new Bar30();
    auto j = testBar.i;
}

/***************************************************/
// test55. bug 1767

class DebugInfo
{
    typedef int CVHeaderType ;
    enum anon:CVHeaderType{ CV_NONE, CV_DOS, CV_NT, CV_DBG }
}

/***************************************************/

void test42_test102()
{
    typedef const(char)[] A;
    A stripl(A s)
    {
	uint i;
	return s[i .. $];
    }
}

/***************************************************/
// test42.d test107(). segfault 2.020
class foo107 {}
typedef foo107 bar107;
void x107()
{
   bar107 a = new bar107();
   bar107 b = new bar107();
   bool c = (a == b);
}

/***************************************************/
// Bug 3668. segfault regression 2.032.

void test42_test167()
{
    typedef byte[] Foo;
    Foo bar;
    foreach(value; bar){}
}


// Bug 190. Test42.d, test 225.

typedef int avocado;
void eat(avocado x225 = .x225);
avocado x225;

/***************************************************/

typedef ireal BUG3919;
alias typeof(BUG3919.init*BUG3919.init) ICE3919;
alias typeof(BUG3919.init/BUG3919.init) ICE3920;

/*****************************************/
// rejectsvalid 0.100. typedef only.

void testswitch_test18()
{
    enum E { a, b }
    typedef E F;
    F i = E.a;
    final switch (i)
    {
	case E.a:
	case E.b:
	    break;
    }
}

/************************************/

void testconst_test7()
{
    typedef void *HANDLE;
    const HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1;
}

/************************************/

void testconst_test67()
{
    typedef char mychar;
    alias immutable(mychar)[] mystring;

    mystring s = cast(mystring)"hello";
    mychar c = s[0];
}

/************************************/

void testconst_test71()
{
    string s = "hello world";
    char c = s[0];

    typedef char mychar;
    alias immutable(mychar)[] mystring;

    mystring t = cast(mystring)("hello world");
    mychar d = t[0];
}

/************************************/

class foo86 { }

typedef shared foo86 Y86;

void testconst_test86()
{
   pragma(msg, Y86);
   shared(Y86) x = new Y86;
}

/************************************/

class Class19 : Throwable
{
    this() { super(""); }
}

typedef Class19 Alias19;

void testdstress_test19()
{
	try{
		throw new Alias19();
	}catch{
		return;
	}
	assert(0);
}
/************************************/

public static const uint U20 = (cast(uint)(-1)) >>> 2;

typedef uint myType20;
public static const myType20 T20 = (cast(myType20)(-1)) >>> 2;

void testdstress_test20()
{
	assert(U20 == 0x3FFFFFFF);
	assert(T20 == 0x3FFFFFFF);
}

/******************************************************/

class ABC { }

typedef ABC DEF;

TypeInfo foo()
{
    ABC c;

    return typeid(DEF);
}

void testtypeid_test1()
{
    TypeInfo ti = foo();

    TypeInfo_Typedef td = cast(TypeInfo_Typedef)ti;
    assert(td);

    ti = td.base;

    TypeInfo_Class tc = cast(TypeInfo_Class)ti;
    assert(tc);

    printf("%.*s\n", tc.info.name.length, tc.info.name.ptr);
    assert(tc.info.name == "deprecate1.ABC");
}

/******************************************************/

union MyUnion5{
	int i;
	byte b;
}

typedef MyUnion5* Foo5;

void testtypeid_test5()
{
	TypeInfo ti = typeid(Foo5);
	assert(!(ti is null));
	assert(ti.tsize==(Foo5).sizeof);
	assert(ti.toString()=="deprecate1.Foo5");
}

/***********************************/
// test8.d test13()
typedef void *HWND;

const HWND hWnd = cast(HWND)(null);

/***********************************/

typedef int* IP;

void test8_test21()
{
    int i = 5;
    IP ip = cast(IP) &i;
    assert(*ip == 5);
}

/***********************************/
// http://www.digitalmars.com/d/archives/7812.html

typedef int delegate() DG;

class A23 {
    int foo() { return 7; }
    DG pfoo() { return &this.foo; } //this is ok
}

void test8_test23()
{
    int i;
    A23 a = new A23;
    DG dg = &a.foo;
    i = dg();
    assert(i == 7);
    DG dg2 = a.pfoo();
    i = dg2();
    assert(i == 7);
}

/***********************************/
// test8 test29()
typedef int[] tint;

void Set( ref tint array, int newLength )
{
    array.length= newLength;
}

/***********************************/

struct V41 { int x; }

typedef V41 W41 = { 3 };

class Node41
{
   W41 v;
}

void test8_test41()
{
    Node41 n = new Node41;

    printf("n.v.x == %d\n", n.v.x);
    assert(n.v.x == 3);
}

/***********************************/
// http://www.digitalmars.com/d/archives/digitalmars/D/bugs/1801.html
// test8 test47. ICE(e2ir.c)

typedef string Qwert47;

string yuiop47(Qwert47 asdfg)
{
    return asdfg[4..6];
}

/***********************************/
void test22_test28()
{
    typedef cdouble Y;
    Y five = cast(Y) (4.0i + 0.4);
}

/*******************************************/
// Bug 184

struct vegetarian
{
    carrots areYummy;
}

typedef ptrdiff_t carrots;

void test23_test35()
{
    assert(vegetarian.sizeof == ptrdiff_t.sizeof);
}

/*******************************************/
// bug 185
void test23_test36()
{
        typedef double type = 5.0;

        type t;
        assert (t == type.init);

        type[] ts = new type[10];
        ts.length = 20;
        foreach (i; ts)
	{
	    assert(i == cast(type)5.0);
	}
}

/*******************************************/

typedef int Int1; 
typedef int Int2; 

int show(Int1 v)
{
    printf("Int1: %d", v); 
    return 1;
}

int show(Int2 v) {
    printf("Int2: %d", v); 
    return 2;
}

int show(int i) { 
    printf("int: %d", i); 
    return 3;
}

int show(long l) {
    printf("long: %d", l);
    return 4;
}

int show(uint u) { 
    printf("uint: %d", u); 
    return 5;
}

void test23_test49()
{   int i;

    Int1 value1 = 42; 
    Int2 value2 = 69; 

    i = show(value1 + value2); 
    assert(i == 3);
    i = show(value2 + value1); 
    assert(i == 3);
    i = show(2 * value1); 
    assert(i == 3);
    i = show(value1 * 2); 
    assert(i == 3);
    i = show(value1 + value1); 
    assert(i == 1);
    i = show(value2 - value2); 
    assert(i == 2);
    i = show(value1 + 2); 
    assert(i == 3);
    i = show(3 + value2); 
    assert(i == 3);
    i = show(3u + value2); 
    assert(i == 5);
    i = show(value1 + 3u); 
    assert(i == 5);

    long l = 23; 
    i = show(value1 + l); 
    assert(i == 4);
    i = show(l + value2); 
    assert(i == 4);

    short s = 105; 
    i = show(s + value1); 
    assert(i == 3);
    i = show(value2 + s); 
    assert(i == 3);
}

/*******************************************/

void test23_test51()
{
    typedef int fooQ = 10;

    int[3][] p = new int[3][5];
    int[3][] q = new int[3][](5);

    int[][]  r = new int[][](5,3);

    for (int i = 0; i < 5; i++)
    {
	for (int j = 0; j < 3; j++)
	{
	    assert(r[i][j] == 0);
	    r[i][j] = i * j;
	}
    }

    fooQ[][]  s = new fooQ[][](5,3);

    for (int i = 0; i < 5; i++)
    {
	for (int j = 0; j < 3; j++)
	{
	    assert(s[i][j] == 10);
	    s[i][j] = cast(fooQ)(i * j);
	}
    }

    typedef fooQ[][] barQ;
    barQ b = new barQ(5,3);

    for (int i = 0; i < 5; i++)
    {
	for (int j = 0; j < 3; j++)
	{
	    assert(b[i][j] == 10);
	    b[i][j] = cast(fooQ)(i * j);
	}
    }
}

/*******************************************/

typedef ubyte x53 = void;

void test23_test53()
{
    new x53[10];
}

/*******************************************/

void test23_test55()
{
    typedef uint myintX = 6;

    myintX[500][] data;

    data.length = 1;
    assert(data.length == 1);
    foreach (ref foo; data)
    {
	assert(foo.length == 500);
	foreach (ref u; foo)
	{   //printf("u = %u\n", u);
	    assert(u == 6);
	    u = 23;
	}
    }
    foreach (ref foo; data)
    {
	assert(foo.length == 500);
	foreach (u; foo)
	{   assert(u == 23);
	    auto v = u;
	    v = 23;
	}
    }

    typedef byte mybyte = 7;

    mybyte[500][] mata;

    mata.length = 1;
    assert(mata.length == 1);
    foreach (ref foo; mata)
    {
	assert(foo.length == 500);
	foreach (ref u; foo)
	{   //printf("u = %u\n", u);
	    assert(u == 7);
	    u = 24;
	}
    }
    foreach (ref foo; mata)
    {
	assert(foo.length == 500);
	foreach (u; foo)
	{   assert(u == 24);
	    auto v = u;
	    v = 24;
	}
    }
}

/*******************************************/

typedef string String67;

int f67( string c,  string a )
{
    return 1;
}

int f67( string c, String67 a )
{
    return 2;
}

void test23_test67()
{
    printf("test67()\n");
    int i;
    i = f67( "", "" );
    assert(i == 1);
    i = f67( "", cast(String67)"" );
    assert(i == 2);
    i = f67( null, "" );
    assert(i == 1);
    i = f67( null, cast(String67)"" );
    assert(i == 2);
}

/************************************************/

void test34_test14()
{
    typedef Exception TypedefException;

    try
    {
    }
    catch(TypedefException e)
    {
    }
}

/************************************************/

void test34_test52()
{

    struct Foo {
	typedef int Y;
    }
    with (Foo) {
         Y y;
    }
}

/***************************************************/


void test6289()
{
    typedef immutable(int)[] X;
    static assert(is(typeof(X.init[]) == X));
    static assert(is(typeof((immutable(int[])).init[]) == immutable(int)[]));
    static assert(is(typeof((const(int[])).init[]) == const(int)[]));
    static assert(is(typeof((const(int[3])).init[]) == const(int)[]));
}

/***************************************************/
// 4237

struct Struct4237(T) { T value; }
void foo4237()
{
    typedef int Number = 1;
    Struct4237!Number s;
    pragma(msg, typeof(s).mangleof);
    assert(s.value == 1);
}
void bar4237()
{
    typedef real Number = 2;
    Struct4237!Number s;
    pragma(msg, typeof(s).mangleof);
    assert(s.value == 2); // Assertion failure
}
void test4237()
{
    foo4237(); bar4237();
}

/******************************************/
// 3990

void test3990()
{
    int[] a1 = [5, 4, 3];
    assert(*a1 == 5);
    alias typeof(a1) T1;
    assert(is(typeof(*T1)));

    int[3] a2 = [5, 4, 3];
    assert(*a2 == 5);
    alias typeof(a2) T2;
    assert(is(typeof(*T2)));
}

/******************************************/
// from extra-files/test2.d

typedef void* HANDLE18;

HANDLE18 testx18()
{
    return null;
}

void test18()
{
    assert(testx18() is null);
}

/******************************************/

int main()
{
    test2();
    test5();
    lexerTest7();
    test10();
    test19();
    test33();
    test41();
    test59();
    test60();
    test4_test26();
    test4_test28();
    structlit_test10();
    test15_test1();
    test15_test2();
    test15_test3();
    test15_test4();
    test15_test11();
    test15_test12();
    test20_test32();
    opover2_test2();
    test12_test21();
    test28_test5();
    test28_test6();
    test28_test16();
    test28_test56();
    test28_test57();
    testaa_test3();
    test42_test26();
    test42_test30();
    test42_test102();
    test42_test167();
    testswitch_test18();
    testconst_test7();
    testconst_test67();
    testconst_test71();
    testconst_test86();
    testdstress_test19();
    testdstress_test20();
    testtypeid_test1();
    testtypeid_test5();
    test8_test21();
    test8_test23();
    test8_test41();
    test22_test28();
    test23_test35();
    test23_test36();
    test23_test49();
    test23_test51();
    test23_test53();
    test23_test55();
    test23_test67();
    test34_test14();
    test34_test52();
    test3990();
    test6289();
    test4237();
    test18();

    return 0;
}