| 1 |
// PERMUTE_ARGS: |
| 2 |
|
| 3 |
module run.module_01; |
| 4 |
|
| 5 |
import core.memory; |
| 6 |
import core.exception; |
| 7 |
import core.vararg; |
| 8 |
|
| 9 |
extern(C) void* malloc(size_t size); |
| 10 |
extern(C) int printf(const char*, ...); |
| 11 |
|
| 12 |
/* ================================ */ |
| 13 |
|
| 14 |
struct MyStruct |
| 15 |
{ |
| 16 |
int i; |
| 17 |
} |
| 18 |
|
| 19 |
void test1() |
| 20 |
{ |
| 21 |
MyStruct inner() |
| 22 |
in{ |
| 23 |
assert(1); |
| 24 |
}out (result){ |
| 25 |
assert(result.i==1); |
| 26 |
}do{ |
| 27 |
MyStruct s; |
| 28 |
s.i = 1; |
| 29 |
return s; |
| 30 |
} |
| 31 |
assert(inner.i==1); |
| 32 |
} |
| 33 |
|
| 34 |
/* ================================ */ |
| 35 |
|
| 36 |
void foo2() |
| 37 |
in{ |
| 38 |
assert(0); |
| 39 |
} |
| 40 |
do{ |
| 41 |
} |
| 42 |
|
| 43 |
void test2() |
| 44 |
{ |
| 45 |
try{ |
| 46 |
foo2(); |
| 47 |
}catch(Error ie){ |
| 48 |
return; |
| 49 |
} |
| 50 |
assert(0); |
| 51 |
} |
| 52 |
|
| 53 |
/* ================================ */ |
| 54 |
|
| 55 |
class MyClass3 |
| 56 |
{ |
| 57 |
|
| 58 |
private int g() const { |
| 59 |
return 1; |
| 60 |
} |
| 61 |
|
| 62 |
invariant() |
| 63 |
{ |
| 64 |
assert(g()==1); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
void test3() |
| 69 |
{ |
| 70 |
MyClass3 c = new MyClass3(); |
| 71 |
assert(c); |
| 72 |
} |
| 73 |
|
| 74 |
/* ================================ */ |
| 75 |
|
| 76 |
class A |
| 77 |
{ |
| 78 |
int x; |
| 79 |
|
| 80 |
this(){ |
| 81 |
printf("A.this()\n"); |
| 82 |
x=3; |
| 83 |
} |
| 84 |
|
| 85 |
invariant() |
| 86 |
{ |
| 87 |
printf("A.invariant\n"); |
| 88 |
assert(x>2); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
class B : A |
| 93 |
{ |
| 94 |
int y; |
| 95 |
|
| 96 |
this(){ |
| 97 |
printf("B.this()\n"); |
| 98 |
y=5; |
| 99 |
} |
| 100 |
|
| 101 |
invariant() |
| 102 |
{ |
| 103 |
printf("B.invariant\n"); |
| 104 |
assert(y>4); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
void test4() |
| 109 |
{ |
| 110 |
B gc = new B(); |
| 111 |
} |
| 112 |
|
| 113 |
/* ================================ */ |
| 114 |
|
| 115 |
class A5 |
| 116 |
{ |
| 117 |
|
| 118 |
int x; |
| 119 |
|
| 120 |
this(){ |
| 121 |
printf("A5.this()\n"); |
| 122 |
x=3; |
| 123 |
} |
| 124 |
|
| 125 |
invariant() |
| 126 |
{ |
| 127 |
printf("A5.invariant\n"); |
| 128 |
assert(x>2); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
class C5 : A5 { } |
| 133 |
|
| 134 |
class B5 : C5 |
| 135 |
{ |
| 136 |
|
| 137 |
int y; |
| 138 |
|
| 139 |
this(){ |
| 140 |
printf("B5.this()\n"); |
| 141 |
y=5; |
| 142 |
} |
| 143 |
|
| 144 |
invariant() |
| 145 |
{ |
| 146 |
printf("B5.invariant\n"); |
| 147 |
assert(y>4); |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
void test5() |
| 152 |
{ |
| 153 |
B5 gc = new B5(); |
| 154 |
} |
| 155 |
|
| 156 |
/* ================================ */ |
| 157 |
|
| 158 |
void test6() |
| 159 |
{ |
| 160 |
long a; |
| 161 |
assert(a.max == 0x7FFF_FFFF_FFFF_FFFFL); |
| 162 |
//assert(a.min == 0xFFFF_FFFF_FFFF_FFFFL); |
| 163 |
assert(a.min == 0x8000_0000_0000_0000L); |
| 164 |
assert(a.init == 0); |
| 165 |
assert(a.sizeof == 8); |
| 166 |
} |
| 167 |
|
| 168 |
/* ================================ */ |
| 169 |
|
| 170 |
int i; |
| 171 |
|
| 172 |
void test7() |
| 173 |
{ |
| 174 |
assert(run.module_01.i==0); |
| 175 |
run.module_01.i++; |
| 176 |
assert(run.module_01.i==1); |
| 177 |
} |
| 178 |
|
| 179 |
/* ================================ */ |
| 180 |
|
| 181 |
template mix(){ |
| 182 |
int x; |
| 183 |
} |
| 184 |
|
| 185 |
mixin .mix; |
| 186 |
|
| 187 |
void test8() |
| 188 |
{ |
| 189 |
} |
| 190 |
|
| 191 |
/* ================================ */ |
| 192 |
|
| 193 |
struct A9 |
| 194 |
{ |
| 195 |
B9 next; |
| 196 |
} |
| 197 |
|
| 198 |
alias A9* B9; |
| 199 |
|
| 200 |
void test9() |
| 201 |
{ |
| 202 |
B9 n = new A9; |
| 203 |
} |
| 204 |
|
| 205 |
/* ================================ */ |
| 206 |
|
| 207 |
|
| 208 |
struct TestStruct |
| 209 |
{ |
| 210 |
void add(...) |
| 211 |
{ |
| 212 |
TestStruct other = va_arg!TestStruct(_argptr); |
| 213 |
foreach(int value; other) |
| 214 |
{ |
| 215 |
foo(); |
| 216 |
} |
| 217 |
} |
| 218 |
|
| 219 |
void foo() |
| 220 |
{ |
| 221 |
assert(left is null); |
| 222 |
bar(); |
| 223 |
} |
| 224 |
|
| 225 |
void bar() |
| 226 |
{ |
| 227 |
assert(left is null); |
| 228 |
} |
| 229 |
|
| 230 |
int opApply(int delegate(ref int val) dg) |
| 231 |
{ |
| 232 |
return 0; |
| 233 |
} |
| 234 |
|
| 235 |
void* left; |
| 236 |
} |
| 237 |
|
| 238 |
void test10() |
| 239 |
{ |
| 240 |
TestStruct t; |
| 241 |
t.foo(); |
| 242 |
} |
| 243 |
|
| 244 |
/* ================================ */ |
| 245 |
|
| 246 |
int status11; |
| 247 |
|
| 248 |
void check(int x){ |
| 249 |
status11++; |
| 250 |
} |
| 251 |
|
| 252 |
class MyClass11{ |
| 253 |
void test(){ |
| 254 |
assert(status11==0); |
| 255 |
.check(0); |
| 256 |
assert(status11==1); |
| 257 |
check(); |
| 258 |
assert(status11==3); |
| 259 |
} |
| 260 |
|
| 261 |
void check(){ |
| 262 |
assert(status11==1); |
| 263 |
status11+=2; |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
void test11() |
| 268 |
{ |
| 269 |
MyClass11 c = new MyClass11(); |
| 270 |
assert(status11==0); |
| 271 |
c.test(); |
| 272 |
assert(status11==3); |
| 273 |
check(0); |
| 274 |
assert(status11==4); |
| 275 |
} |
| 276 |
|
| 277 |
/* ================================ */ |
| 278 |
|
| 279 |
int status12; |
| 280 |
|
| 281 |
class C12{ |
| 282 |
void foo(){ |
| 283 |
status12='N'; |
| 284 |
} |
| 285 |
|
| 286 |
static void foo(int x){ |
| 287 |
status12=x; |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
void test12() |
| 292 |
{ |
| 293 |
C12 m = new C12(); |
| 294 |
|
| 295 |
C12.foo('S'); |
| 296 |
assert(status12=='S'); |
| 297 |
|
| 298 |
m.foo('s'); |
| 299 |
assert(status12=='s'); |
| 300 |
|
| 301 |
m.foo(); |
| 302 |
assert(status12=='N'); |
| 303 |
} |
| 304 |
|
| 305 |
/* ================================ */ |
| 306 |
|
| 307 |
void test13() |
| 308 |
{ |
| 309 |
wstring a="abc"; |
| 310 |
wstring b="efg"; |
| 311 |
wstring c=a~"d"~b; |
| 312 |
|
| 313 |
assert(c == "abcdefg"); |
| 314 |
} |
| 315 |
|
| 316 |
/* ================================ */ |
| 317 |
|
| 318 |
void test14() |
| 319 |
{ |
| 320 |
dstring a="abc"; |
| 321 |
dstring b="efg"; |
| 322 |
dstring c=a~"d"~b; |
| 323 |
|
| 324 |
assert(c == "abcdefg"); |
| 325 |
} |
| 326 |
|
| 327 |
/* ================================ */ |
| 328 |
|
| 329 |
class Parent15 |
| 330 |
{ |
| 331 |
void test(int i){ |
| 332 |
} |
| 333 |
|
| 334 |
int opCast(){ |
| 335 |
return 0; |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
class Child15 : Parent15 |
| 340 |
{ |
| 341 |
} |
| 342 |
|
| 343 |
void test15() |
| 344 |
{ |
| 345 |
(new Child15()).test(2); |
| 346 |
} |
| 347 |
|
| 348 |
/* ================================ */ |
| 349 |
|
| 350 |
class Parent16 |
| 351 |
{ |
| 352 |
void test(int i){ |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
class Child16 : Parent16 |
| 357 |
{ |
| 358 |
int opCast(){ |
| 359 |
return 0; |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
void test16() |
| 364 |
{ |
| 365 |
(new Child16()).test=2; |
| 366 |
} |
| 367 |
|
| 368 |
/* ================================ */ |
| 369 |
|
| 370 |
void foo17(){ |
| 371 |
class MyClass{ |
| 372 |
static int x; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
void foo17(int i){ |
| 377 |
class MyClass{ |
| 378 |
static int x; |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
void test17() |
| 383 |
{ |
| 384 |
} |
| 385 |
|
| 386 |
/* ================================ */ |
| 387 |
|
| 388 |
void foo18(){ |
| 389 |
struct MyStruct{ |
| 390 |
static int x; |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
void foo18(int i){ |
| 395 |
struct MyStruct{ |
| 396 |
static int x; |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
void test18() |
| 401 |
{ |
| 402 |
} |
| 403 |
|
| 404 |
/* ================================ */ |
| 405 |
|
| 406 |
class Class19 : Throwable |
| 407 |
{ |
| 408 |
this() { super(""); } |
| 409 |
} |
| 410 |
|
| 411 |
alias Class19 Alias19; |
| 412 |
|
| 413 |
void test19() |
| 414 |
{ |
| 415 |
try{ |
| 416 |
throw new Alias19(); |
| 417 |
}catch(Throwable){ |
| 418 |
return; |
| 419 |
} |
| 420 |
assert(0); |
| 421 |
} |
| 422 |
|
| 423 |
/* ================================ */ |
| 424 |
|
| 425 |
public static const uint U20 = (cast(uint)(-1)) >>> 2; |
| 426 |
|
| 427 |
alias uint myType20; |
| 428 |
public static const myType20 T20 = (cast(myType20)(-1)) >>> 2; |
| 429 |
|
| 430 |
void test20() |
| 431 |
{ |
| 432 |
assert(U20 == 0x3FFFFFFF); |
| 433 |
assert(T20 == 0x3FFFFFFF); |
| 434 |
} |
| 435 |
|
| 436 |
/* ================================ */ |
| 437 |
|
| 438 |
class C21(T1){ |
| 439 |
alias T1 type1; |
| 440 |
} |
| 441 |
|
| 442 |
class C21(T1, T2){ |
| 443 |
alias T1 type1; |
| 444 |
alias .C21!(T2) type2; |
| 445 |
} |
| 446 |
|
| 447 |
void test21() |
| 448 |
{ |
| 449 |
alias C21!(int,long) CT; |
| 450 |
CT c = new CT(); |
| 451 |
} |
| 452 |
|
| 453 |
/* ================================ */ |
| 454 |
|
| 455 |
class AutoClass{ |
| 456 |
} |
| 457 |
|
| 458 |
void test22() |
| 459 |
{ |
| 460 |
scope AutoClass ac = new AutoClass(); |
| 461 |
|
| 462 |
with(ac){ |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
/* ================================ */ |
| 467 |
|
| 468 |
int status23; |
| 469 |
|
| 470 |
class C23{ |
| 471 |
~this(){ |
| 472 |
assert(status23==0); |
| 473 |
status23--; |
| 474 |
throw new Exception("error msg"); |
| 475 |
} |
| 476 |
} |
| 477 |
|
| 478 |
void foo23(){ |
| 479 |
assert(status23==0); |
| 480 |
scope C23 ac = new C23(); |
| 481 |
} |
| 482 |
|
| 483 |
void test23() |
| 484 |
{ |
| 485 |
try{ |
| 486 |
foo23(); |
| 487 |
}catch(Throwable){ |
| 488 |
} |
| 489 |
assert(status23==-1); |
| 490 |
} |
| 491 |
|
| 492 |
/* ================================ */ |
| 493 |
|
| 494 |
int status24; |
| 495 |
|
| 496 |
class C24{ |
| 497 |
this() scope { |
| 498 |
assert(status24==0); |
| 499 |
status24+=2; |
| 500 |
} |
| 501 |
~this(){ |
| 502 |
assert(status24==2); |
| 503 |
status24--; |
| 504 |
throw new Exception("error msg"); |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
void check24(){ |
| 509 |
scope C24 ac = new C24(); |
| 510 |
throw new Exception("check error"); |
| 511 |
} |
| 512 |
|
| 513 |
void test24() |
| 514 |
{ |
| 515 |
assert(status24==0); |
| 516 |
try{ |
| 517 |
check24(); |
| 518 |
}catch(Throwable){ |
| 519 |
assert(status24==1); |
| 520 |
status24-=5; |
| 521 |
} |
| 522 |
assert(status24==-4); |
| 523 |
} |
| 524 |
|
| 525 |
/* ================================ */ |
| 526 |
|
| 527 |
struct S25{ |
| 528 |
S25 opBinary(string op)(int i) if (op == "-") { S25 s; return s; } |
| 529 |
} |
| 530 |
|
| 531 |
struct GeomObject{ |
| 532 |
S25 mesh; |
| 533 |
int xlate; |
| 534 |
} |
| 535 |
|
| 536 |
|
| 537 |
void extractTriangles(GeomObject g) |
| 538 |
{ |
| 539 |
void foobar() |
| 540 |
{ |
| 541 |
g.mesh - g.xlate; |
| 542 |
//g.mesh.opBinary!("-")(g.xlate); |
| 543 |
} |
| 544 |
|
| 545 |
foobar(); |
| 546 |
} |
| 547 |
|
| 548 |
void test25() |
| 549 |
{ |
| 550 |
} |
| 551 |
|
| 552 |
/* ================================ */ |
| 553 |
|
| 554 |
struct S26{ |
| 555 |
int i; |
| 556 |
|
| 557 |
void display(){ |
| 558 |
assert(i==10); |
| 559 |
} |
| 560 |
|
| 561 |
void someFunc(){ |
| 562 |
// We never call this function |
| 563 |
void bug(S26[] array){ |
| 564 |
array[0].i = i+1; |
| 565 |
} |
| 566 |
|
| 567 |
assert(i==10); |
| 568 |
display(); |
| 569 |
assert(i==10); |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
void test26() |
| 574 |
{ |
| 575 |
S26 m; |
| 576 |
m.i = 10; |
| 577 |
assert(m.i==10); |
| 578 |
m.someFunc(); |
| 579 |
assert(m.i==10); |
| 580 |
} |
| 581 |
|
| 582 |
/* ================================ */ |
| 583 |
|
| 584 |
template foo27(T:T[],alias S) { |
| 585 |
string foo(T[] a, T[] b) { |
| 586 |
return a ~ S ~ b; |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
string comma = ", "; |
| 591 |
alias foo27!(string,comma).foo catComma; |
| 592 |
|
| 593 |
void test27() |
| 594 |
{ |
| 595 |
string a = "Heath"; |
| 596 |
string b = "Regan"; |
| 597 |
|
| 598 |
assert("Heath, Regan"==catComma(a,b)); |
| 599 |
} |
| 600 |
|
| 601 |
/* ================================ */ |
| 602 |
|
| 603 |
void test28() |
| 604 |
{ |
| 605 |
assert((new S28!()).i==int.sizeof); |
| 606 |
} |
| 607 |
|
| 608 |
struct S28(){ |
| 609 |
int i=func28(0).sizeof; |
| 610 |
} |
| 611 |
|
| 612 |
int func28(...){ |
| 613 |
return 0; |
| 614 |
} |
| 615 |
|
| 616 |
/* ================================ */ |
| 617 |
|
| 618 |
void test29() |
| 619 |
{ |
| 620 |
uint u; |
| 621 |
u = 1 << 31; |
| 622 |
assert( u == 0b1000_0000__0000_0000__0000_0000__0000_0000u); |
| 623 |
} |
| 624 |
|
| 625 |
/* ================================ */ |
| 626 |
// Test for FinalizeError - it will be thrown if an Exception is thrown |
| 627 |
// during the class object finalization. |
| 628 |
|
| 629 |
int status30; |
| 630 |
|
| 631 |
class C30 |
| 632 |
{ |
| 633 |
this() |
| 634 |
{ |
| 635 |
status30++; |
| 636 |
} |
| 637 |
|
| 638 |
~this() |
| 639 |
{ |
| 640 |
status30--; |
| 641 |
throw new Exception("E2"); |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
void test30() |
| 646 |
{ |
| 647 |
try |
| 648 |
{ |
| 649 |
//scope C30 m = new C30(); |
| 650 |
// It will insert one more `delete m` for the scope destruction, and it will be |
| 651 |
// called during stack unwinding. |
| 652 |
// Instead use bare memory chunk on stack to construct dummy class instance. |
| 653 |
void[__traits(classInstanceSize, C30)] payload = |
| 654 |
typeid(C30).initializer[]; |
| 655 |
C30 m = cast(C30)payload.ptr; |
| 656 |
m.__ctor(); |
| 657 |
|
| 658 |
assert(status30 == 1); |
| 659 |
|
| 660 |
destroy(m); // _d_callfinalizer |
| 661 |
} |
| 662 |
catch (Error e) // FinalizeError |
| 663 |
{ |
| 664 |
assert(status30 == 0); |
| 665 |
status30--; |
| 666 |
} |
| 667 |
|
| 668 |
assert(status30 == -1); |
| 669 |
} |
| 670 |
|
| 671 |
/* ================================ */ |
| 672 |
|
| 673 |
void test31() |
| 674 |
{ |
| 675 |
string str = "\xF0\x9D\x83\x93"; // utf-8 for U+1D0D3 |
| 676 |
|
| 677 |
int count=0; |
| 678 |
dchar tmp; |
| 679 |
foreach(dchar value ; str){ |
| 680 |
tmp=value; |
| 681 |
count++; |
| 682 |
} |
| 683 |
assert(count==1); |
| 684 |
assert(tmp==0x01D0D3); |
| 685 |
} |
| 686 |
|
| 687 |
/* ================================ */ |
| 688 |
|
| 689 |
union MyUnion32 |
| 690 |
{ |
| 691 |
int i; |
| 692 |
byte b; |
| 693 |
} |
| 694 |
|
| 695 |
void test32() |
| 696 |
{ |
| 697 |
TypeInfo ti = typeid(MyUnion32*); |
| 698 |
assert(!(ti is null)); |
| 699 |
assert(ti.tsize==(MyUnion32*).sizeof); |
| 700 |
assert(ti.toString()=="run.module_01.MyUnion32*"); |
| 701 |
} |
| 702 |
|
| 703 |
/* ================================ */ |
| 704 |
|
| 705 |
void test35() |
| 706 |
{ |
| 707 |
try{ |
| 708 |
onOutOfMemoryError(); |
| 709 |
}catch(OutOfMemoryError e){ |
| 710 |
return; |
| 711 |
} |
| 712 |
assert(0); |
| 713 |
} |
| 714 |
|
| 715 |
/* ================================ */ |
| 716 |
|
| 717 |
void test36() |
| 718 |
{ |
| 719 |
try{ |
| 720 |
onOutOfMemoryError(); |
| 721 |
}catch(OutOfMemoryError e){ |
| 722 |
return; |
| 723 |
} |
| 724 |
assert(0); |
| 725 |
} |
| 726 |
|
| 727 |
/* ================================ */ |
| 728 |
|
| 729 |
struct S37{ |
| 730 |
int a; |
| 731 |
} |
| 732 |
|
| 733 |
const int i37 = 15; |
| 734 |
|
| 735 |
const S37 s1 = { i37+1 }; |
| 736 |
const S37 s2 = s1; |
| 737 |
|
| 738 |
void test37() |
| 739 |
{ |
| 740 |
assert(s1.a == 16); |
| 741 |
assert(s2.a == 16); |
| 742 |
} |
| 743 |
|
| 744 |
/* ================================ */ |
| 745 |
|
| 746 |
class Foo38 |
| 747 |
{ |
| 748 |
enum MyEnum{ |
| 749 |
VALUE_A=1, |
| 750 |
} |
| 751 |
} |
| 752 |
|
| 753 |
class Bar38 |
| 754 |
{ |
| 755 |
enum MyEnum{ |
| 756 |
VALUE_B=2, |
| 757 |
} |
| 758 |
} |
| 759 |
|
| 760 |
void test38() |
| 761 |
{ |
| 762 |
assert(Foo38.MyEnum.VALUE_A==1); |
| 763 |
assert(Bar38.MyEnum.VALUE_B==2); |
| 764 |
} |
| 765 |
|
| 766 |
/* ================================ */ |
| 767 |
|
| 768 |
void test39() |
| 769 |
{ |
| 770 |
bool[] bArray; |
| 771 |
int[] iArray; |
| 772 |
|
| 773 |
bArray[]=false; |
| 774 |
|
| 775 |
foreach(int c; iArray){ |
| 776 |
assert(0); |
| 777 |
} |
| 778 |
} |
| 779 |
|
| 780 |
/* ================================ */ |
| 781 |
|
| 782 |
bool checked40; |
| 783 |
|
| 784 |
class Parent40{ |
| 785 |
int x; |
| 786 |
|
| 787 |
void test(){ |
| 788 |
} |
| 789 |
|
| 790 |
invariant() |
| 791 |
{ |
| 792 |
assert(!checked40); |
| 793 |
checked40=true; |
| 794 |
// even number |
| 795 |
assert((x&1u)==0); |
| 796 |
} |
| 797 |
} |
| 798 |
|
| 799 |
class Child40 : Parent40{ |
| 800 |
} |
| 801 |
|
| 802 |
class GrandChild40 : Child40{ |
| 803 |
this(){ |
| 804 |
x=5; |
| 805 |
} |
| 806 |
} |
| 807 |
|
| 808 |
void test40() |
| 809 |
{ |
| 810 |
try{ |
| 811 |
assert(!checked40); |
| 812 |
GrandChild40 gc = new GrandChild40(); |
| 813 |
}catch(Throwable){ |
| 814 |
assert(checked40); |
| 815 |
return; |
| 816 |
} |
| 817 |
assert(0); |
| 818 |
} |
| 819 |
|
| 820 |
/* ================================ */ |
| 821 |
|
| 822 |
int counter41; |
| 823 |
|
| 824 |
class C41{ |
| 825 |
this(){ |
| 826 |
printf("this: counter41 = %d\n", counter41); |
| 827 |
assert(counter41==0); |
| 828 |
counter41+=2; |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
void test41() |
| 833 |
{ |
| 834 |
C41 c; |
| 835 |
assert(counter41==0); |
| 836 |
c = new C41(); |
| 837 |
assert(counter41==2); |
| 838 |
} |
| 839 |
|
| 840 |
/* ================================ */ |
| 841 |
|
| 842 |
struct S42{ |
| 843 |
int y; |
| 844 |
void* x; |
| 845 |
} |
| 846 |
|
| 847 |
void test42() |
| 848 |
{ |
| 849 |
size_t t; |
| 850 |
t = S42.y.offsetof; |
| 851 |
assert(t == 0); |
| 852 |
t = S42.x.offsetof; |
| 853 |
assert((t % (void*).sizeof) == 0); |
| 854 |
} |
| 855 |
|
| 856 |
/* ================================ */ |
| 857 |
|
| 858 |
int main() |
| 859 |
{ |
| 860 |
test1(); |
| 861 |
test2(); |
| 862 |
test3(); |
| 863 |
test4(); |
| 864 |
test5(); |
| 865 |
test6(); |
| 866 |
test7(); |
| 867 |
test8(); |
| 868 |
test9(); |
| 869 |
test10(); |
| 870 |
test11(); |
| 871 |
test12(); |
| 872 |
test13(); |
| 873 |
test14(); |
| 874 |
test15(); |
| 875 |
test16(); |
| 876 |
test17(); |
| 877 |
test18(); |
| 878 |
test19(); |
| 879 |
test20(); |
| 880 |
test21(); |
| 881 |
test22(); |
| 882 |
test23(); |
| 883 |
test24(); |
| 884 |
test25(); |
| 885 |
test26(); |
| 886 |
test27(); |
| 887 |
test28(); |
| 888 |
test29(); |
| 889 |
test30(); |
| 890 |
test31(); |
| 891 |
test32(); |
| 892 |
test35(); |
| 893 |
test36(); |
| 894 |
test37(); |
| 895 |
test38(); |
| 896 |
test39(); |
| 897 |
test40(); |
| 898 |
test41(); |
| 899 |
test42(); |
| 900 |
|
| 901 |
printf("Success\n"); |
| 902 |
return 0; |
| 903 |
} |