| 1 |
/* |
| 2 |
REQUIRED_ARGS: |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
success |
| 6 |
myInt int |
| 7 |
myBool bool |
| 8 |
i |
| 9 |
s |
| 10 |
C6test42__T4T219TiZ1C |
| 11 |
C6test427test219FZ8__mixin11C |
| 12 |
--- |
| 13 |
*/ |
| 14 |
|
| 15 |
module test42; |
| 16 |
|
| 17 |
import core.stdc.stdio; |
| 18 |
import core.memory; |
| 19 |
import core.vararg; |
| 20 |
|
| 21 |
/***************************************************/ |
| 22 |
|
| 23 |
class Foo { |
| 24 |
template myCast(T) { |
| 25 |
T myCast(U)(U val) { |
| 26 |
return cast(T) val; |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void test1() |
| 32 |
{ |
| 33 |
Foo foo = new Foo; |
| 34 |
int i = foo.myCast!(int)(1.0); |
| 35 |
} |
| 36 |
|
| 37 |
/***************************************************/ |
| 38 |
|
| 39 |
template A() |
| 40 |
{ |
| 41 |
static T foo(T)(T t) { return 7 + t; } |
| 42 |
} |
| 43 |
|
| 44 |
struct Bar |
| 45 |
{ |
| 46 |
mixin A!() a; |
| 47 |
} |
| 48 |
|
| 49 |
void test2() |
| 50 |
{ |
| 51 |
auto i = A!().foo(1); |
| 52 |
assert(i == 8); |
| 53 |
i = Bar.a.foo!(int)(2); |
| 54 |
assert(i == 9); |
| 55 |
i = Bar.a.foo(3); |
| 56 |
assert(i == 10); |
| 57 |
} |
| 58 |
|
| 59 |
/***************************************************/ |
| 60 |
|
| 61 |
void test3() |
| 62 |
{ |
| 63 |
auto i = mixin("__LINE__"); |
| 64 |
printf("%d\n", i); |
| 65 |
assert(i == 63); |
| 66 |
} |
| 67 |
|
| 68 |
/***************************************************/ |
| 69 |
|
| 70 |
class C4 |
| 71 |
{ |
| 72 |
void Stamp(){} |
| 73 |
|
| 74 |
this() { } |
| 75 |
|
| 76 |
S4 cursor; |
| 77 |
} |
| 78 |
|
| 79 |
struct S4 |
| 80 |
{ |
| 81 |
} |
| 82 |
|
| 83 |
void test4() |
| 84 |
{ |
| 85 |
} |
| 86 |
|
| 87 |
/***************************************************/ |
| 88 |
|
| 89 |
char a5 = (cast(char[])['a']) [$-1]; |
| 90 |
|
| 91 |
void test5() |
| 92 |
{ |
| 93 |
assert(a5 == 'a'); |
| 94 |
} |
| 95 |
|
| 96 |
/***************************************************/ |
| 97 |
// https://issues.dlang.org/show_bug.cgi?id=1200 |
| 98 |
// One case moved to deprecate1.d |
| 99 |
|
| 100 |
void foo6a() { |
| 101 |
do |
| 102 |
debug {} |
| 103 |
while (true); |
| 104 |
} |
| 105 |
|
| 106 |
void foo6b() { |
| 107 |
while (true) |
| 108 |
debug {} |
| 109 |
} |
| 110 |
|
| 111 |
void foo6c() { |
| 112 |
with (Object.init) |
| 113 |
debug {} |
| 114 |
} |
| 115 |
|
| 116 |
void foo6d() { |
| 117 |
synchronized debug {} |
| 118 |
} |
| 119 |
|
| 120 |
void foo6e() { |
| 121 |
// volatile debug {} |
| 122 |
} |
| 123 |
|
| 124 |
void test6() |
| 125 |
{ |
| 126 |
} |
| 127 |
|
| 128 |
/***************************************************/ |
| 129 |
|
| 130 |
class C7 { |
| 131 |
public this(){ |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
interface I7 { |
| 136 |
void fnc(); |
| 137 |
} |
| 138 |
|
| 139 |
void test7() |
| 140 |
{ |
| 141 |
char[][] t; |
| 142 |
foreach( char[] c; t ){ |
| 143 |
new class( c ) C7, I7 { |
| 144 |
public this( char[] c ){ |
| 145 |
super(); |
| 146 |
} |
| 147 |
void fnc(){ |
| 148 |
} |
| 149 |
}; |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
/***************************************************/ |
| 154 |
|
| 155 |
const ulong[] A8 = ([1LU])[0..$]; |
| 156 |
|
| 157 |
void test8() |
| 158 |
{ |
| 159 |
assert(A8[0] == 1); |
| 160 |
} |
| 161 |
|
| 162 |
/***************************************************/ |
| 163 |
|
| 164 |
void test9() |
| 165 |
{ |
| 166 |
//writeln(long.max.stringof); |
| 167 |
//writeln(ulong.max.stringof); |
| 168 |
assert(long.max.stringof == "9223372036854775807L"); |
| 169 |
assert(ulong.max.stringof == "18446744073709551615LU"); |
| 170 |
} |
| 171 |
|
| 172 |
/***************************************************/ |
| 173 |
|
| 174 |
const ulong[] A10 = [1UL]; |
| 175 |
const ulong[] B10 = A10 ~ [1UL]; |
| 176 |
|
| 177 |
void test10() |
| 178 |
{ |
| 179 |
} |
| 180 |
|
| 181 |
/***************************************************/ |
| 182 |
|
| 183 |
class Base11 { |
| 184 |
private final void foo() {} |
| 185 |
} |
| 186 |
|
| 187 |
class Derived11 : Base11 { |
| 188 |
void foo() {} |
| 189 |
} |
| 190 |
|
| 191 |
void test11() |
| 192 |
{ |
| 193 |
} |
| 194 |
|
| 195 |
/***************************************************/ |
| 196 |
|
| 197 |
void test12() |
| 198 |
{ |
| 199 |
int[] bar; |
| 200 |
assert((bar ~ 1).length == bar.length + 1); |
| 201 |
|
| 202 |
int[][] baz; |
| 203 |
assert((baz ~ cast(int[])[1]).length == baz.length + 1); |
| 204 |
|
| 205 |
char[][] foo; |
| 206 |
assert((foo ~ cast(char[])"foo").length == foo.length + 1); |
| 207 |
assert((cast(char[])"foo" ~ foo).length == foo.length + 1); |
| 208 |
|
| 209 |
printf("%zd\n", (foo ~ cast(char[])"foo")[0].length); |
| 210 |
|
| 211 |
assert((foo ~ [cast(char[])"foo"]).length == foo.length + 1); |
| 212 |
|
| 213 |
char[] qux; |
| 214 |
assert(([qux] ~ cast(char[])"foo").length == [qux].length + 1); |
| 215 |
|
| 216 |
assert(([cast(dchar[])"asdf"] ~ cast(dchar[])"foo").length == [cast(dchar[])"asdf"].length + 1); |
| 217 |
|
| 218 |
string[] quux; |
| 219 |
auto quuux = quux.dup; |
| 220 |
quuux ~= "foo"; |
| 221 |
assert (quuux.length == quux.length + 1); |
| 222 |
} |
| 223 |
|
| 224 |
/***************************************************/ |
| 225 |
|
| 226 |
int prop() { return 3; } |
| 227 |
|
| 228 |
void test13() |
| 229 |
{ |
| 230 |
auto x = prop; |
| 231 |
assert(x == 3); |
| 232 |
} |
| 233 |
|
| 234 |
/***************************************************/ |
| 235 |
|
| 236 |
void recurse(ref int i) |
| 237 |
{ |
| 238 |
int j = i; |
| 239 |
recurse(j); |
| 240 |
} |
| 241 |
|
| 242 |
void test14() |
| 243 |
{ |
| 244 |
} |
| 245 |
|
| 246 |
/***************************************************/ |
| 247 |
|
| 248 |
void bar15(void delegate(int) dg) |
| 249 |
{ |
| 250 |
dg(7); |
| 251 |
} |
| 252 |
|
| 253 |
class C15 |
| 254 |
{ |
| 255 |
int x; |
| 256 |
|
| 257 |
private void callback(int i) |
| 258 |
{ |
| 259 |
x = i + 3; |
| 260 |
} |
| 261 |
|
| 262 |
void foo() |
| 263 |
{ |
| 264 |
bar15(&callback); |
| 265 |
assert(x == 10); |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
void test15() |
| 270 |
{ |
| 271 |
C15 c = new C15(); |
| 272 |
|
| 273 |
c.foo(); |
| 274 |
} |
| 275 |
|
| 276 |
/***************************************************/ |
| 277 |
|
| 278 |
void bar16(int i, ...) { } |
| 279 |
|
| 280 |
void foo16() { } |
| 281 |
void foo16(int) { } |
| 282 |
|
| 283 |
void test16() |
| 284 |
{ |
| 285 |
bar16(1, cast(void function())&foo16); |
| 286 |
} |
| 287 |
|
| 288 |
/***************************************************/ |
| 289 |
|
| 290 |
void foo17(char[4] buf, dchar c) { } |
| 291 |
void foo17(string s) { } |
| 292 |
void foo17(wstring s) { } |
| 293 |
|
| 294 |
|
| 295 |
void test17() |
| 296 |
{ |
| 297 |
wstring w; |
| 298 |
.foo17(w); |
| 299 |
} |
| 300 |
|
| 301 |
/***************************************************/ |
| 302 |
|
| 303 |
struct S18 |
| 304 |
{ |
| 305 |
version (Dversion2) |
| 306 |
{ |
| 307 |
static void opCall(string msg) { assert(0); } |
| 308 |
} |
| 309 |
static void opCall() { } |
| 310 |
} |
| 311 |
|
| 312 |
void test18() |
| 313 |
{ |
| 314 |
S18(); |
| 315 |
} |
| 316 |
|
| 317 |
/***************************************************/ |
| 318 |
|
| 319 |
class C19 |
| 320 |
{ |
| 321 |
version (Dversion2) |
| 322 |
{ |
| 323 |
static void opCall(string msg) { assert(0); } |
| 324 |
} |
| 325 |
static void opCall() { } |
| 326 |
} |
| 327 |
|
| 328 |
void test19() |
| 329 |
{ |
| 330 |
C19(); |
| 331 |
} |
| 332 |
|
| 333 |
/***************************************************/ |
| 334 |
|
| 335 |
extern (System) void test20() |
| 336 |
{ |
| 337 |
} |
| 338 |
|
| 339 |
/***************************************************/ |
| 340 |
|
| 341 |
void func21() |
| 342 |
{ |
| 343 |
} |
| 344 |
|
| 345 |
int foo21() |
| 346 |
{ |
| 347 |
return *cast(int*)&func21; |
| 348 |
} |
| 349 |
|
| 350 |
void test21() |
| 351 |
{ |
| 352 |
foo21(); |
| 353 |
} |
| 354 |
|
| 355 |
/***************************************************/ |
| 356 |
|
| 357 |
void bar22(alias T)() |
| 358 |
{ |
| 359 |
assert(3 == T); |
| 360 |
} |
| 361 |
|
| 362 |
class Test22 |
| 363 |
{ |
| 364 |
int a; |
| 365 |
mixin bar22!(a); |
| 366 |
} |
| 367 |
|
| 368 |
void test22() |
| 369 |
{ |
| 370 |
Test22 t = new Test22(); |
| 371 |
t.a = 3; |
| 372 |
t.bar22(); |
| 373 |
} |
| 374 |
|
| 375 |
/***************************************************/ |
| 376 |
|
| 377 |
static this() |
| 378 |
{ |
| 379 |
printf("one\n"); |
| 380 |
} |
| 381 |
|
| 382 |
static this() |
| 383 |
{ |
| 384 |
printf("two\n"); |
| 385 |
} |
| 386 |
|
| 387 |
static ~this() |
| 388 |
{ |
| 389 |
printf("~two\n"); |
| 390 |
} |
| 391 |
|
| 392 |
static ~this() |
| 393 |
{ |
| 394 |
printf("~one\n"); |
| 395 |
} |
| 396 |
|
| 397 |
void test23() |
| 398 |
{ |
| 399 |
} |
| 400 |
|
| 401 |
/***************************************************/ |
| 402 |
|
| 403 |
class Foo24 |
| 404 |
{ |
| 405 |
static string gen() |
| 406 |
{ |
| 407 |
return "abc"; |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
auto s24 = Foo24.gen(); |
| 412 |
|
| 413 |
void test24() |
| 414 |
{ |
| 415 |
assert(s24 == "abc"); |
| 416 |
} |
| 417 |
|
| 418 |
/***************************************************/ |
| 419 |
|
| 420 |
void test25() |
| 421 |
{ |
| 422 |
int[10] arrayA = [0,1,2,3,4,5,6,7,8,9]; |
| 423 |
foreach(int i; arrayA) |
| 424 |
{ |
| 425 |
printf("%d\n", i); |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
/************************************/ |
| 430 |
|
| 431 |
const char[][7] DAY_NAME = [ |
| 432 |
DAY.SUN: "sunday", "monday", "tuesday", "wednesday", |
| 433 |
"thursday", "friday", "saturday" |
| 434 |
]; |
| 435 |
|
| 436 |
enum DAY { SUN, MON, TUE, WED, THU, FRI, SAT } |
| 437 |
|
| 438 |
void test27() |
| 439 |
{ |
| 440 |
assert(DAY_NAME[DAY.SUN] == "sunday"); |
| 441 |
assert(DAY_NAME[DAY.MON] == "monday"); |
| 442 |
assert(DAY_NAME[DAY.TUE] == "tuesday"); |
| 443 |
assert(DAY_NAME[DAY.WED] == "wednesday"); |
| 444 |
assert(DAY_NAME[DAY.THU] == "thursday"); |
| 445 |
assert(DAY_NAME[DAY.FRI] == "friday"); |
| 446 |
assert(DAY_NAME[DAY.SAT] == "saturday"); |
| 447 |
} |
| 448 |
|
| 449 |
/***************************************************/ |
| 450 |
|
| 451 |
void test28() |
| 452 |
{ |
| 453 |
} |
| 454 |
|
| 455 |
/***************************************************/ |
| 456 |
|
| 457 |
struct C29 { |
| 458 |
|
| 459 |
C29 copy() { return this; } |
| 460 |
} |
| 461 |
|
| 462 |
void foo29(C29 _c) { |
| 463 |
|
| 464 |
foo29( _c.copy() ); |
| 465 |
} |
| 466 |
|
| 467 |
void test29() { |
| 468 |
|
| 469 |
C29 c; |
| 470 |
|
| 471 |
//foo(c); |
| 472 |
} |
| 473 |
|
| 474 |
/***************************************************/ |
| 475 |
|
| 476 |
template Tuple31(T...) { alias T Tuple31; } |
| 477 |
alias Tuple31!(int,int) TType31; |
| 478 |
|
| 479 |
void bar31(TType31) { |
| 480 |
} |
| 481 |
|
| 482 |
void test31() |
| 483 |
{ |
| 484 |
} |
| 485 |
|
| 486 |
/***************************************************/ |
| 487 |
|
| 488 |
template Foo32(T : S!(T), alias S) |
| 489 |
{ |
| 490 |
alias int Foo32; |
| 491 |
} |
| 492 |
|
| 493 |
struct Struct32(T) |
| 494 |
{ |
| 495 |
} |
| 496 |
|
| 497 |
void test32() |
| 498 |
{ |
| 499 |
Foo32!(Struct32!(int)) f; |
| 500 |
} |
| 501 |
|
| 502 |
/***************************************************/ |
| 503 |
|
| 504 |
void test33() |
| 505 |
{ |
| 506 |
string a = "a"; |
| 507 |
string b = "b"; |
| 508 |
string c = a ~ b; |
| 509 |
assert(c == "ab"); |
| 510 |
} |
| 511 |
|
| 512 |
/***************************************************/ |
| 513 |
|
| 514 |
void foo34(in string s) |
| 515 |
{ |
| 516 |
string t = s; |
| 517 |
} |
| 518 |
|
| 519 |
void test34() |
| 520 |
{ |
| 521 |
} |
| 522 |
|
| 523 |
/***************************************************/ |
| 524 |
|
| 525 |
struct S35 |
| 526 |
{ |
| 527 |
string toString() |
| 528 |
{ |
| 529 |
return "foo"; |
| 530 |
} |
| 531 |
} |
| 532 |
|
| 533 |
void test35() |
| 534 |
{ S35 s; |
| 535 |
auto t = typeid(S35); |
| 536 |
//writefln("s = %s", s); |
| 537 |
//writefln("s = %s", t); |
| 538 |
auto tis = cast(TypeInfo_Struct)t; |
| 539 |
//writefln("s = %s", tis); |
| 540 |
//writefln("s = %s", tis.xtoString); |
| 541 |
assert(tis.xtoString != null); |
| 542 |
} |
| 543 |
|
| 544 |
/***************************************************/ |
| 545 |
|
| 546 |
void test36() |
| 547 |
{ |
| 548 |
void[0] x; |
| 549 |
auto y = x; |
| 550 |
alias x z; |
| 551 |
} |
| 552 |
|
| 553 |
/***************************************************/ |
| 554 |
|
| 555 |
template isStaticArray(T : U[], U) |
| 556 |
{ |
| 557 |
const bool isStaticArray = is(typeof(U) == typeof(T.init)); |
| 558 |
} |
| 559 |
|
| 560 |
template isStaticArray(T, U = void) |
| 561 |
{ |
| 562 |
const bool isStaticArray = false; |
| 563 |
} |
| 564 |
|
| 565 |
template isStaticArray(T : T[N], size_t N) |
| 566 |
{ |
| 567 |
const bool isStaticArray = true; |
| 568 |
} |
| 569 |
|
| 570 |
static assert (isStaticArray!(int[51])); |
| 571 |
static assert (isStaticArray!(int[][2])); |
| 572 |
static assert (isStaticArray!(char[][int][11])); |
| 573 |
static assert (!isStaticArray!(int[])); |
| 574 |
static assert (!isStaticArray!(int[char])); |
| 575 |
static assert (!isStaticArray!(int[1][])); |
| 576 |
|
| 577 |
static assert(isStaticArray!(void[0])); |
| 578 |
|
| 579 |
void test37() |
| 580 |
{ |
| 581 |
} |
| 582 |
|
| 583 |
/***************************************************/ |
| 584 |
|
| 585 |
template Foo38(T) |
| 586 |
{ |
| 587 |
const bool Foo38 = false; |
| 588 |
} |
| 589 |
|
| 590 |
template Foo38(T : U[N], U, size_t N) |
| 591 |
{ |
| 592 |
const bool Foo38 = true; |
| 593 |
} |
| 594 |
|
| 595 |
void test38() |
| 596 |
{ |
| 597 |
static assert (Foo38!(int[51])); |
| 598 |
} |
| 599 |
|
| 600 |
/***************************************************/ |
| 601 |
|
| 602 |
void test39() |
| 603 |
{ |
| 604 |
} |
| 605 |
|
| 606 |
/***************************************************/ |
| 607 |
|
| 608 |
void test40() |
| 609 |
{ |
| 610 |
static x = [[1.0, 2.0], [3.0, 4.0]]; // works |
| 611 |
assert(x[0][0] == 1.0); |
| 612 |
assert(x[0][1] == 2.0); |
| 613 |
assert(x[1][0] == 3.0); |
| 614 |
assert(x[1][1] == 4.0); |
| 615 |
|
| 616 |
auto y = [[1.0, 2.0], [3.0, 4.0]]; // fails |
| 617 |
assert(y[0][0] == 1.0); |
| 618 |
assert(y[0][1] == 2.0); |
| 619 |
assert(y[1][0] == 3.0); |
| 620 |
assert(y[1][1] == 4.0); |
| 621 |
} |
| 622 |
|
| 623 |
/***************************************************/ |
| 624 |
|
| 625 |
align(16) struct S41 |
| 626 |
{ |
| 627 |
int[4] a; |
| 628 |
} |
| 629 |
|
| 630 |
shared int x41; |
| 631 |
shared S41 s41; |
| 632 |
|
| 633 |
void test41() |
| 634 |
{ |
| 635 |
printf("&x = %p\n", &x41); |
| 636 |
printf("&s = %p\n", &s41); |
| 637 |
assert((cast(int)&s41 & 0xF) == 0); |
| 638 |
} |
| 639 |
|
| 640 |
/***************************************************/ |
| 641 |
|
| 642 |
int test42(string[] args = null) |
| 643 |
{ |
| 644 |
foreach(p; args){ |
| 645 |
version(dummy) int i; |
| 646 |
} |
| 647 |
return 0; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
/***************************************************/ |
| 652 |
|
| 653 |
void foo43(float length, byte b) |
| 654 |
{ |
| 655 |
// b /= cast(cfloat) length; |
| 656 |
} |
| 657 |
|
| 658 |
void test43() |
| 659 |
{ |
| 660 |
} |
| 661 |
|
| 662 |
/***************************************************/ |
| 663 |
|
| 664 |
int foo45(int i) |
| 665 |
{ |
| 666 |
if(i==0){ |
| 667 |
return 2; |
| 668 |
} |
| 669 |
assert(0); |
| 670 |
} |
| 671 |
|
| 672 |
void test45() |
| 673 |
{ |
| 674 |
version (Win32) // this test fails in -release because asserts will be removed |
| 675 |
{ |
| 676 |
assert(foo45(0)==2); |
| 677 |
try{ |
| 678 |
foo45(1); |
| 679 |
}catch(Throwable){ |
| 680 |
return cast(void)0; |
| 681 |
} |
| 682 |
assert(0); |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
/***************************************************/ |
| 687 |
|
| 688 |
|
| 689 |
void va_copy46(out void* dest, void* src) |
| 690 |
{ |
| 691 |
dest = src; |
| 692 |
} |
| 693 |
|
| 694 |
void test46() |
| 695 |
{ |
| 696 |
} |
| 697 |
|
| 698 |
/***************************************************/ |
| 699 |
|
| 700 |
void test47() |
| 701 |
{ |
| 702 |
enum { _P_WAIT, _P_NOWAIT, _P_OVERLAY } |
| 703 |
|
| 704 |
alias _P_WAIT P_WAIT; |
| 705 |
alias _P_NOWAIT P_NOWAIT; |
| 706 |
} |
| 707 |
|
| 708 |
/***************************************************/ |
| 709 |
|
| 710 |
void f48(int x) |
| 711 |
{ |
| 712 |
const(char)[] blah = (x == 1 ? "hello".dup : "world"); |
| 713 |
} |
| 714 |
|
| 715 |
void test48() |
| 716 |
{ |
| 717 |
f48(1); |
| 718 |
} |
| 719 |
|
| 720 |
/***************************************************/ |
| 721 |
|
| 722 |
void test49() |
| 723 |
{ |
| 724 |
version(GNU) |
| 725 |
{ |
| 726 |
assert((25.5).stringof ~ (3.0625).stringof == "2.55e+13.0625e+0"); |
| 727 |
assert(25.5.stringof ~ 3.0625.stringof == "2.55e+13.0625e+0"); |
| 728 |
} |
| 729 |
else |
| 730 |
{ |
| 731 |
assert((25.5).stringof ~ (3.01).stringof == "25.53.01"); |
| 732 |
assert(25.5.stringof ~ 3.01.stringof == "25.53.01"); |
| 733 |
} |
| 734 |
} |
| 735 |
|
| 736 |
/***************************************************/ |
| 737 |
|
| 738 |
class Ap50 |
| 739 |
{ |
| 740 |
ulong size; |
| 741 |
static uint valuex; |
| 742 |
|
| 743 |
void update(ubyte input, int i) |
| 744 |
{ |
| 745 |
valuex = |
| 746 |
(((size + i) & 1) == 0) ? |
| 747 |
0 : |
| 748 |
input; |
| 749 |
} |
| 750 |
} |
| 751 |
|
| 752 |
void test50() |
| 753 |
{ |
| 754 |
} |
| 755 |
|
| 756 |
/***************************************************/ |
| 757 |
|
| 758 |
int* foo51() |
| 759 |
{ |
| 760 |
assert(is(typeof(return) == int*)); |
| 761 |
return null; |
| 762 |
} |
| 763 |
|
| 764 |
void test51() |
| 765 |
{ |
| 766 |
foo51(); |
| 767 |
} |
| 768 |
|
| 769 |
/***************************************************/ |
| 770 |
|
| 771 |
template Foo52(ulong U) |
| 772 |
{ |
| 773 |
int Foo52 = 1; |
| 774 |
} |
| 775 |
|
| 776 |
template Foo52(uint U) |
| 777 |
{ |
| 778 |
int Foo52 = 2; |
| 779 |
} |
| 780 |
|
| 781 |
template Foo52(ubyte U) |
| 782 |
{ |
| 783 |
int Foo52 = 3; |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
void test52() |
| 788 |
{ |
| 789 |
const uint u = 3; |
| 790 |
auto s = Foo52!(u); |
| 791 |
assert(s == 2); |
| 792 |
} |
| 793 |
|
| 794 |
/***************************************************/ |
| 795 |
|
| 796 |
void test53() |
| 797 |
{ |
| 798 |
extern int x; |
| 799 |
} |
| 800 |
|
| 801 |
/***************************************************/ |
| 802 |
|
| 803 |
void func54(string delegate() dg) |
| 804 |
{ |
| 805 |
dg(); |
| 806 |
} |
| 807 |
|
| 808 |
void test54() |
| 809 |
{ |
| 810 |
string[] k=["adf","AsdfadSF","dfdsfassdf"]; |
| 811 |
foreach(d;k) |
| 812 |
{ |
| 813 |
printf("%.*s\n", cast(int)d.length, d.ptr); |
| 814 |
string foo() {assert(d!="");return d;} |
| 815 |
func54(&foo); |
| 816 |
func54(delegate string() {assert(d!="");return d;}); |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
/***************************************************/ |
| 821 |
// https://issues.dlang.org/show_bug.cgi?id=1767 |
| 822 |
|
| 823 |
class DebugInfo |
| 824 |
{ |
| 825 |
alias int CVHeaderType ; |
| 826 |
enum anon:CVHeaderType{ CV_NONE, CV_DOS, CV_NT, CV_DBG } |
| 827 |
} |
| 828 |
|
| 829 |
void test55() |
| 830 |
{ |
| 831 |
} |
| 832 |
|
| 833 |
/***************************************************/ |
| 834 |
|
| 835 |
template T56() { int i; } |
| 836 |
|
| 837 |
struct S56 { |
| 838 |
alias T56!() data; |
| 839 |
} |
| 840 |
|
| 841 |
class C56 { |
| 842 |
alias T56!() data; |
| 843 |
} |
| 844 |
|
| 845 |
void test56() |
| 846 |
{ |
| 847 |
S56.data.i = 3; |
| 848 |
C56.data.i = 4; |
| 849 |
assert(S56.data.i == 4); |
| 850 |
} |
| 851 |
|
| 852 |
/***************************************************/ |
| 853 |
|
| 854 |
void writecrossing(bool goal) |
| 855 |
{ |
| 856 |
goal ? printf("escape\n") : printf("return\n"); |
| 857 |
} |
| 858 |
|
| 859 |
void test57() |
| 860 |
{ |
| 861 |
writecrossing(true); |
| 862 |
writecrossing(false); |
| 863 |
} |
| 864 |
|
| 865 |
/***************************************************/ |
| 866 |
|
| 867 |
void f58(int n) {} |
| 868 |
void g58(char[] s) {} |
| 869 |
|
| 870 |
char[][] a58; |
| 871 |
|
| 872 |
class bar58 |
| 873 |
{ |
| 874 |
int i; |
| 875 |
|
| 876 |
void func() { |
| 877 |
f58(i); |
| 878 |
|
| 879 |
foreach (s; a58) { |
| 880 |
if (s == s){} |
| 881 |
if (s[0..0] == "" && s[0..0]) |
| 882 |
g58(s); |
| 883 |
} |
| 884 |
|
| 885 |
f58(i); |
| 886 |
} |
| 887 |
} |
| 888 |
|
| 889 |
void test58() |
| 890 |
{ |
| 891 |
} |
| 892 |
|
| 893 |
/***************************************************/ |
| 894 |
|
| 895 |
void test59() |
| 896 |
{ |
| 897 |
int[] array = new int[5]; |
| 898 |
uint check = 0; |
| 899 |
foreach (it; array.ptr .. array.ptr + array.length) { |
| 900 |
++check; |
| 901 |
} |
| 902 |
assert(check == array.length); |
| 903 |
} |
| 904 |
|
| 905 |
/***************************************************/ |
| 906 |
|
| 907 |
final class Foo60() |
| 908 |
{ |
| 909 |
void bar() |
| 910 |
{ |
| 911 |
int baz; |
| 912 |
baz = 1; |
| 913 |
} |
| 914 |
} |
| 915 |
|
| 916 |
void test60() |
| 917 |
{ |
| 918 |
auto foo = new Foo60!(); |
| 919 |
} |
| 920 |
|
| 921 |
/***************************************************/ |
| 922 |
|
| 923 |
class ZipEntry61 |
| 924 |
{ |
| 925 |
ZipEntryInfo61 info; |
| 926 |
this() {} |
| 927 |
} |
| 928 |
struct ZipEntryInfo61 {} |
| 929 |
|
| 930 |
void test61() |
| 931 |
{ |
| 932 |
} |
| 933 |
|
| 934 |
/***************************************************/ |
| 935 |
|
| 936 |
void test62() |
| 937 |
{ |
| 938 |
int foo() { return 0; } |
| 939 |
int bar() { return 0; } |
| 940 |
|
| 941 |
auto t1 = typeid(typeof(foo)); |
| 942 |
auto t2 = typeid(typeof(bar)); |
| 943 |
|
| 944 |
t1.tsize(); |
| 945 |
} |
| 946 |
|
| 947 |
/***************************************************/ |
| 948 |
|
| 949 |
struct S63 |
| 950 |
{ |
| 951 |
int a; |
| 952 |
static int foo() |
| 953 |
{ |
| 954 |
return a.sizeof; |
| 955 |
} |
| 956 |
} |
| 957 |
|
| 958 |
void test63() |
| 959 |
{ |
| 960 |
int x = S63.a.sizeof; |
| 961 |
assert(x == 4); |
| 962 |
assert(S63.foo() == 4); |
| 963 |
} |
| 964 |
|
| 965 |
/***************************************************/ |
| 966 |
|
| 967 |
string[] foo64() |
| 968 |
{ |
| 969 |
return [[]]; |
| 970 |
} |
| 971 |
|
| 972 |
void test64() |
| 973 |
{ |
| 974 |
auto a = foo64(); |
| 975 |
assert(a.length == 1); |
| 976 |
assert(a[0].length == 0); |
| 977 |
} |
| 978 |
|
| 979 |
/***************************************************/ |
| 980 |
|
| 981 |
string[][] foo65() |
| 982 |
{ |
| 983 |
string[][] result = []; |
| 984 |
string[] s = []; |
| 985 |
result ~= [s]; |
| 986 |
return result; |
| 987 |
} |
| 988 |
|
| 989 |
void test65() |
| 990 |
{ |
| 991 |
auto s = foo65(); |
| 992 |
assert(s.length == 1); |
| 993 |
assert(s[0].length == 0); |
| 994 |
} |
| 995 |
|
| 996 |
/***************************************************/ |
| 997 |
|
| 998 |
string[][] foo66() |
| 999 |
{ |
| 1000 |
string[] strings = ["a","bc"]; |
| 1001 |
string [][] result = []; |
| 1002 |
foreach (s; strings) |
| 1003 |
{ |
| 1004 |
result ~= [s]; |
| 1005 |
} |
| 1006 |
return result; |
| 1007 |
} |
| 1008 |
|
| 1009 |
void test66() |
| 1010 |
{ |
| 1011 |
auto s = foo66(); |
| 1012 |
assert(s.length == 2); |
| 1013 |
assert(s[0].length == 1); |
| 1014 |
assert(s[0][0].length == 1); |
| 1015 |
assert(s[1].length == 1); |
| 1016 |
assert(s[1][0].length == 2); |
| 1017 |
} |
| 1018 |
|
| 1019 |
/***************************************************/ |
| 1020 |
|
| 1021 |
template Tuple67(A...) |
| 1022 |
{ |
| 1023 |
alias A Tuple67; |
| 1024 |
} |
| 1025 |
|
| 1026 |
template Bar67() |
| 1027 |
{ |
| 1028 |
const s = "a bar"; |
| 1029 |
} |
| 1030 |
|
| 1031 |
void test67() |
| 1032 |
{ |
| 1033 |
alias Tuple67!(Bar67!()) tuple; |
| 1034 |
static const i = 0; |
| 1035 |
alias tuple[0] bara; |
| 1036 |
alias tuple[i] barb; |
| 1037 |
|
| 1038 |
static assert(bara.s == "a bar"); |
| 1039 |
static assert(barb.s == "a bar"); |
| 1040 |
} |
| 1041 |
|
| 1042 |
/***************************************************/ |
| 1043 |
|
| 1044 |
template Tuple68(A...) |
| 1045 |
{ |
| 1046 |
alias A Tuple68; |
| 1047 |
} |
| 1048 |
|
| 1049 |
size_t foo68() |
| 1050 |
{ |
| 1051 |
return 1; |
| 1052 |
} |
| 1053 |
|
| 1054 |
void test68() |
| 1055 |
{ |
| 1056 |
alias Tuple68!("one", "two") tuple; |
| 1057 |
static assert(tuple[foo68()] == "two"); |
| 1058 |
} |
| 1059 |
|
| 1060 |
/***************************************************/ |
| 1061 |
|
| 1062 |
class Base69 {} |
| 1063 |
|
| 1064 |
class Da69 : Base69 {} |
| 1065 |
class Db69 : Base69 {} |
| 1066 |
|
| 1067 |
void test69() |
| 1068 |
{ int i; |
| 1069 |
auto b = i ? new Da69 : new Db69; |
| 1070 |
assert(is(typeof(b) == Base69)); |
| 1071 |
} |
| 1072 |
|
| 1073 |
/***************************************************/ |
| 1074 |
|
| 1075 |
struct Bar70 |
| 1076 |
{ |
| 1077 |
Bar70[] bars; |
| 1078 |
} |
| 1079 |
|
| 1080 |
void test70() |
| 1081 |
{ |
| 1082 |
Bar70 node; |
| 1083 |
} |
| 1084 |
|
| 1085 |
/***************************************************/ |
| 1086 |
|
| 1087 |
template Foo71(string s) |
| 1088 |
{ |
| 1089 |
string b = s; |
| 1090 |
} |
| 1091 |
|
| 1092 |
void test71() |
| 1093 |
{ |
| 1094 |
size_t s = Foo71!( |
| 1095 |
"helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1096 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1097 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1098 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1099 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1100 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1101 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1102 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1103 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1104 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1105 |
~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" |
| 1106 |
~ "When dealing with complex template tuples, it's very easy to overflow the |
| 1107 |
maximum symbol length allowed by OPTLINK. This is, simply put, a damn shame, |
| 1108 |
because it prevents otherwise completely legal code from compiling and linking |
| 1109 |
with DMDWin, whereas it works perfectly fine when using DMDNix or GDC. |
| 1110 |
I know that this is neither a simple nor a small issue to fix: either the |
| 1111 |
ancient, nearly-immutable OPTLINK would have to be modified, or DMDWin would |
| 1112 |
have to be changed to output a more reasonable format, in which case a new |
| 1113 |
linker would probably have to be written. Until then, this issue should stand |
| 1114 |
as a reminder that DMDWin is inherently limited. |
| 1115 |
Oplink isn't the issue. The OMF file format has a hard limit. This results in |
| 1116 |
the only solutions being: convert DMD to use some other .obj format or have DMD |
| 1117 |
do something else for name mangling. |
| 1118 |
In talking to Walter, the issue is that it's easy to get symbols that have more |
| 1119 |
info in them than can be fit into the limit. (the limit has already stretched |
| 1120 |
by gziping the symbols.) |
| 1121 |
The simple solution I have proposed is to just MD5 (or what not) the symbols. |
| 1122 |
The only issue (besides a vanishingly small chance of a hash collision) is that |
| 1123 |
this looses information so you can't look at a symbol and directly determine |
| 1124 |
what it was. My answer to that is, who cares? The only place where hashing |
| 1125 |
provides less info than compressing is in a debugger and it can grab the full |
| 1126 |
symbol from a table in the static data segment. |
| 1127 |
I suppose as a stopgap measure that'd work fine, and might even be controlled |
| 1128 |
by a compiler switch, so that in the general case debugger info wouldn't be |
| 1129 |
affected. And what's more -- the only time these issues come up is with |
| 1130 |
templates, which a lot of debuggers have serious problems with anyway, so.. |
| 1131 |
I would set it up as a method of last resort. It wouldn't be used unless the |
| 1132 |
symbol can't be used any other way. |
| 1133 |
" |
| 1134 |
).b.length; |
| 1135 |
} |
| 1136 |
|
| 1137 |
/***************************************************/ |
| 1138 |
|
| 1139 |
class B72 { this(bool b, string c){} } |
| 1140 |
|
| 1141 |
class C72 : B72 |
| 1142 |
{ |
| 1143 |
this() |
| 1144 |
{ |
| 1145 |
alias typeof(super(false,"hello")) foo; |
| 1146 |
super(false,"hello"); |
| 1147 |
} |
| 1148 |
} |
| 1149 |
|
| 1150 |
void test72() |
| 1151 |
{ |
| 1152 |
} |
| 1153 |
|
| 1154 |
/***************************************************/ |
| 1155 |
|
| 1156 |
template Foo73() |
| 1157 |
{ |
| 1158 |
mixin ("const int x = 3;"); |
| 1159 |
//const int x = 3; |
| 1160 |
|
| 1161 |
static if (x == 3) |
| 1162 |
{ |
| 1163 |
pragma(msg, "success"); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
|
| 1167 |
alias Foo73!() foo73; |
| 1168 |
|
| 1169 |
void test73() |
| 1170 |
{ |
| 1171 |
} |
| 1172 |
|
| 1173 |
/***************************************************/ |
| 1174 |
|
| 1175 |
alias uint foo74; |
| 1176 |
|
| 1177 |
void simple_func_t(T)(T s, foo74 i) |
| 1178 |
{ |
| 1179 |
assert(s == "hello"); |
| 1180 |
assert(i == 3); |
| 1181 |
} |
| 1182 |
|
| 1183 |
void test74() |
| 1184 |
{ |
| 1185 |
simple_func_t("hello", 3); |
| 1186 |
} |
| 1187 |
|
| 1188 |
/***************************************************/ |
| 1189 |
|
| 1190 |
void foo75(T)(T[] x ...) |
| 1191 |
{ |
| 1192 |
assert(x.length == 3); |
| 1193 |
assert(x[0] == 2); |
| 1194 |
assert(x[1] == 3); |
| 1195 |
assert(x[2] == 4); |
| 1196 |
assert(is(T == int)); |
| 1197 |
} |
| 1198 |
|
| 1199 |
void test75() |
| 1200 |
{ |
| 1201 |
foo75(2,3,4); |
| 1202 |
} |
| 1203 |
|
| 1204 |
/***************************************************/ |
| 1205 |
|
| 1206 |
void delegate(U) Curry(A, U...)(void delegate(A,U) dg,A arg) |
| 1207 |
{ |
| 1208 |
struct ArgRecord { |
| 1209 |
A arg; |
| 1210 |
typeof(dg) callback; |
| 1211 |
|
| 1212 |
void OpCall(U args) { callback(arg,args); } |
| 1213 |
} |
| 1214 |
auto temp = new ArgRecord; |
| 1215 |
temp.arg = arg; |
| 1216 |
temp.callback = dg; |
| 1217 |
return &temp.OpCall; |
| 1218 |
} |
| 1219 |
|
| 1220 |
void delegate(A) Seq(A...)(void delegate(A)[] dgs...) |
| 1221 |
{ |
| 1222 |
return Curry(delegate void(void delegate(A)[] dgs1,A args) |
| 1223 |
{ |
| 1224 |
foreach(dg; dgs1) |
| 1225 |
dg(args); |
| 1226 |
}, |
| 1227 |
dgs); |
| 1228 |
} |
| 1229 |
|
| 1230 |
struct Foo76 |
| 1231 |
{ |
| 1232 |
void fred(int i) {} |
| 1233 |
} |
| 1234 |
|
| 1235 |
void test76() |
| 1236 |
{ |
| 1237 |
void delegate(int) tmp; |
| 1238 |
auto bob = new Foo76; |
| 1239 |
auto dan = new Foo76; |
| 1240 |
|
| 1241 |
tmp = Seq!(int)(&bob.fred); // this works |
| 1242 |
tmp = Seq!(int)(&bob.fred, &dan.fred); // this works |
| 1243 |
tmp = Seq (&bob.fred); // this doesn't |
| 1244 |
tmp = Seq (&bob.fred, &dan.fred); // neither does this |
| 1245 |
} |
| 1246 |
|
| 1247 |
/***************************************************/ |
| 1248 |
|
| 1249 |
int x77; |
| 1250 |
|
| 1251 |
void foo77() |
| 1252 |
{ |
| 1253 |
x77 = 1; |
| 1254 |
|
| 1255 |
static if(true) |
| 1256 |
{ |
| 1257 |
} |
| 1258 |
else |
| 1259 |
{ |
| 1260 |
} |
| 1261 |
} |
| 1262 |
|
| 1263 |
void test77() |
| 1264 |
{ |
| 1265 |
foo77(); |
| 1266 |
assert(x77 == 1); |
| 1267 |
} |
| 1268 |
|
| 1269 |
/***************************************************/ |
| 1270 |
|
| 1271 |
class Foo78 |
| 1272 |
{ |
| 1273 |
template TBar(T) |
| 1274 |
{ |
| 1275 |
T x; // Compiles, but is implicitly static |
| 1276 |
void func(T t) // Ok, non-static member template function |
| 1277 |
{ assert(t == 2); assert(this.bar == 42); } |
| 1278 |
} |
| 1279 |
int bar = 42; |
| 1280 |
} |
| 1281 |
|
| 1282 |
void test78() |
| 1283 |
{ |
| 1284 |
alias Foo78 Foo; |
| 1285 |
Foo.TBar!(int).x = 2; |
| 1286 |
//Foo.TBar!(int).func(2); // error, since funcx is not static |
| 1287 |
|
| 1288 |
Foo f = new Foo; |
| 1289 |
Foo g = new Foo; |
| 1290 |
|
| 1291 |
f.TBar!(int).func(2); // works |
| 1292 |
|
| 1293 |
f.TBar!(int).x = 10; |
| 1294 |
g.TBar!(int).x = 20; |
| 1295 |
assert(f.TBar!(int).x == 20); // prints 20 |
| 1296 |
} |
| 1297 |
|
| 1298 |
/***************************************************/ |
| 1299 |
|
| 1300 |
class C79 |
| 1301 |
{ |
| 1302 |
} |
| 1303 |
|
| 1304 |
void test79() |
| 1305 |
{ |
| 1306 |
C79 c = new C79(); |
| 1307 |
// writeln(c.__vptr); |
| 1308 |
// writeln(c.__vptr[0]); |
| 1309 |
// writeln(cast(void*)c.classinfo); |
| 1310 |
assert(c.__vptr[0] == cast(void*)c.classinfo); |
| 1311 |
// writeln(c.__monitor); |
| 1312 |
assert(c.__monitor == null); |
| 1313 |
synchronized (c) |
| 1314 |
{ |
| 1315 |
// writeln(c.__monitor); |
| 1316 |
assert(c.__monitor !is null); |
| 1317 |
} |
| 1318 |
} |
| 1319 |
|
| 1320 |
/***************************************************/ |
| 1321 |
|
| 1322 |
class Test80{ |
| 1323 |
template test(){ |
| 1324 |
enum int test=1; |
| 1325 |
} |
| 1326 |
} |
| 1327 |
|
| 1328 |
void test80() |
| 1329 |
{ |
| 1330 |
assert(Test80.test!()==1); |
| 1331 |
assert((new Test80).test!()==1); |
| 1332 |
} |
| 1333 |
|
| 1334 |
/***************************************************/ |
| 1335 |
|
| 1336 |
class Test81 |
| 1337 |
{ |
| 1338 |
static const test2=1; |
| 1339 |
template test(){ |
| 1340 |
static const int test=1; |
| 1341 |
} |
| 1342 |
} |
| 1343 |
|
| 1344 |
void test81() |
| 1345 |
{ |
| 1346 |
auto a=new Test81; |
| 1347 |
static assert(typeof(a).test2==1);//ok |
| 1348 |
alias typeof(a) t; |
| 1349 |
static assert(t.test!()==1);//ok |
| 1350 |
static assert(typeof(a).test!()==1);//syntax error |
| 1351 |
} |
| 1352 |
|
| 1353 |
/***************************************************/ |
| 1354 |
|
| 1355 |
deprecated |
| 1356 |
{ |
| 1357 |
alias real A82; |
| 1358 |
void foo82(A82 x) { } |
| 1359 |
} |
| 1360 |
|
| 1361 |
void test82() |
| 1362 |
{ |
| 1363 |
} |
| 1364 |
|
| 1365 |
/***************************************************/ |
| 1366 |
|
| 1367 |
class Bar83 |
| 1368 |
{ |
| 1369 |
deprecated void foo(int param) |
| 1370 |
{ |
| 1371 |
} |
| 1372 |
|
| 1373 |
void foo(string param) |
| 1374 |
{ |
| 1375 |
} |
| 1376 |
} |
| 1377 |
|
| 1378 |
void test83() |
| 1379 |
{ |
| 1380 |
Bar83 b = new Bar83; |
| 1381 |
string str = "bar"; |
| 1382 |
b.foo(str); |
| 1383 |
} |
| 1384 |
|
| 1385 |
/***************************************************/ |
| 1386 |
|
| 1387 |
void test84() |
| 1388 |
{ |
| 1389 |
int[0][10] arr; |
| 1390 |
printf("%tu\n", &arr[9] - &arr[0]); |
| 1391 |
auto i = &arr[9] - &arr[0]; |
| 1392 |
assert(i == 0); |
| 1393 |
} |
| 1394 |
|
| 1395 |
/***************************************************/ |
| 1396 |
|
| 1397 |
class myid |
| 1398 |
{ |
| 1399 |
string buf; |
| 1400 |
this(string str ) |
| 1401 |
{ |
| 1402 |
buf = str; |
| 1403 |
} |
| 1404 |
} |
| 1405 |
struct Lex |
| 1406 |
{ |
| 1407 |
static myid myidinst; |
| 1408 |
static void Init() |
| 1409 |
{ |
| 1410 |
myidinst = new myid("abc"); |
| 1411 |
} |
| 1412 |
} |
| 1413 |
|
| 1414 |
void test85() |
| 1415 |
{ |
| 1416 |
Lex.Init(); |
| 1417 |
assert(cast(myid)(Lex.myidinst) !is null); |
| 1418 |
} |
| 1419 |
|
| 1420 |
/***************************************************/ |
| 1421 |
|
| 1422 |
struct Time |
| 1423 |
{ |
| 1424 |
long ticks; |
| 1425 |
} |
| 1426 |
|
| 1427 |
struct Stamps |
| 1428 |
{ |
| 1429 |
Time created, /// time created |
| 1430 |
accessed, /// last time accessed |
| 1431 |
modified; /// last time modified |
| 1432 |
} |
| 1433 |
|
| 1434 |
Stamps getTimeStamps() |
| 1435 |
{ |
| 1436 |
foreach(i; 0..10) { } |
| 1437 |
Stamps time = void; |
| 1438 |
|
| 1439 |
time.modified = Time(20); |
| 1440 |
time.accessed = Time(20); |
| 1441 |
time.created = Time(20); |
| 1442 |
return time; |
| 1443 |
} |
| 1444 |
|
| 1445 |
Time accessed () |
| 1446 |
{ |
| 1447 |
foreach(i; 0..10) { } |
| 1448 |
return timeStamps(4).accessed; |
| 1449 |
} |
| 1450 |
|
| 1451 |
Stamps timeStamps (int name) |
| 1452 |
{ |
| 1453 |
return getTimeStamps(); |
| 1454 |
} |
| 1455 |
|
| 1456 |
void test86() |
| 1457 |
{ |
| 1458 |
|
| 1459 |
assert(accessed().ticks == 20); |
| 1460 |
} |
| 1461 |
|
| 1462 |
/***************************************************/ |
| 1463 |
|
| 1464 |
const bool foo87 = is(typeof(function void() { })); |
| 1465 |
const bar87 = is(typeof(function void() { })); |
| 1466 |
|
| 1467 |
void test87() |
| 1468 |
{ |
| 1469 |
assert(foo87 == true); |
| 1470 |
assert(bar87 == true); |
| 1471 |
} |
| 1472 |
|
| 1473 |
/***************************************************/ |
| 1474 |
|
| 1475 |
int function() wrap88(void function()) { return null; } |
| 1476 |
|
| 1477 |
void test88() |
| 1478 |
{ |
| 1479 |
printf("test88\n"); |
| 1480 |
if (0) |
| 1481 |
wrap88(&test88)(); |
| 1482 |
} |
| 1483 |
|
| 1484 |
/***************************************************/ |
| 1485 |
|
| 1486 |
struct S89 |
| 1487 |
{ |
| 1488 |
static const float[2] z = 3; |
| 1489 |
} |
| 1490 |
|
| 1491 |
class C89 |
| 1492 |
{ |
| 1493 |
static const float[2] z = 3; |
| 1494 |
} |
| 1495 |
|
| 1496 |
void bar89(float f) { assert(f == 3); } |
| 1497 |
|
| 1498 |
void test89() |
| 1499 |
{ |
| 1500 |
printf("test89\n"); |
| 1501 |
bar89(S89.z[0]); |
| 1502 |
bar89(S89.z[1]); |
| 1503 |
bar89(C89.z[0]); |
| 1504 |
bar89(C89.z[1]); |
| 1505 |
} |
| 1506 |
|
| 1507 |
/***************************************************/ |
| 1508 |
|
| 1509 |
void trigger(char[] txt) |
| 1510 |
{ |
| 1511 |
txt[0] = 'x'; |
| 1512 |
|
| 1513 |
scope(exit) |
| 1514 |
{ |
| 1515 |
txt[0] = 'x'; |
| 1516 |
} |
| 1517 |
|
| 1518 |
return; |
| 1519 |
} |
| 1520 |
|
| 1521 |
void test90() |
| 1522 |
{ |
| 1523 |
} |
| 1524 |
|
| 1525 |
/***************************************************/ |
| 1526 |
|
| 1527 |
void test91() |
| 1528 |
{ |
| 1529 |
enum ABC { a, b, c } |
| 1530 |
assert(ABC.stringof == "ABC"); |
| 1531 |
} |
| 1532 |
|
| 1533 |
/***************************************************/ |
| 1534 |
|
| 1535 |
int x92; |
| 1536 |
|
| 1537 |
int f92() { |
| 1538 |
x92++; |
| 1539 |
return 0; |
| 1540 |
} |
| 1541 |
|
| 1542 |
void test92() |
| 1543 |
{ |
| 1544 |
int[1] a; |
| 1545 |
a[f92()] += 42L; |
| 1546 |
assert(x92 == 1); |
| 1547 |
} |
| 1548 |
|
| 1549 |
/***************************************************/ |
| 1550 |
|
| 1551 |
void test93() |
| 1552 |
{ |
| 1553 |
void foo() { } |
| 1554 |
static assert(is(typeof(1 || foo()) == void)); |
| 1555 |
static assert(is(typeof(1 && foo()) == void)); |
| 1556 |
} |
| 1557 |
|
| 1558 |
/***************************************************/ |
| 1559 |
|
| 1560 |
void foo94(T)() |
| 1561 |
{ |
| 1562 |
} |
| 1563 |
|
| 1564 |
struct f94(alias func=foo94!(int)) |
| 1565 |
{ |
| 1566 |
} |
| 1567 |
|
| 1568 |
void test94() |
| 1569 |
{ |
| 1570 |
f94!() myf; |
| 1571 |
} |
| 1572 |
|
| 1573 |
/***************************************************/ |
| 1574 |
|
| 1575 |
struct X95 |
| 1576 |
{ |
| 1577 |
import core.stdc.stdio; |
| 1578 |
} |
| 1579 |
|
| 1580 |
void test95() |
| 1581 |
{ |
| 1582 |
X95.core.stdc.stdio.printf("hello\n"); |
| 1583 |
} |
| 1584 |
|
| 1585 |
/***************************************************/ |
| 1586 |
|
| 1587 |
template foo96(alias bar) |
| 1588 |
{ |
| 1589 |
pragma(msg, bar.stringof ~ " " ~ typeof(bar).stringof); |
| 1590 |
static assert((bar.stringof ~ " " ~ typeof(bar).stringof) == "myInt int" || |
| 1591 |
(bar.stringof ~ " " ~ typeof(bar).stringof) == "myBool bool"); |
| 1592 |
void foo96() {} |
| 1593 |
} |
| 1594 |
|
| 1595 |
void test96() |
| 1596 |
{ |
| 1597 |
int myInt; |
| 1598 |
bool myBool; |
| 1599 |
|
| 1600 |
foo96!(myInt)(); |
| 1601 |
foo96!(myBool)(); |
| 1602 |
} |
| 1603 |
|
| 1604 |
/***************************************************/ |
| 1605 |
|
| 1606 |
void test97() |
| 1607 |
{ |
| 1608 |
const short[] ct = cast(short[]) [cast(byte)1, 1]; |
| 1609 |
// writeln(ct); |
| 1610 |
assert(ct.length == 2 && ct[0] == 1 && ct[1] == 1); |
| 1611 |
|
| 1612 |
short[] rt = cast(short[]) [cast(byte)1, cast(byte)1].dup; |
| 1613 |
// writeln(rt); |
| 1614 |
assert(rt.length == 1 && rt[0] == 257); |
| 1615 |
} |
| 1616 |
|
| 1617 |
/***************************************************/ |
| 1618 |
|
| 1619 |
class Foo98 |
| 1620 |
{ |
| 1621 |
string foo = "abc"; |
| 1622 |
size_t i = 0; |
| 1623 |
|
| 1624 |
void bar() |
| 1625 |
{ |
| 1626 |
printf("%c\n", foo[i]); |
| 1627 |
i++; |
| 1628 |
printf("%c\n", foo[i]); |
| 1629 |
assert(foo[i] == 'b'); |
| 1630 |
} |
| 1631 |
} |
| 1632 |
|
| 1633 |
void test98() |
| 1634 |
{ |
| 1635 |
auto f = new Foo98(); |
| 1636 |
f.bar(); |
| 1637 |
} |
| 1638 |
|
| 1639 |
/***************************************************/ |
| 1640 |
|
| 1641 |
template implicitlyConverts99(S, T) |
| 1642 |
{ |
| 1643 |
enum bool implicitlyConverts99 = T.sizeof >= S.sizeof |
| 1644 |
&& is(typeof({S s; T t = s;}())); |
| 1645 |
} |
| 1646 |
|
| 1647 |
static assert(!implicitlyConverts99!(long, short)); |
| 1648 |
|
| 1649 |
void test99() |
| 1650 |
{ |
| 1651 |
} |
| 1652 |
|
| 1653 |
/***************************************************/ |
| 1654 |
|
| 1655 |
void test100() |
| 1656 |
{ |
| 1657 |
static void check(ulong value) |
| 1658 |
{ |
| 1659 |
real r = value; |
| 1660 |
ulong d = cast(ulong)r; |
| 1661 |
printf("ulong: %llu => real: %Lg => ulong: %llu\n", value, r, d); |
| 1662 |
assert(d == value); |
| 1663 |
} |
| 1664 |
|
| 1665 |
// check biggest power of 2 representable in ulong: 2^63 |
| 1666 |
check(1L << 63); |
| 1667 |
|
| 1668 |
// check biggest representable uneven number |
| 1669 |
static if (real.mant_dig >= 64) // > 64: limited by ulong precision |
| 1670 |
check(ulong.max); // 2^64-1 |
| 1671 |
else |
| 1672 |
check((1L << real.mant_dig) - 1); |
| 1673 |
} |
| 1674 |
|
| 1675 |
/***************************************************/ |
| 1676 |
|
| 1677 |
auto e101(int x) { return 5; } |
| 1678 |
|
| 1679 |
void test101() |
| 1680 |
{ |
| 1681 |
assert(is(typeof(e101(3)) == int)); |
| 1682 |
} |
| 1683 |
|
| 1684 |
/***************************************************/ |
| 1685 |
|
| 1686 |
int x103; |
| 1687 |
|
| 1688 |
void external(...) |
| 1689 |
{ |
| 1690 |
int arg = va_arg!int(_argptr); |
| 1691 |
printf("external: %d\n", arg); |
| 1692 |
x103 = arg; |
| 1693 |
} |
| 1694 |
|
| 1695 |
class C103 |
| 1696 |
{ |
| 1697 |
void method () |
| 1698 |
{ |
| 1699 |
void internal (...) |
| 1700 |
{ |
| 1701 |
int arg = va_arg!int(_argptr); |
| 1702 |
printf("internal: %d\n", arg); |
| 1703 |
x103 = arg; |
| 1704 |
} |
| 1705 |
|
| 1706 |
internal (43); |
| 1707 |
assert(x103 == 43); |
| 1708 |
} |
| 1709 |
} |
| 1710 |
|
| 1711 |
void test103() |
| 1712 |
{ |
| 1713 |
external(42); |
| 1714 |
assert(x103 == 42); |
| 1715 |
(new C103).method (); |
| 1716 |
} |
| 1717 |
|
| 1718 |
/***************************************************/ |
| 1719 |
|
| 1720 |
class C104 |
| 1721 |
{ |
| 1722 |
template Bar() |
| 1723 |
{ |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
static assert(!is(typeof(C104.Bar.foo))); |
| 1728 |
|
| 1729 |
void test104() |
| 1730 |
{ |
| 1731 |
} |
| 1732 |
|
| 1733 |
/***************************************************/ |
| 1734 |
|
| 1735 |
template Templ(T) |
| 1736 |
{ |
| 1737 |
const char [] XXX = Type.mangleof; |
| 1738 |
alias T Type; |
| 1739 |
} |
| 1740 |
|
| 1741 |
void test105() |
| 1742 |
{ |
| 1743 |
Templ!(int).Type x; |
| 1744 |
auto s = Templ!(int).XXX; |
| 1745 |
printf("%.*s\n", cast(int)s.length, s.ptr); |
| 1746 |
assert(s == "i"); |
| 1747 |
} |
| 1748 |
|
| 1749 |
/***************************************************/ |
| 1750 |
// rejects-valid 2.012. |
| 1751 |
|
| 1752 |
class foo107 {} |
| 1753 |
alias foo107 bar107; |
| 1754 |
void x107() |
| 1755 |
{ |
| 1756 |
bar107 a = new bar107(); |
| 1757 |
bar107 b = new bar107(); |
| 1758 |
bool c = (a == b); |
| 1759 |
} |
| 1760 |
|
| 1761 |
void test107() |
| 1762 |
{ |
| 1763 |
} |
| 1764 |
|
| 1765 |
/***************************************************/ |
| 1766 |
|
| 1767 |
struct Foo108 |
| 1768 |
{ |
| 1769 |
char[] byLine()() |
| 1770 |
{ |
| 1771 |
return null; |
| 1772 |
} |
| 1773 |
} |
| 1774 |
|
| 1775 |
void test108() |
| 1776 |
{ Foo108 foo; |
| 1777 |
|
| 1778 |
foreach (char c; foo.byLine) |
| 1779 |
{ |
| 1780 |
} |
| 1781 |
} |
| 1782 |
|
| 1783 |
/***************************************************/ |
| 1784 |
|
| 1785 |
void test109() |
| 1786 |
{ |
| 1787 |
double[] x = new double[1]; |
| 1788 |
assert(x[0] != 0); |
| 1789 |
} |
| 1790 |
|
| 1791 |
/***************************************************/ |
| 1792 |
|
| 1793 |
void test110() |
| 1794 |
{ |
| 1795 |
struct C { |
| 1796 |
int[0] b; |
| 1797 |
} |
| 1798 |
static C g_c2_ = { }; |
| 1799 |
} |
| 1800 |
|
| 1801 |
/***************************************************/ |
| 1802 |
|
| 1803 |
template Foo111(T...) { |
| 1804 |
alias T Foo111; |
| 1805 |
} |
| 1806 |
|
| 1807 |
void test111() |
| 1808 |
{ |
| 1809 |
auto y = (Foo111!(int) x){ return 0; }; |
| 1810 |
} |
| 1811 |
|
| 1812 |
/***************************************************/ |
| 1813 |
|
| 1814 |
bool isNull(string str) { |
| 1815 |
return str is null; |
| 1816 |
} |
| 1817 |
|
| 1818 |
const bool foo112 = isNull("hello!"); |
| 1819 |
|
| 1820 |
void test112() |
| 1821 |
{ |
| 1822 |
assert(!foo112); |
| 1823 |
} |
| 1824 |
|
| 1825 |
/***************************************************/ |
| 1826 |
|
| 1827 |
void test113() |
| 1828 |
{ |
| 1829 |
for (int j=1; j<2; j++) { |
| 1830 |
int x = (j<0) ? -j : j; |
| 1831 |
int q=0; |
| 1832 |
for (int i=0; i<x; i++) ++q; |
| 1833 |
assert(q!=0); |
| 1834 |
} |
| 1835 |
} |
| 1836 |
|
| 1837 |
/***************************************************/ |
| 1838 |
|
| 1839 |
struct VariantN |
| 1840 |
{ |
| 1841 |
static int opCall(int value) |
| 1842 |
{ |
| 1843 |
return 0; |
| 1844 |
} |
| 1845 |
|
| 1846 |
void foo() |
| 1847 |
{ |
| 1848 |
VariantN v; |
| 1849 |
v.bar(42, 5); |
| 1850 |
} |
| 1851 |
|
| 1852 |
void bar(int value, int i) |
| 1853 |
{ |
| 1854 |
int[2] args = [ VariantN(value), VariantN(i) ]; |
| 1855 |
} |
| 1856 |
} |
| 1857 |
|
| 1858 |
void test114() |
| 1859 |
{ |
| 1860 |
} |
| 1861 |
|
| 1862 |
/***************************************************/ |
| 1863 |
|
| 1864 |
class B115 : A115!(B115) { } |
| 1865 |
class A115(T) { } |
| 1866 |
|
| 1867 |
void test115() |
| 1868 |
{ |
| 1869 |
} |
| 1870 |
|
| 1871 |
/***************************************************/ |
| 1872 |
|
| 1873 |
struct Foo116 { |
| 1874 |
this(U...)(U values) { } |
| 1875 |
} |
| 1876 |
|
| 1877 |
void test116() |
| 1878 |
{ |
| 1879 |
new Foo116; |
| 1880 |
} |
| 1881 |
|
| 1882 |
/***************************************************/ |
| 1883 |
|
| 1884 |
void test117() |
| 1885 |
{ |
| 1886 |
float f = 7; |
| 1887 |
f = f * 2; |
| 1888 |
assert(f == 14); |
| 1889 |
|
| 1890 |
double d = 7; |
| 1891 |
d = d * 2; |
| 1892 |
assert(d == 14); |
| 1893 |
|
| 1894 |
real r = 7; |
| 1895 |
r = r * 2; |
| 1896 |
assert(r == 14); |
| 1897 |
} |
| 1898 |
|
| 1899 |
/***************************************************/ |
| 1900 |
|
| 1901 |
void test118() |
| 1902 |
{ |
| 1903 |
int foo(real x) |
| 1904 |
{ |
| 1905 |
real y = -x*-x; |
| 1906 |
return cast(int)y; |
| 1907 |
} |
| 1908 |
|
| 1909 |
auto i = foo(4.0); |
| 1910 |
assert(i == 16); |
| 1911 |
} |
| 1912 |
|
| 1913 |
/***************************************************/ |
| 1914 |
|
| 1915 |
class A119 |
| 1916 |
{ |
| 1917 |
static class B119 : C119.D { } |
| 1918 |
} |
| 1919 |
|
| 1920 |
abstract class C119 |
| 1921 |
{ |
| 1922 |
static class D { } |
| 1923 |
} |
| 1924 |
|
| 1925 |
void test119() |
| 1926 |
{ |
| 1927 |
} |
| 1928 |
|
| 1929 |
/***************************************************/ |
| 1930 |
|
| 1931 |
class A120 { |
| 1932 |
class B120 : C120.D { } |
| 1933 |
} |
| 1934 |
|
| 1935 |
class C120 : E120 { |
| 1936 |
static class D { } |
| 1937 |
} |
| 1938 |
|
| 1939 |
interface E120 { } |
| 1940 |
|
| 1941 |
void test120() |
| 1942 |
{ |
| 1943 |
} |
| 1944 |
|
| 1945 |
/***************************************************/ |
| 1946 |
|
| 1947 |
void test121() |
| 1948 |
{ |
| 1949 |
static assert(null is null); |
| 1950 |
} |
| 1951 |
|
| 1952 |
/***************************************************/ |
| 1953 |
|
| 1954 |
T[] find123(alias pred, T)(T[] input) { |
| 1955 |
while (input.length > 0) { |
| 1956 |
if (pred(input[0])) break; |
| 1957 |
input = input[1 .. $]; |
| 1958 |
} |
| 1959 |
return input; |
| 1960 |
} |
| 1961 |
|
| 1962 |
void test123() |
| 1963 |
{ |
| 1964 |
int[] a = [ 1, 2, 3, 4, -5, 3, -4 ]; |
| 1965 |
find123!(function bool(int i) { return i < 0; })(a); |
| 1966 |
} |
| 1967 |
|
| 1968 |
|
| 1969 |
/***************************************************/ |
| 1970 |
|
| 1971 |
static assert(!is(typeof((){(){} |
| 1972 |
;-() |
| 1973 |
{};}))); |
| 1974 |
|
| 1975 |
/***************************************************/ |
| 1976 |
|
| 1977 |
struct Foobar; |
| 1978 |
|
| 1979 |
/***************************************************/ |
| 1980 |
|
| 1981 |
int test124() |
| 1982 |
{ int result; |
| 1983 |
dchar[] aa; |
| 1984 |
alias size_t foo_t; |
| 1985 |
|
| 1986 |
foreach (foo_t i, dchar d; aa) |
| 1987 |
{ |
| 1988 |
} |
| 1989 |
return result; |
| 1990 |
} |
| 1991 |
|
| 1992 |
/***************************************************/ |
| 1993 |
|
| 1994 |
int foo125(int x) |
| 1995 |
{ |
| 1996 |
while (1) |
| 1997 |
{ |
| 1998 |
if (x) |
| 1999 |
return 3; |
| 2000 |
x++; |
| 2001 |
} |
| 2002 |
} |
| 2003 |
|
| 2004 |
void test125() |
| 2005 |
{ |
| 2006 |
foo125(4); |
| 2007 |
} |
| 2008 |
|
| 2009 |
/***************************************************/ |
| 2010 |
|
| 2011 |
int foo126(int x) |
| 2012 |
{ |
| 2013 |
while (1) |
| 2014 |
{ |
| 2015 |
if (x) |
| 2016 |
return 3; |
| 2017 |
x++; |
| 2018 |
} |
| 2019 |
assert(0); |
| 2020 |
} |
| 2021 |
|
| 2022 |
void test126() |
| 2023 |
{ |
| 2024 |
foo126(4); |
| 2025 |
} |
| 2026 |
|
| 2027 |
/***************************************************/ |
| 2028 |
|
| 2029 |
struct S127(T, int topology = 1) |
| 2030 |
{ |
| 2031 |
this(T value) { } |
| 2032 |
} |
| 2033 |
|
| 2034 |
void cons127(int t)(S127!(int, t) tail) |
| 2035 |
{ |
| 2036 |
} |
| 2037 |
|
| 2038 |
void test127() |
| 2039 |
{ |
| 2040 |
S127!(int)(1); |
| 2041 |
S127!(int, 1) lst; |
| 2042 |
cons127(lst); |
| 2043 |
} |
| 2044 |
|
| 2045 |
/***************************************************/ |
| 2046 |
|
| 2047 |
struct S128(T, int topology = 1) |
| 2048 |
{ |
| 2049 |
this(T value) { } |
| 2050 |
} |
| 2051 |
|
| 2052 |
void cons128(int t)(S128!(int, t) tail) |
| 2053 |
{ |
| 2054 |
} |
| 2055 |
|
| 2056 |
void test128() |
| 2057 |
{ |
| 2058 |
S128!(int, 1)(1); |
| 2059 |
S128!(int) lst; |
| 2060 |
cons128(lst); |
| 2061 |
} |
| 2062 |
|
| 2063 |
/***************************************************/ |
| 2064 |
|
| 2065 |
struct R129(R : E[], E) |
| 2066 |
{ |
| 2067 |
E[] forward; |
| 2068 |
static R129 opCall(E[] range) |
| 2069 |
{ |
| 2070 |
R129 result = {}; |
| 2071 |
result.forward = range; |
| 2072 |
return result; |
| 2073 |
} |
| 2074 |
} |
| 2075 |
|
| 2076 |
R129!(E[]) retro129(E)(E[] r) |
| 2077 |
{ |
| 2078 |
return R129!(E[])(r); |
| 2079 |
} |
| 2080 |
|
| 2081 |
int begin129(F)(R129!(F) range) |
| 2082 |
{ |
| 2083 |
return 0; |
| 2084 |
} |
| 2085 |
|
| 2086 |
void test129() |
| 2087 |
{ |
| 2088 |
int[] a = [ 1, 2, 3 ]; |
| 2089 |
auto r = retro129(a); |
| 2090 |
auto i = begin129(r); |
| 2091 |
} |
| 2092 |
|
| 2093 |
/***************************************************/ |
| 2094 |
// https://issues.dlang.org/show_bug.cgi?id=12725 |
| 2095 |
|
| 2096 |
struct R12725(R : E[], E) |
| 2097 |
{ |
| 2098 |
} |
| 2099 |
|
| 2100 |
int begin12725(F)(R12725!(F) range) |
| 2101 |
{ |
| 2102 |
return 0; |
| 2103 |
} |
| 2104 |
|
| 2105 |
void test12725() |
| 2106 |
{ |
| 2107 |
R12725!(int[], int) r; |
| 2108 |
auto i = begin12725(r); |
| 2109 |
} |
| 2110 |
|
| 2111 |
/***************************************************/ |
| 2112 |
// https://issues.dlang.org/show_bug.cgi?id=12728 |
| 2113 |
|
| 2114 |
struct Matrix12728(T, uint m, uint n = m, ubyte f = 0) |
| 2115 |
{ |
| 2116 |
void foo(uint r)(const auto ref Matrix12728!(T, n, r) b) |
| 2117 |
{ |
| 2118 |
} |
| 2119 |
} |
| 2120 |
|
| 2121 |
void test12728() |
| 2122 |
{ |
| 2123 |
alias Matrix4 = Matrix12728!(float, 4); |
| 2124 |
|
| 2125 |
Matrix4 m; |
| 2126 |
m.foo(m); |
| 2127 |
} |
| 2128 |
|
| 2129 |
/***************************************************/ |
| 2130 |
|
| 2131 |
struct S130 |
| 2132 |
{ |
| 2133 |
byte[3] x; |
| 2134 |
} |
| 2135 |
|
| 2136 |
__gshared S130 e130; |
| 2137 |
|
| 2138 |
const(S130) example130() { return e130; } |
| 2139 |
|
| 2140 |
void test130() |
| 2141 |
{ |
| 2142 |
} |
| 2143 |
|
| 2144 |
/***************************************************/ |
| 2145 |
|
| 2146 |
void foo131(real z) {} |
| 2147 |
|
| 2148 |
void test131() |
| 2149 |
{ |
| 2150 |
real F = 1; |
| 2151 |
foo131( 1 + (F*3*2.1) ); |
| 2152 |
} |
| 2153 |
|
| 2154 |
/***************************************************/ |
| 2155 |
|
| 2156 |
float getFloat() { |
| 2157 |
return 11468.78f; |
| 2158 |
} |
| 2159 |
|
| 2160 |
void test132() |
| 2161 |
{ |
| 2162 |
uint i = cast(uint) 11468.78f; |
| 2163 |
assert(i == 11468); |
| 2164 |
|
| 2165 |
uint j = cast(uint) getFloat(); |
| 2166 |
assert(j == 11468); |
| 2167 |
} |
| 2168 |
|
| 2169 |
/***************************************************/ |
| 2170 |
|
| 2171 |
template T133(string s) { |
| 2172 |
const string T133 = s; |
| 2173 |
} |
| 2174 |
|
| 2175 |
string f133(string s) { |
| 2176 |
return s; |
| 2177 |
} |
| 2178 |
|
| 2179 |
void test133() |
| 2180 |
{ |
| 2181 |
int foo; |
| 2182 |
//writeln(foo.stringof); |
| 2183 |
assert ("foo" == f133(foo.stringof)); |
| 2184 |
assert ("foo" == T133!(foo.stringof)); |
| 2185 |
} |
| 2186 |
|
| 2187 |
/***************************************************/ |
| 2188 |
|
| 2189 |
public struct foo134 |
| 2190 |
{ |
| 2191 |
public this(real aleft) |
| 2192 |
{ |
| 2193 |
} |
| 2194 |
} |
| 2195 |
|
| 2196 |
class bar134 |
| 2197 |
{ |
| 2198 |
final void fun(foo134 arg = foo134(0.)) { } |
| 2199 |
} |
| 2200 |
|
| 2201 |
/***************************************************/ |
| 2202 |
|
| 2203 |
void test135() |
| 2204 |
{ |
| 2205 |
char[char[3]] ac; |
| 2206 |
char[3] c = "abc"; |
| 2207 |
ac["abc"]='a'; |
| 2208 |
assert(ac[c]=='a'); |
| 2209 |
|
| 2210 |
char[dchar[3]] ad; |
| 2211 |
dchar[3] d = "abc"d; |
| 2212 |
ad["abc"d]='a'; |
| 2213 |
assert(ad[d]=='a'); |
| 2214 |
} |
| 2215 |
|
| 2216 |
/***************************************************/ |
| 2217 |
|
| 2218 |
void test136() |
| 2219 |
{ |
| 2220 |
struct S { int[3] i; } |
| 2221 |
enum S s = S(8); |
| 2222 |
const int i = s.i[2]; |
| 2223 |
assert(i == 8); |
| 2224 |
} |
| 2225 |
|
| 2226 |
/***************************************************/ |
| 2227 |
|
| 2228 |
struct Particle { |
| 2229 |
char[16] name; |
| 2230 |
} |
| 2231 |
|
| 2232 |
class ReadSystem { |
| 2233 |
size_t[char[16]] pKindsIdx; |
| 2234 |
|
| 2235 |
void t(Particle p) |
| 2236 |
{ auto idx=p.name in pKindsIdx; |
| 2237 |
} |
| 2238 |
} |
| 2239 |
|
| 2240 |
void test137() |
| 2241 |
{ |
| 2242 |
char[16] n; |
| 2243 |
size_t[char[16]] aa; |
| 2244 |
auto r=n in aa; // works |
| 2245 |
} |
| 2246 |
|
| 2247 |
/***************************************************/ |
| 2248 |
|
| 2249 |
long test138(int y) |
| 2250 |
{ |
| 2251 |
return *cast(long*)(&y); |
| 2252 |
} |
| 2253 |
|
| 2254 |
/***************************************************/ |
| 2255 |
|
| 2256 |
void test139() |
| 2257 |
{ |
| 2258 |
auto famousNamedConstants = |
| 2259 |
[ "pi" : 3.14, "e" : 2.71, "moving sofa" : 2.22 ]; |
| 2260 |
|
| 2261 |
assert(famousNamedConstants["e"]==2.71); |
| 2262 |
} |
| 2263 |
|
| 2264 |
/***************************************************/ |
| 2265 |
|
| 2266 |
int* get140() { return (new int[4]).ptr; } |
| 2267 |
|
| 2268 |
void test140() |
| 2269 |
{ |
| 2270 |
int* p = get140(); |
| 2271 |
p[0..3] = 0; |
| 2272 |
p[0] = 7; |
| 2273 |
} |
| 2274 |
|
| 2275 |
/***************************************************/ |
| 2276 |
|
| 2277 |
class Foo141 { |
| 2278 |
Foo141 next; |
| 2279 |
void start() |
| 2280 |
in { assert (!next); } do |
| 2281 |
{ |
| 2282 |
void* p = cast(void*)this; |
| 2283 |
} |
| 2284 |
} |
| 2285 |
|
| 2286 |
/***************************************************/ |
| 2287 |
|
| 2288 |
void a142(int b = 1+2)(){}; |
| 2289 |
|
| 2290 |
void test142() |
| 2291 |
{ |
| 2292 |
a142!(1+2)(); |
| 2293 |
a142(); |
| 2294 |
} |
| 2295 |
|
| 2296 |
/***************************************************/ |
| 2297 |
|
| 2298 |
class A143 |
| 2299 |
{ |
| 2300 |
invariant() { } |
| 2301 |
void fill() { } |
| 2302 |
} |
| 2303 |
|
| 2304 |
|
| 2305 |
class B143 : A143 |
| 2306 |
{ |
| 2307 |
override void fill() { } |
| 2308 |
} |
| 2309 |
|
| 2310 |
void test143() |
| 2311 |
{ |
| 2312 |
auto b = new B143(); |
| 2313 |
b.fill(); |
| 2314 |
} |
| 2315 |
|
| 2316 |
/***************************************************/ |
| 2317 |
|
| 2318 |
struct Pair |
| 2319 |
{ |
| 2320 |
static Pair opCall(uint a, uint b) { return Pair.init; } |
| 2321 |
} |
| 2322 |
|
| 2323 |
struct Stack |
| 2324 |
{ |
| 2325 |
Pair pop() { return Pair.init; } |
| 2326 |
} |
| 2327 |
|
| 2328 |
void test144() |
| 2329 |
{ |
| 2330 |
Stack stack; |
| 2331 |
Pair item = stack.pop; |
| 2332 |
} |
| 2333 |
|
| 2334 |
/***************************************************/ |
| 2335 |
|
| 2336 |
struct Ashes { |
| 2337 |
int ashes = cast(int)0; |
| 2338 |
} |
| 2339 |
void funky (Ashes s = Ashes()) { } |
| 2340 |
|
| 2341 |
struct S145 { |
| 2342 |
real a = 0, b = 0; |
| 2343 |
} |
| 2344 |
|
| 2345 |
void func145(S145 s = S145()) { } |
| 2346 |
|
| 2347 |
void test145() |
| 2348 |
{ |
| 2349 |
funky(); |
| 2350 |
func145(); |
| 2351 |
} |
| 2352 |
|
| 2353 |
/***************************************************/ |
| 2354 |
|
| 2355 |
string foo146(T...)(T args) |
| 2356 |
{ |
| 2357 |
string ret; |
| 2358 |
|
| 2359 |
foreach(arg; args) { |
| 2360 |
ret = arg; |
| 2361 |
} |
| 2362 |
|
| 2363 |
assert(ret=="b"); // passes |
| 2364 |
return ret; |
| 2365 |
} |
| 2366 |
|
| 2367 |
void test146() |
| 2368 |
{ |
| 2369 |
string s = foo146("b"); |
| 2370 |
assert(s == "b"); // fails |
| 2371 |
} |
| 2372 |
|
| 2373 |
/***************************************************/ |
| 2374 |
|
| 2375 |
void test147() |
| 2376 |
{ |
| 2377 |
string s = "foo"; |
| 2378 |
dchar c = 'x'; |
| 2379 |
s ~= c; |
| 2380 |
assert(s == "foox"); |
| 2381 |
|
| 2382 |
wstring ws = "foo"; |
| 2383 |
ws ~= c; |
| 2384 |
assert(ws == "foox"); |
| 2385 |
} |
| 2386 |
|
| 2387 |
/***************************************************/ |
| 2388 |
|
| 2389 |
void test148() |
| 2390 |
{ |
| 2391 |
string a = "\U00091234"; |
| 2392 |
string b; |
| 2393 |
|
| 2394 |
b ~= "\U00091234"; |
| 2395 |
|
| 2396 |
if (a != b) { |
| 2397 |
assert(0); |
| 2398 |
} |
| 2399 |
} |
| 2400 |
|
| 2401 |
/***************************************************/ |
| 2402 |
|
| 2403 |
void test149() |
| 2404 |
{ |
| 2405 |
long[1] b = void; |
| 2406 |
b[0] = -1L; |
| 2407 |
b[0] >>>= 2; |
| 2408 |
assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL); |
| 2409 |
} |
| 2410 |
|
| 2411 |
/***************************************************/ |
| 2412 |
|
| 2413 |
bool foo150() |
| 2414 |
{ |
| 2415 |
int x; |
| 2416 |
return cast(void*) (x & 1) == null; |
| 2417 |
} |
| 2418 |
|
| 2419 |
/***************************************************/ |
| 2420 |
// https://issues.dlang.org/show_bug.cgi?id=3521 |
| 2421 |
|
| 2422 |
void crash(int x) |
| 2423 |
{ |
| 2424 |
if (x==200) return; |
| 2425 |
assert(0); |
| 2426 |
} |
| 2427 |
|
| 2428 |
void test151() |
| 2429 |
{ |
| 2430 |
int x; |
| 2431 |
bug3521(&x); |
| 2432 |
} |
| 2433 |
|
| 2434 |
void bug3521(int *a) |
| 2435 |
{ |
| 2436 |
int c = 0; |
| 2437 |
*a = 0; |
| 2438 |
if ( *a || (*a != (c = 200)) ) |
| 2439 |
crash(c); |
| 2440 |
} |
| 2441 |
|
| 2442 |
/***************************************************/ |
| 2443 |
|
| 2444 |
string foo152(T...)() { |
| 2445 |
return ""; |
| 2446 |
} |
| 2447 |
|
| 2448 |
void test152() { |
| 2449 |
foo152!(int, char)(); |
| 2450 |
} |
| 2451 |
|
| 2452 |
/***************************************************/ |
| 2453 |
|
| 2454 |
int get_value() |
| 2455 |
{ |
| 2456 |
return 1; |
| 2457 |
} |
| 2458 |
|
| 2459 |
int[2] array1; |
| 2460 |
int[2] array2; |
| 2461 |
|
| 2462 |
int foo153(ulong a1, ulong extra, ulong extra2, ulong extra3) |
| 2463 |
{ |
| 2464 |
if (!((a1 & 1) | (get_value() | array1[cast(uint)(a1^1)]))) |
| 2465 |
return 0; |
| 2466 |
|
| 2467 |
if (0 >= array2[cast(uint)(a1^1)]) |
| 2468 |
return 0; |
| 2469 |
|
| 2470 |
return 1; |
| 2471 |
} |
| 2472 |
|
| 2473 |
void test153() |
| 2474 |
{ |
| 2475 |
foo153(0, 0, 0, 0); |
| 2476 |
} |
| 2477 |
|
| 2478 |
/***************************************************/ |
| 2479 |
|
| 2480 |
class B154 : A154 |
| 2481 |
{ |
| 2482 |
} |
| 2483 |
|
| 2484 |
enum SomeEnum |
| 2485 |
{ |
| 2486 |
EnumMember = 10 |
| 2487 |
} |
| 2488 |
|
| 2489 |
class A154 |
| 2490 |
{ |
| 2491 |
SomeEnum someEnum() |
| 2492 |
{ |
| 2493 |
return SomeEnum.EnumMember; |
| 2494 |
} |
| 2495 |
} |
| 2496 |
|
| 2497 |
void test154() |
| 2498 |
{ |
| 2499 |
auto b = new B154(); |
| 2500 |
assert(cast(int)b.someEnum == 10); |
| 2501 |
} |
| 2502 |
|
| 2503 |
/***************************************************/ |
| 2504 |
|
| 2505 |
struct Qwert { |
| 2506 |
Yuiop.Asdfg hjkl; |
| 2507 |
} |
| 2508 |
|
| 2509 |
struct Yuiop { |
| 2510 |
struct Asdfg { |
| 2511 |
int zxcvb; |
| 2512 |
} |
| 2513 |
} |
| 2514 |
|
| 2515 |
/***************************************************/ |
| 2516 |
|
| 2517 |
void f156(Value156.Id t) |
| 2518 |
{ |
| 2519 |
assert(cast(int)t == 1); |
| 2520 |
} |
| 2521 |
|
| 2522 |
struct Value156 { |
| 2523 |
public static enum Id { |
| 2524 |
A, |
| 2525 |
B |
| 2526 |
} |
| 2527 |
} |
| 2528 |
|
| 2529 |
void test156() |
| 2530 |
{ |
| 2531 |
Value156.Id t = Value156.Id.B; |
| 2532 |
f156(t); |
| 2533 |
} |
| 2534 |
|
| 2535 |
/***************************************************/ |
| 2536 |
|
| 2537 |
X157 x157; |
| 2538 |
enum X157 { Y }; |
| 2539 |
|
| 2540 |
interface Foo157 { |
| 2541 |
Policy157 fn(); |
| 2542 |
} |
| 2543 |
|
| 2544 |
enum Policy157 {Default, Cached, Direct} |
| 2545 |
|
| 2546 |
void test157() |
| 2547 |
{ |
| 2548 |
} |
| 2549 |
|
| 2550 |
/***************************************************/ |
| 2551 |
|
| 2552 |
class X158 { |
| 2553 |
Y158.NY t; |
| 2554 |
enum NX { BLA, BLA1 } |
| 2555 |
} |
| 2556 |
|
| 2557 |
class Y158 { |
| 2558 |
enum NY { FOO, BAR } |
| 2559 |
X158.NX nx; |
| 2560 |
} |
| 2561 |
|
| 2562 |
/***************************************************/ |
| 2563 |
|
| 2564 |
struct Foo159 { |
| 2565 |
Bar.Baz x; |
| 2566 |
|
| 2567 |
struct Bar { |
| 2568 |
struct Baz {} |
| 2569 |
} |
| 2570 |
} |
| 2571 |
|
| 2572 |
/***************************************************/ |
| 2573 |
|
| 2574 |
void test160() |
| 2575 |
{ |
| 2576 |
long[1] b = void; |
| 2577 |
b[0] = -1L; |
| 2578 |
b[0] >>>= 2; |
| 2579 |
assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL); |
| 2580 |
int i = -1; |
| 2581 |
assert(i >>>2 == 0x3FFFFFFF); |
| 2582 |
} |
| 2583 |
|
| 2584 |
/***************************************************/ |
| 2585 |
|
| 2586 |
class A161 { |
| 2587 |
struct B { |
| 2588 |
D161 x; |
| 2589 |
|
| 2590 |
struct C {} |
| 2591 |
} |
| 2592 |
} |
| 2593 |
|
| 2594 |
|
| 2595 |
struct D161 {} |
| 2596 |
|
| 2597 |
class C161 |
| 2598 |
{ |
| 2599 |
A a; |
| 2600 |
|
| 2601 |
struct A |
| 2602 |
{ |
| 2603 |
uint m; |
| 2604 |
} |
| 2605 |
|
| 2606 |
enum |
| 2607 |
{ |
| 2608 |
E = 0 |
| 2609 |
} |
| 2610 |
} |
| 2611 |
|
| 2612 |
/***************************************************/ |
| 2613 |
|
| 2614 |
interface A162 |
| 2615 |
{ |
| 2616 |
C162 foo(); |
| 2617 |
C162 foo() const; |
| 2618 |
} |
| 2619 |
|
| 2620 |
class B162 : A162 |
| 2621 |
{ |
| 2622 |
C162 foo() { return null; } |
| 2623 |
C162 foo() const { return null; } |
| 2624 |
} |
| 2625 |
|
| 2626 |
abstract class C162 : A162 |
| 2627 |
{ |
| 2628 |
C162 foo() { return null; } |
| 2629 |
C162 foo() const { return null; } |
| 2630 |
} |
| 2631 |
|
| 2632 |
/***************************************************/ |
| 2633 |
|
| 2634 |
void func163( A... )( string name, string v ) |
| 2635 |
{ |
| 2636 |
} |
| 2637 |
|
| 2638 |
void test163() |
| 2639 |
{ |
| 2640 |
func163!( int, long, float )( "val", "10" ); |
| 2641 |
func163!()( "tmp", "77" ); |
| 2642 |
alias func163!() TMP; TMP( "tmp", "77" ); |
| 2643 |
} |
| 2644 |
|
| 2645 |
/***************************************************/ |
| 2646 |
|
| 2647 |
class A164 |
| 2648 |
{ |
| 2649 |
B164 foo() { return null; } |
| 2650 |
B164 foo() const { return null; } |
| 2651 |
} |
| 2652 |
|
| 2653 |
abstract class B164 : A164 |
| 2654 |
{ |
| 2655 |
override final B164 foo() { return null; } |
| 2656 |
override final B164 foo() const { return null; } |
| 2657 |
} |
| 2658 |
|
| 2659 |
/***************************************************/ |
| 2660 |
|
| 2661 |
class A165 |
| 2662 |
{ |
| 2663 |
B165 foo() { return null; } |
| 2664 |
const(B165) foo() const { return null; } |
| 2665 |
} |
| 2666 |
|
| 2667 |
abstract class B165 : A165 |
| 2668 |
{ |
| 2669 |
override final B165 foo() { return null; } |
| 2670 |
override final const(B165) foo() const { return null; } |
| 2671 |
} |
| 2672 |
|
| 2673 |
/***************************************************/ |
| 2674 |
|
| 2675 |
struct A166 { |
| 2676 |
B166 xxx; |
| 2677 |
static this () { } |
| 2678 |
} |
| 2679 |
|
| 2680 |
struct B166 {} |
| 2681 |
|
| 2682 |
/***************************************************/ |
| 2683 |
|
| 2684 |
void x168(T)() { |
| 2685 |
static assert(false); |
| 2686 |
} |
| 2687 |
|
| 2688 |
template y168(T) { |
| 2689 |
const bool y168 = is(typeof( { x168!(T)(); } )); |
| 2690 |
} |
| 2691 |
|
| 2692 |
static assert(!y168!(int)); |
| 2693 |
|
| 2694 |
/***************************************************/ |
| 2695 |
|
| 2696 |
void test169() |
| 2697 |
{ |
| 2698 |
int AssociativeArray; |
| 2699 |
int[int] foo; |
| 2700 |
foreach (x; foo) { } |
| 2701 |
} |
| 2702 |
|
| 2703 |
/***************************************************/ |
| 2704 |
|
| 2705 |
FwdEnum this_fails; |
| 2706 |
|
| 2707 |
enum : int |
| 2708 |
{ |
| 2709 |
E170 = 2 |
| 2710 |
} |
| 2711 |
|
| 2712 |
enum FwdEnum : int |
| 2713 |
{ |
| 2714 |
E2 = E170 |
| 2715 |
} |
| 2716 |
|
| 2717 |
/***************************************************/ |
| 2718 |
// https://issues.dlang.org/show_bug.cgi?id=3740 |
| 2719 |
|
| 2720 |
abstract class Address { |
| 2721 |
abstract int nameLen(); |
| 2722 |
} |
| 2723 |
|
| 2724 |
class Class171 : Address { |
| 2725 |
FwdStruct z; |
| 2726 |
|
| 2727 |
struct FwdStruct { } |
| 2728 |
|
| 2729 |
override int nameLen() { return 0; } |
| 2730 |
} |
| 2731 |
|
| 2732 |
void test171 () |
| 2733 |
{ |
| 2734 |
Class171 xxx = new Class171; |
| 2735 |
assert(typeid(Class171).vtbl.length - typeid(Object).vtbl.length == 1); |
| 2736 |
} |
| 2737 |
|
| 2738 |
/***************************************************/ |
| 2739 |
|
| 2740 |
struct Foo172 |
| 2741 |
{ |
| 2742 |
enum bool BAR = is (typeof({}())); |
| 2743 |
static assert (BAR == is (typeof({}()))); |
| 2744 |
} |
| 2745 |
|
| 2746 |
/***************************************************/ |
| 2747 |
|
| 2748 |
const char[][ 89 ] ENUM_NAME = [ 1:"N0" ]; |
| 2749 |
|
| 2750 |
void test173() |
| 2751 |
{ |
| 2752 |
switch(`Hi`.dup) { |
| 2753 |
case ENUM_NAME[1]: |
| 2754 |
default: |
| 2755 |
break; |
| 2756 |
} |
| 2757 |
} |
| 2758 |
|
| 2759 |
/***************************************************/ |
| 2760 |
|
| 2761 |
class A174 { |
| 2762 |
void x() { } |
| 2763 |
} |
| 2764 |
|
| 2765 |
class B174 : A174 { |
| 2766 |
override void x() { |
| 2767 |
assert(0); |
| 2768 |
} |
| 2769 |
final void do_x() { |
| 2770 |
super.x(); |
| 2771 |
} |
| 2772 |
} |
| 2773 |
|
| 2774 |
void test174() |
| 2775 |
{ |
| 2776 |
auto b = new B174(); |
| 2777 |
b.do_x(); |
| 2778 |
} |
| 2779 |
|
| 2780 |
/***************************************************/ |
| 2781 |
|
| 2782 |
void badvariadic(...) {} |
| 2783 |
|
| 2784 |
static assert(!is(typeof(mixin(badvariadic())))); |
| 2785 |
|
| 2786 |
/***************************************************/ |
| 2787 |
|
| 2788 |
struct Foo176 |
| 2789 |
{ |
| 2790 |
int x; |
| 2791 |
} |
| 2792 |
|
| 2793 |
Foo176 getFoo(Foo176 irrelevant) |
| 2794 |
{ |
| 2795 |
Foo176 p = Foo176(400); |
| 2796 |
if ( p.x > p.x ) |
| 2797 |
return irrelevant; |
| 2798 |
else |
| 2799 |
return p; |
| 2800 |
} |
| 2801 |
|
| 2802 |
void test176() |
| 2803 |
{ |
| 2804 |
assert(getFoo( Foo176(0) ).x == 400); |
| 2805 |
} |
| 2806 |
|
| 2807 |
/***************************************************/ |
| 2808 |
|
| 2809 |
int test177() |
| 2810 |
{ |
| 2811 |
long[1] c = [0]; // must be long |
| 2812 |
|
| 2813 |
int [1] d = [1]; |
| 2814 |
int k = 0; |
| 2815 |
if (!d[0]) |
| 2816 |
k = 1; |
| 2817 |
k = d[0] + k + k; |
| 2818 |
|
| 2819 |
if (c[0]) assert(c[0]); |
| 2820 |
|
| 2821 |
return k; |
| 2822 |
} |
| 2823 |
|
| 2824 |
/***************************************************/ |
| 2825 |
|
| 2826 |
struct S178 { |
| 2827 |
int x; |
| 2828 |
|
| 2829 |
template T(int val) { |
| 2830 |
enum S178 T = { val }; |
| 2831 |
} |
| 2832 |
} |
| 2833 |
|
| 2834 |
const x178 = S178.T!(0); |
| 2835 |
|
| 2836 |
/***************************************************/ |
| 2837 |
|
| 2838 |
double[100_000] arr = 0.0; |
| 2839 |
|
| 2840 |
/***************************************************/ |
| 2841 |
|
| 2842 |
struct S179 { |
| 2843 |
char a, b, c, d; |
| 2844 |
} |
| 2845 |
|
| 2846 |
void show(char[] args...) { |
| 2847 |
assert(args[0]=='A'); |
| 2848 |
assert(args[1]=='L'); |
| 2849 |
assert(args[2]=='D'); |
| 2850 |
assert(args[3]=='O'); |
| 2851 |
} |
| 2852 |
|
| 2853 |
void A179( S179 ss ) { |
| 2854 |
show( ss.a, ss.b, ss.c, ss.d ); |
| 2855 |
} |
| 2856 |
|
| 2857 |
void test179() |
| 2858 |
{ |
| 2859 |
S179 ss3; |
| 2860 |
ss3.a = 'A'; |
| 2861 |
ss3.b = 'L'; |
| 2862 |
ss3.c = 'D'; |
| 2863 |
ss3.d = 'O'; |
| 2864 |
A179( ss3 ); |
| 2865 |
} |
| 2866 |
|
| 2867 |
/***************************************************/ |
| 2868 |
|
| 2869 |
struct XY { union { int x, y; } } |
| 2870 |
struct AHolder { |
| 2871 |
XY aa; |
| 2872 |
void a(XY x) { aa = x; } |
| 2873 |
} |
| 2874 |
struct AB { |
| 2875 |
AHolder aHolder; |
| 2876 |
XY b; |
| 2877 |
void a(XY x) { aHolder.a(x); } |
| 2878 |
} |
| 2879 |
struct Main { |
| 2880 |
AB ab; |
| 2881 |
|
| 2882 |
void setB() { ab.b = XY(); } |
| 2883 |
void f() { |
| 2884 |
ab.a(XY.init); |
| 2885 |
setB(); |
| 2886 |
} |
| 2887 |
} |
| 2888 |
|
| 2889 |
/***************************************************/ |
| 2890 |
|
| 2891 |
void fooa181(int x, int y, int[0] a, int z, int t) |
| 2892 |
{ |
| 2893 |
if (!(x == 2 && y == 4 && z == 6 && t == 8)) |
| 2894 |
assert(0); |
| 2895 |
} |
| 2896 |
|
| 2897 |
void foob181(int x, int y, int[0] a) |
| 2898 |
{ |
| 2899 |
if (!(x == 2 && y == 4)) |
| 2900 |
assert(0); |
| 2901 |
} |
| 2902 |
|
| 2903 |
void fooc181(int[0] a, int x, int y) |
| 2904 |
{ |
| 2905 |
if (!(x == 2 && y == 4)) |
| 2906 |
assert(0); |
| 2907 |
} |
| 2908 |
|
| 2909 |
void food181(int[0] a) |
| 2910 |
{ |
| 2911 |
} |
| 2912 |
|
| 2913 |
void test181() |
| 2914 |
{ |
| 2915 |
int[0] arr = 0; |
| 2916 |
fooa181(2, 4, arr, 6, 8); |
| 2917 |
foob181(2, 4, arr); |
| 2918 |
fooc181(arr, 2, 4); |
| 2919 |
food181(arr); |
| 2920 |
} |
| 2921 |
|
| 2922 |
/***************************************************/ |
| 2923 |
// https://issues.dlang.org/show_bug.cgi?id=4042 |
| 2924 |
|
| 2925 |
template isQObjectType(T) |
| 2926 |
{ |
| 2927 |
enum isQObjectType = is(T.__isQObjectType); |
| 2928 |
} |
| 2929 |
|
| 2930 |
template QTypeInfo(T) |
| 2931 |
{ |
| 2932 |
static if (!isQObjectType!T) |
| 2933 |
{ |
| 2934 |
enum size = T.sizeof; |
| 2935 |
} |
| 2936 |
} |
| 2937 |
|
| 2938 |
struct QList(T) |
| 2939 |
{ |
| 2940 |
alias QTypeInfo!T TI; |
| 2941 |
int x; |
| 2942 |
|
| 2943 |
void foo() |
| 2944 |
{ |
| 2945 |
x++; |
| 2946 |
} |
| 2947 |
} |
| 2948 |
|
| 2949 |
void exec(QList!(QAction) actions) {} |
| 2950 |
|
| 2951 |
interface IQGraphicsItem |
| 2952 |
{ |
| 2953 |
} |
| 2954 |
|
| 2955 |
abstract |
| 2956 |
class QGraphicsObject : IQGraphicsItem |
| 2957 |
{ |
| 2958 |
} |
| 2959 |
|
| 2960 |
class QGraphicsWidget : QGraphicsObject |
| 2961 |
{ |
| 2962 |
} |
| 2963 |
|
| 2964 |
class QAction |
| 2965 |
{ |
| 2966 |
void associatedGraphicsWidgets(QList!(QGraphicsWidget) a) |
| 2967 |
{ |
| 2968 |
QList!(QGraphicsWidget) x; |
| 2969 |
} |
| 2970 |
} |
| 2971 |
|
| 2972 |
void test182() |
| 2973 |
{ |
| 2974 |
} |
| 2975 |
|
| 2976 |
/***************************************************/ |
| 2977 |
|
| 2978 |
enum { a183 = b183() } |
| 2979 |
|
| 2980 |
int b183() { return 0; } |
| 2981 |
|
| 2982 |
/***************************************************/ |
| 2983 |
|
| 2984 |
struct Z184 { |
| 2985 |
int bar = 1; |
| 2986 |
union { Foo184 foo; } |
| 2987 |
} |
| 2988 |
|
| 2989 |
struct Foo184 { size_t offset = 0;} |
| 2990 |
|
| 2991 |
/***************************************************/ |
| 2992 |
|
| 2993 |
struct BB185 |
| 2994 |
{ |
| 2995 |
Item185[1] aa; |
| 2996 |
} |
| 2997 |
|
| 2998 |
struct CC185 |
| 2999 |
{ |
| 3000 |
Item185 aa; |
| 3001 |
} |
| 3002 |
|
| 3003 |
struct Item185 |
| 3004 |
{ |
| 3005 |
byte data; |
| 3006 |
} |
| 3007 |
|
| 3008 |
/***************************************************/ |
| 3009 |
|
| 3010 |
const PM_QS_INPUT = QS_INPUT; |
| 3011 |
const QS_INPUT = 2; |
| 3012 |
|
| 3013 |
/***************************************************/ |
| 3014 |
|
| 3015 |
alias A187 B187; |
| 3016 |
const int A187 = 1; |
| 3017 |
|
| 3018 |
/***************************************************/ |
| 3019 |
|
| 3020 |
int foo188(int[3] s) |
| 3021 |
{ |
| 3022 |
return s[0] + s[1] + s[2]; |
| 3023 |
} |
| 3024 |
|
| 3025 |
void test188() |
| 3026 |
{ |
| 3027 |
int[3] t = [1,3,4]; |
| 3028 |
auto i = foo188(t); |
| 3029 |
if (i != 8) |
| 3030 |
assert(0); |
| 3031 |
} |
| 3032 |
|
| 3033 |
/***************************************************/ |
| 3034 |
|
| 3035 |
template X189(alias fn) { |
| 3036 |
alias typeof(fn) X189; |
| 3037 |
} |
| 3038 |
|
| 3039 |
void a189()(T1189 x) { |
| 3040 |
alias X189!(T1189.foo) P; //line 7 |
| 3041 |
|
| 3042 |
x.foo(); |
| 3043 |
} |
| 3044 |
|
| 3045 |
class T1189 { |
| 3046 |
void foo() { |
| 3047 |
printf("T1.foo()\n"); |
| 3048 |
} |
| 3049 |
} |
| 3050 |
|
| 3051 |
class T2189 : T1189 { |
| 3052 |
void bla() { |
| 3053 |
printf("T2.blah()\n"); |
| 3054 |
assert(false); //line 19 |
| 3055 |
} |
| 3056 |
} |
| 3057 |
|
| 3058 |
void test189() { |
| 3059 |
a189!()(new T2189()); |
| 3060 |
} |
| 3061 |
|
| 3062 |
/***************************************************/ |
| 3063 |
|
| 3064 |
void test190() |
| 3065 |
{ |
| 3066 |
string s; |
| 3067 |
|
| 3068 |
if (true) scope(exit) s ~= "a"; |
| 3069 |
if (false) { } else scope(exit) s ~= "b"; |
| 3070 |
if (true) scope(exit) scope(exit) s ~= "c"; |
| 3071 |
foreach(x; 1..2) scope(exit) s ~= "d"; |
| 3072 |
if (true) L1: scope(exit) s ~= "e"; |
| 3073 |
do scope(exit) s ~= "f"; while (false); |
| 3074 |
int i; while (++i == 1) scope(exit) s ~= "g"; |
| 3075 |
try { } finally scope(exit) s ~= "h"; |
| 3076 |
assert(s == "abcdefgh"); |
| 3077 |
} |
| 3078 |
|
| 3079 |
/***************************************************/ |
| 3080 |
|
| 3081 |
struct S191 { |
| 3082 |
int last = 0; |
| 3083 |
S191 opCall(int i) { |
| 3084 |
printf("%d %d\n", last, i); |
| 3085 |
assert(i == 1 && last == 0 || i == 2 && last == 1 || i == 3 && last == 1); |
| 3086 |
last = i; |
| 3087 |
return this; |
| 3088 |
} |
| 3089 |
} |
| 3090 |
|
| 3091 |
void test191() |
| 3092 |
{ |
| 3093 |
S191 t; |
| 3094 |
t(1)(2); |
| 3095 |
t(3); |
| 3096 |
} |
| 3097 |
|
| 3098 |
/***************************************************/ |
| 3099 |
|
| 3100 |
enum foo192 { |
| 3101 |
item, |
| 3102 |
} |
| 3103 |
|
| 3104 |
//pragma(msg, foo.mangleof); |
| 3105 |
static assert(foo192.mangleof == "E6test426foo192"); |
| 3106 |
|
| 3107 |
/***************************************************/ |
| 3108 |
|
| 3109 |
void test193() |
| 3110 |
{ |
| 3111 |
enum Shapes |
| 3112 |
{ |
| 3113 |
Circle, Square |
| 3114 |
} |
| 3115 |
|
| 3116 |
int i; |
| 3117 |
Shapes s; |
| 3118 |
|
| 3119 |
pragma(msg, i.stringof); |
| 3120 |
pragma(msg, s.stringof); |
| 3121 |
|
| 3122 |
static assert(i.stringof == "i"); |
| 3123 |
static assert(s.stringof == "s"); |
| 3124 |
} |
| 3125 |
|
| 3126 |
/***************************************************/ |
| 3127 |
|
| 3128 |
void test194() |
| 3129 |
{ |
| 3130 |
uint[][] b = [[ 1, 2, ]]; |
| 3131 |
} |
| 3132 |
|
| 3133 |
/***************************************************/ |
| 3134 |
|
| 3135 |
alias int T195; |
| 3136 |
|
| 3137 |
class C195 |
| 3138 |
{ |
| 3139 |
int yum = x195; |
| 3140 |
} |
| 3141 |
|
| 3142 |
const T195 x195 = 0; |
| 3143 |
|
| 3144 |
/***************************************************/ |
| 3145 |
|
| 3146 |
union A196 { |
| 3147 |
double[2] a; |
| 3148 |
double[2] b; |
| 3149 |
} |
| 3150 |
|
| 3151 |
union B196 { |
| 3152 |
public: |
| 3153 |
double[2] a; |
| 3154 |
double[2] b; |
| 3155 |
} |
| 3156 |
|
| 3157 |
static assert(A196.sizeof == B196.sizeof); |
| 3158 |
|
| 3159 |
/***************************************************/ |
| 3160 |
|
| 3161 |
template Compileable(int z) { bool OK;} |
| 3162 |
|
| 3163 |
struct Bug3569 { |
| 3164 |
int bar() { return 7; } |
| 3165 |
} |
| 3166 |
|
| 3167 |
struct Bug3569b { |
| 3168 |
Bug3569 foo; |
| 3169 |
void crash() { |
| 3170 |
static assert(!is(typeof(Compileable!(foo.bar())))); |
| 3171 |
static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar())))); |
| 3172 |
} |
| 3173 |
} |
| 3174 |
|
| 3175 |
void test197() |
| 3176 |
{ |
| 3177 |
} |
| 3178 |
|
| 3179 |
/***************************************************/ |
| 3180 |
|
| 3181 |
void test198() // https://issues.dlang.org/show_bug.cgi?id=4506 |
| 3182 |
{ |
| 3183 |
int c = 1; |
| 3184 |
for (int k = 0; k < 2; k++) { |
| 3185 |
assert((k == 0 && c == 1) || (k == 1 && c == -1)); |
| 3186 |
c *= -1; |
| 3187 |
} |
| 3188 |
} |
| 3189 |
|
| 3190 |
/***************************************************/ |
| 3191 |
|
| 3192 |
// https://issues.dlang.org/show_bug.cgi?id=4514 |
| 3193 |
void g199(void delegate(void*, void*) d) { } |
| 3194 |
|
| 3195 |
struct X199 { |
| 3196 |
void f(void*, void*) {} |
| 3197 |
void n() |
| 3198 |
{ |
| 3199 |
g199(&f); |
| 3200 |
} |
| 3201 |
} |
| 3202 |
|
| 3203 |
/***************************************************/ |
| 3204 |
// https://issues.dlang.org/show_bug.cgi?id=4443 |
| 3205 |
|
| 3206 |
struct Struct4443 |
| 3207 |
{ |
| 3208 |
int x; |
| 3209 |
char[5] unused; |
| 3210 |
} |
| 3211 |
|
| 3212 |
void foo4443(Struct4443 *dest, Struct4443[] arr) |
| 3213 |
{ |
| 3214 |
int junk = arr[$-1].x; |
| 3215 |
if (dest || arr[$-1].x) { |
| 3216 |
*dest = arr[$-1]; |
| 3217 |
} |
| 3218 |
} |
| 3219 |
|
| 3220 |
void test200() |
| 3221 |
{ |
| 3222 |
Struct4443[1] a; |
| 3223 |
Struct4443 info; |
| 3224 |
foo4443(&info, a); |
| 3225 |
} |
| 3226 |
|
| 3227 |
/***************************************************/ |
| 3228 |
|
| 3229 |
// https://issues.dlang.org/show_bug.cgi?id=2931 |
| 3230 |
|
| 3231 |
struct Bug2931 { |
| 3232 |
int[4][3] val; |
| 3233 |
} |
| 3234 |
|
| 3235 |
struct Outer2931 { |
| 3236 |
Bug2931 p = Bug2931(67); // Applies to struct static initializers too |
| 3237 |
int zoom = 2; |
| 3238 |
int move = 3; |
| 3239 |
int scale = 4; |
| 3240 |
} |
| 3241 |
|
| 3242 |
int bug2931() |
| 3243 |
{ |
| 3244 |
Outer2931 v; |
| 3245 |
assert(v.move==3); |
| 3246 |
assert(v.scale == 4); |
| 3247 |
return v.zoom; |
| 3248 |
} |
| 3249 |
|
| 3250 |
int bug2931_2() |
| 3251 |
{ |
| 3252 |
Outer2931 v; |
| 3253 |
Bug2931 w = Bug2931(68); |
| 3254 |
assert(v.move==3); |
| 3255 |
for (int i = 0; i < 4; i++) |
| 3256 |
{ |
| 3257 |
for (int j = 0; j < 3; j++) |
| 3258 |
{ |
| 3259 |
assert(w.val[j][i] == 68); |
| 3260 |
assert(v.p.val[j][i] == 67); |
| 3261 |
} |
| 3262 |
} |
| 3263 |
assert(v.scale == 4); |
| 3264 |
return v.zoom; |
| 3265 |
} |
| 3266 |
|
| 3267 |
static assert(bug2931()==2); |
| 3268 |
|
| 3269 |
void test201() { |
| 3270 |
assert(bug2931()==2); |
| 3271 |
assert(bug2931_2()==2); |
| 3272 |
} |
| 3273 |
|
| 3274 |
|
| 3275 |
/***************************************************/ |
| 3276 |
// This was the original varargs example in std.vararg |
| 3277 |
|
| 3278 |
|
| 3279 |
void foo202(int x, ...) { |
| 3280 |
printf("%zd arguments\n", _arguments.length); |
| 3281 |
for (int i = 0; i < _arguments.length; i++) { |
| 3282 |
int j = va_arg!(int)(_argptr); |
| 3283 |
printf("\t%d\n", j); |
| 3284 |
assert(j == i + 2); |
| 3285 |
} |
| 3286 |
} |
| 3287 |
|
| 3288 |
void fooRef202(ref int x, ...) { |
| 3289 |
printf("%zd arguments\n", _arguments.length); |
| 3290 |
for (int i = 0; i < _arguments.length; i++) { |
| 3291 |
int j = va_arg!(int)(_argptr); |
| 3292 |
printf("\t%d\n", j); |
| 3293 |
assert(j == i + 2); |
| 3294 |
} |
| 3295 |
} |
| 3296 |
|
| 3297 |
void test202() |
| 3298 |
{ |
| 3299 |
foo202(1, 2, 3, 4, 5); |
| 3300 |
|
| 3301 |
printf("---\n"); |
| 3302 |
|
| 3303 |
int x = 1; |
| 3304 |
fooRef202(x, 2, 3, 4, 5); |
| 3305 |
} |
| 3306 |
|
| 3307 |
/***************************************************/ |
| 3308 |
// https://issues.dlang.org/show_bug.cgi?id=1418 |
| 3309 |
|
| 3310 |
class A203 |
| 3311 |
{ |
| 3312 |
char name = 'A'; |
| 3313 |
class B203 |
| 3314 |
{ |
| 3315 |
char name = 'B'; |
| 3316 |
} |
| 3317 |
} |
| 3318 |
|
| 3319 |
void test203() |
| 3320 |
{ |
| 3321 |
class C203 |
| 3322 |
{ |
| 3323 |
char name = 'C'; |
| 3324 |
} |
| 3325 |
|
| 3326 |
auto a = new A203; |
| 3327 |
auto b = a.new B203; |
| 3328 |
auto c = new C203; |
| 3329 |
|
| 3330 |
// writeln(a.tupleof); // prints: A |
| 3331 |
// writeln(b.tupleof); // prints: B main.A |
| 3332 |
// writeln(c.tupleof); // prints: C 0000 |
| 3333 |
assert(a.tupleof.length == 1 && a.tupleof[0] == 'A'); |
| 3334 |
assert(b.tupleof.length == 1 && b.tupleof[0] == 'B'); |
| 3335 |
assert(c.tupleof.length == 1 && c.tupleof[0] == 'C'); |
| 3336 |
} |
| 3337 |
|
| 3338 |
/***************************************************/ |
| 3339 |
// https://issues.dlang.org/show_bug.cgi?id=4516 |
| 3340 |
|
| 3341 |
struct A204 { B204 b; } |
| 3342 |
enum B204 { Z } |
| 3343 |
|
| 3344 |
/***************************************************/ |
| 3345 |
// https://issues.dlang.org/show_bug.cgi?id=4503 |
| 3346 |
|
| 3347 |
class Collection205(T) { } |
| 3348 |
ICollection c; |
| 3349 |
|
| 3350 |
alias Collection205!int ICollection; |
| 3351 |
|
| 3352 |
/***************************************************/ |
| 3353 |
|
| 3354 |
enum TaskStatus:int { Building=-1, } |
| 3355 |
|
| 3356 |
TaskStatus test206(char[] s){ |
| 3357 |
char[] t="TaskStatus".dup; |
| 3358 |
if (s.length>t.length && s[0..t.length]==t){ |
| 3359 |
long res=0; |
| 3360 |
if (s[t.length]=='-') res= -res; // <= OPnegass |
| 3361 |
return cast(TaskStatus)cast(int)res; |
| 3362 |
} |
| 3363 |
assert(0); |
| 3364 |
} |
| 3365 |
|
| 3366 |
/***************************************************/ |
| 3367 |
|
| 3368 |
struct UN { double dd; long ll; } |
| 3369 |
bool cmp( UN * pU ) { return pU.dd >= pU.ll ? true : false; } |
| 3370 |
|
| 3371 |
struct UN2 { real dd; long ll; } |
| 3372 |
bool cmp2( UN2 * pU ) { return pU.dd >= pU.ll ? true : false; } |
| 3373 |
|
| 3374 |
struct UN3 { double dd; int ll; } |
| 3375 |
bool cmp3( UN3 * pU ) { return pU.dd >= pU.ll ? true : false; } |
| 3376 |
|
| 3377 |
void test207() |
| 3378 |
{ |
| 3379 |
static UN u = { 10.50, 10 }; |
| 3380 |
auto i = cmp(&u); |
| 3381 |
printf( "%d\n", cmp( &u ) ); |
| 3382 |
assert(i); |
| 3383 |
|
| 3384 |
static UN2 u2 = { 10.50, 10 }; |
| 3385 |
i = cmp2(&u2); |
| 3386 |
assert(i); |
| 3387 |
|
| 3388 |
static UN3 u3 = { 10.50, 10 }; |
| 3389 |
i = cmp3(&u3); |
| 3390 |
assert(i); |
| 3391 |
|
| 3392 |
static UN3 u3_1 = { 9.50, 10 }; |
| 3393 |
i = cmp3(&u3_1); |
| 3394 |
assert(!i); |
| 3395 |
} |
| 3396 |
|
| 3397 |
/***************************************************/ |
| 3398 |
|
| 3399 |
template fail4302() { |
| 3400 |
static assert(0); |
| 3401 |
} |
| 3402 |
template bug4302() { |
| 3403 |
alias fail4302!() bad; |
| 3404 |
} |
| 3405 |
static if (is(bug4302!())) {} |
| 3406 |
|
| 3407 |
/***************************************************/ |
| 3408 |
|
| 3409 |
template tough4302() |
| 3410 |
{ |
| 3411 |
template bar() |
| 3412 |
{ |
| 3413 |
template far() |
| 3414 |
{ |
| 3415 |
static assert(0); |
| 3416 |
} |
| 3417 |
alias far!() par; |
| 3418 |
} |
| 3419 |
static if (is(bar!())) {} |
| 3420 |
} |
| 3421 |
|
| 3422 |
alias tough4302!() tougher; |
| 3423 |
|
| 3424 |
/***************************************************/ |
| 3425 |
|
| 3426 |
template Bug6602A(T) { |
| 3427 |
Bug6602B!(T).Result result; |
| 3428 |
} |
| 3429 |
|
| 3430 |
template Bug6602B(U) { |
| 3431 |
static assert(is(U == int)); |
| 3432 |
alias bool Result; |
| 3433 |
} |
| 3434 |
|
| 3435 |
enum bug6602Compiles = __traits(compiles, Bug6602A!short); |
| 3436 |
|
| 3437 |
/***************************************************/ |
| 3438 |
// https://issues.dlang.org/show_bug.cgi?id=3493 |
| 3439 |
|
| 3440 |
const bar209 = foo209; |
| 3441 |
const int * foo209 = null; |
| 3442 |
|
| 3443 |
/***************************************************/ |
| 3444 |
// https://issues.dlang.org/show_bug.cgi?id=3418 |
| 3445 |
|
| 3446 |
void test210() |
| 3447 |
{ |
| 3448 |
ulong a = 1; |
| 3449 |
a = cast(ulong)(a * 2.0L); |
| 3450 |
} |
| 3451 |
|
| 3452 |
/***************************************************/ |
| 3453 |
|
| 3454 |
static assert(!is(typeof(Object.tupleof[2000]=0))); |
| 3455 |
|
| 3456 |
/***************************************************/ |
| 3457 |
|
| 3458 |
struct Ghost {} |
| 3459 |
|
| 3460 |
void bug4430(T)(int x) {} |
| 3461 |
void bug4430(T)(Ghost x) {} |
| 3462 |
|
| 3463 |
void test212() |
| 3464 |
{ |
| 3465 |
bug4430!(char)( 777 ); |
| 3466 |
} |
| 3467 |
|
| 3468 |
/***************************************************/ |
| 3469 |
// https://issues.dlang.org/show_bug.cgi?id=4768 |
| 3470 |
|
| 3471 |
struct A213 { B213 b; } |
| 3472 |
enum B213 { Z213 = 2 } |
| 3473 |
|
| 3474 |
void test213() |
| 3475 |
{ |
| 3476 |
A213 x; |
| 3477 |
assert(x.b == 2); |
| 3478 |
} |
| 3479 |
|
| 3480 |
/***************************************************/ |
| 3481 |
|
| 3482 |
void g214(int j) { } |
| 3483 |
|
| 3484 |
void test214() |
| 3485 |
{ |
| 3486 |
struct S |
| 3487 |
{ |
| 3488 |
int i; |
| 3489 |
void f() { g214(i); } |
| 3490 |
} |
| 3491 |
auto s = S(); |
| 3492 |
} |
| 3493 |
|
| 3494 |
/***************************************************/ |
| 3495 |
|
| 3496 |
template Q(s...) { alias s q; } |
| 3497 |
|
| 3498 |
void test215() |
| 3499 |
{ |
| 3500 |
class C {} |
| 3501 |
enum assocarrayliteral = Q!( [1:2] ).q.stringof; |
| 3502 |
//enum dottype = Q!( C.Object.toString ).q.stringof; |
| 3503 |
enum halt = 0.stringof; // ICE w/ -release |
| 3504 |
//enum remove = Q!( [1:2].remove(1) ).q.stringof; |
| 3505 |
enum templat = Q!( Q ).q.stringof; |
| 3506 |
} |
| 3507 |
|
| 3508 |
/***************************************************/ |
| 3509 |
// https://issues.dlang.org/show_bug.cgi?id=4941 |
| 3510 |
|
| 3511 |
template T216(_...) { alias _ T216; } |
| 3512 |
size_t mid216(size_t n) { return n/2; } |
| 3513 |
|
| 3514 |
alias T216!(int, int)[0 .. mid216($)] A216; |
| 3515 |
alias T216!(1, 2, 3)[0 .. mid216($)] B216; |
| 3516 |
|
| 3517 |
void test216() |
| 3518 |
{ |
| 3519 |
T216!(int, int, int) values; |
| 3520 |
auto slice = values[0 .. mid216($)]; // C |
| 3521 |
} |
| 3522 |
|
| 3523 |
/***************************************************/ |
| 3524 |
|
| 3525 |
int bug4529a() { return 0; } |
| 3526 |
int function() bug4529b; |
| 3527 |
auto ivorBomb1 = typeid(typeof(bug4529a)); |
| 3528 |
auto ivorBomb2 = typeid(typeof(bug4529b)); |
| 3529 |
|
| 3530 |
/***************************************************/ |
| 3531 |
|
| 3532 |
void bug5218c(char [3] s) {} |
| 3533 |
void bug5218w(wchar [3] s) {} |
| 3534 |
void bug5218d(dchar [3] s) {} |
| 3535 |
|
| 3536 |
void test217() |
| 3537 |
{ |
| 3538 |
bug5218c("abc"); |
| 3539 |
bug5218w("abc"w); |
| 3540 |
bug5218d("abc"d); |
| 3541 |
} |
| 3542 |
|
| 3543 |
/***************************************************/ |
| 3544 |
// https://issues.dlang.org/show_bug.cgi?id=2954 |
| 3545 |
|
| 3546 |
void test218() |
| 3547 |
{ |
| 3548 |
char[char[3]] ac; |
| 3549 |
char[3] c = "abc"; |
| 3550 |
ac["abc"]='a'; |
| 3551 |
assert(ac[c]=='a'); |
| 3552 |
|
| 3553 |
char[dchar[3]] ad; |
| 3554 |
dchar[3] d = "abc"d; |
| 3555 |
ad["abc"d]='a'; |
| 3556 |
assert(ad[d]=='a'); |
| 3557 |
} |
| 3558 |
|
| 3559 |
/***************************************************/ |
| 3560 |
// https://issues.dlang.org/show_bug.cgi?id=2206 |
| 3561 |
|
| 3562 |
template T219(U) { |
| 3563 |
class C {} |
| 3564 |
} |
| 3565 |
|
| 3566 |
void test219() |
| 3567 |
{ |
| 3568 |
mixin T219!(int); // using a named mixin here fixes it |
| 3569 |
|
| 3570 |
pragma(msg, T219!(int).C.mangleof); |
| 3571 |
pragma(msg, C.mangleof); // incorrectly outputs the same as above |
| 3572 |
|
| 3573 |
assert(T219!(int).C.classinfo !is C.classinfo); // fails |
| 3574 |
assert(T219!(int).C.mangleof != C.mangleof); // fails |
| 3575 |
} |
| 3576 |
|
| 3577 |
|
| 3578 |
/***************************************************/ |
| 3579 |
// https://issues.dlang.org/show_bug.cgi?id=2206 |
| 3580 |
|
| 3581 |
class D220 {} |
| 3582 |
|
| 3583 |
template T220(U) { |
| 3584 |
class C { this() { } } |
| 3585 |
} |
| 3586 |
|
| 3587 |
void test220() |
| 3588 |
{ |
| 3589 |
mixin T220!(int); |
| 3590 |
|
| 3591 |
// all print 8 |
| 3592 |
// writeln(T220!(int).C.classinfo.initializer.length); |
| 3593 |
// writeln(C.classinfo.initializer.length); |
| 3594 |
// writeln(D220.classinfo.initializer.length); |
| 3595 |
|
| 3596 |
auto c = new C; // segfault in _d_newclass |
| 3597 |
} |
| 3598 |
|
| 3599 |
/***************************************************/ |
| 3600 |
|
| 3601 |
const struct S5110 |
| 3602 |
{ |
| 3603 |
static int value; |
| 3604 |
} |
| 3605 |
|
| 3606 |
static assert(is(typeof(S5110.value) == int)); |
| 3607 |
|
| 3608 |
/***************************************************/ |
| 3609 |
|
| 3610 |
class C5110 |
| 3611 |
{ |
| 3612 |
override: |
| 3613 |
string toString() { return ""; } |
| 3614 |
|
| 3615 |
class Nested |
| 3616 |
{ |
| 3617 |
void gun() {} |
| 3618 |
} |
| 3619 |
} |
| 3620 |
|
| 3621 |
/***************************************************/ |
| 3622 |
|
| 3623 |
immutable class Bug5504 |
| 3624 |
{ |
| 3625 |
void foo(T)(T a) {} |
| 3626 |
template xx(X) { |
| 3627 |
void hoo(T)(T a) {} |
| 3628 |
} |
| 3629 |
} |
| 3630 |
|
| 3631 |
shared class Bug5504b |
| 3632 |
{ |
| 3633 |
void foo(T)(T a) {} |
| 3634 |
template xx(X) { |
| 3635 |
void hoo(T)(T a) {} |
| 3636 |
} |
| 3637 |
} |
| 3638 |
|
| 3639 |
void test5504() |
| 3640 |
{ |
| 3641 |
immutable Bug5504 c; |
| 3642 |
c.foo(10); |
| 3643 |
c.xx!(int).hoo(10); |
| 3644 |
shared Bug5504b d; |
| 3645 |
d.foo(10); |
| 3646 |
d.xx!(int).hoo(10); |
| 3647 |
} |
| 3648 |
|
| 3649 |
/***************************************************/ |
| 3650 |
|
| 3651 |
void bug5105() // compilation test -- don't need to run |
| 3652 |
{ |
| 3653 |
auto c = new shared(C5105); |
| 3654 |
c.foo(10); |
| 3655 |
} |
| 3656 |
|
| 3657 |
synchronized shared class C5105 |
| 3658 |
{ |
| 3659 |
void foo(T)(T a) {} |
| 3660 |
} |
| 3661 |
|
| 3662 |
/***************************************************/ |
| 3663 |
// https://issues.dlang.org/show_bug.cgi?id=5145 |
| 3664 |
|
| 3665 |
interface I221{ |
| 3666 |
void bla(); |
| 3667 |
} |
| 3668 |
|
| 3669 |
interface J221 |
| 3670 |
{ |
| 3671 |
I221 sync (); |
| 3672 |
} |
| 3673 |
|
| 3674 |
class A221 : B221 |
| 3675 |
{ |
| 3676 |
final override I221 sync() |
| 3677 |
in { assert( valid ); } |
| 3678 |
do |
| 3679 |
{ |
| 3680 |
return null; |
| 3681 |
} |
| 3682 |
} |
| 3683 |
|
| 3684 |
class B221 : J221 |
| 3685 |
{ |
| 3686 |
override I221 sync() |
| 3687 |
in { assert( valid ); } |
| 3688 |
do |
| 3689 |
{ |
| 3690 |
return null; |
| 3691 |
} |
| 3692 |
|
| 3693 |
final bool valid() |
| 3694 |
{ |
| 3695 |
return true; |
| 3696 |
} |
| 3697 |
} |
| 3698 |
|
| 3699 |
/***************************************************/ |
| 3700 |
|
| 3701 |
template Bug3276(bool B) { |
| 3702 |
static if (B) |
| 3703 |
alias Bug3276!(false) Bug3276; |
| 3704 |
else |
| 3705 |
alias double Bug3276; |
| 3706 |
} |
| 3707 |
|
| 3708 |
template Bug3276_b(alias W) { |
| 3709 |
alias W!(true) Bug3276_b; |
| 3710 |
} |
| 3711 |
|
| 3712 |
alias Bug3276_b!(Bug3276) Bug3276_c; |
| 3713 |
|
| 3714 |
/***************************************************/ |
| 3715 |
// https://issues.dlang.org/show_bug.cgi?id=5294 |
| 3716 |
|
| 3717 |
void foo222(int) {} |
| 3718 |
|
| 3719 |
void test222() |
| 3720 |
{ |
| 3721 |
int count; |
| 3722 |
for (int i = 0; i < 2; i++) { |
| 3723 |
count++; |
| 3724 |
foo222(i * 5 - 6); // comment this out and it makes 2 loops |
| 3725 |
} |
| 3726 |
printf("%d\n", count); // compile with -O and it prints 1 |
| 3727 |
assert(count == 2); |
| 3728 |
} |
| 3729 |
|
| 3730 |
/***************************************************/ |
| 3731 |
|
| 3732 |
void foo223(long x,long a,long b,long c,long d,long e,long f) |
| 3733 |
{ |
| 3734 |
assert(x == 0x123456789ABCDEF0); |
| 3735 |
} |
| 3736 |
|
| 3737 |
void test223() |
| 3738 |
{ |
| 3739 |
foo223(0x123456789ABCDEF0,2,3,4,5,6,7); |
| 3740 |
} |
| 3741 |
|
| 3742 |
/***************************************************/ |
| 3743 |
// https://issues.dlang.org/show_bug.cgi?id=4379 |
| 3744 |
|
| 3745 |
template BigTuple(U...) { |
| 3746 |
alias U BigTuple; |
| 3747 |
} |
| 3748 |
|
| 3749 |
alias |
| 3750 |
BigTuple!(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 3751 |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 3752 |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 3753 |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 3754 |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 3755 |
1,1,1,1,1,1) Tuple4379; |
| 3756 |
|
| 3757 |
void test224() |
| 3758 |
{ |
| 3759 |
foreach(x; Tuple4379) { } |
| 3760 |
} |
| 3761 |
|
| 3762 |
/***************************************************/ |
| 3763 |
// https://issues.dlang.org/show_bug.cgi?id=3681 |
| 3764 |
|
| 3765 |
public final class A3681 { |
| 3766 |
private this() { |
| 3767 |
int i =0; |
| 3768 |
int j = i + 1; |
| 3769 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3770 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3771 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3772 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3773 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3774 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3775 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3776 |
i = j * 15; j = i * 59; i = j * 15; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3777 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3778 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3779 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3780 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3781 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3782 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3783 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3784 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3785 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3786 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3787 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3788 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3789 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3790 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3791 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3792 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3793 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3794 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3795 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3796 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3797 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3798 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3799 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3800 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3801 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; |
| 3802 |
j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; j = i * 59; i = j * 15; j = i * 59; |
| 3803 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3804 |
i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; |
| 3805 |
} |
| 3806 |
} |
| 3807 |
|
| 3808 |
/***************************************************/ |
| 3809 |
|
| 3810 |
int bug4389() |
| 3811 |
{ |
| 3812 |
string s; |
| 3813 |
dchar c = '\u2348'; |
| 3814 |
s ~= c; |
| 3815 |
assert(s.length==3); |
| 3816 |
dchar d = 'D'; |
| 3817 |
s ~= d; |
| 3818 |
assert(s.length==4); |
| 3819 |
s = ""; |
| 3820 |
s ~= c; |
| 3821 |
assert(s.length==3); |
| 3822 |
s ~= d; |
| 3823 |
assert(s.length==4); |
| 3824 |
string z; |
| 3825 |
wchar w = '\u0300'; |
| 3826 |
z ~= w; |
| 3827 |
assert(z.length==2); |
| 3828 |
z = ""; |
| 3829 |
z ~= w; |
| 3830 |
assert(z.length==2); |
| 3831 |
return 1; |
| 3832 |
} |
| 3833 |
|
| 3834 |
static assert(bug4389()); |
| 3835 |
|
| 3836 |
// ICE(constfold.c) |
| 3837 |
int ice4389() |
| 3838 |
{ |
| 3839 |
string s; |
| 3840 |
dchar c = '\u2348'; |
| 3841 |
s ~= c; |
| 3842 |
s = s ~ "xxx"; |
| 3843 |
return 1; |
| 3844 |
} |
| 3845 |
|
| 3846 |
static assert(ice4389()); |
| 3847 |
|
| 3848 |
// ICE(expression.c) |
| 3849 |
string ice4390() |
| 3850 |
{ |
| 3851 |
string s; |
| 3852 |
dchar c = '`'; |
| 3853 |
s ~= c; |
| 3854 |
s ~= c; |
| 3855 |
return s; |
| 3856 |
} |
| 3857 |
|
| 3858 |
static assert(mixin(ice4390()) == ``); |
| 3859 |
static assert(mixin(ice4390()) == ``); |
| 3860 |
|
| 3861 |
/***************************************************/ |
| 3862 |
// https://issues.dlang.org/show_bug.cgi?id=190 |
| 3863 |
|
| 3864 |
alias int avocado; |
| 3865 |
void eat(avocado x225 = .x225); |
| 3866 |
avocado x225; |
| 3867 |
|
| 3868 |
void test225() |
| 3869 |
{ |
| 3870 |
} |
| 3871 |
|
| 3872 |
/***************************************************/ |
| 3873 |
// https://issues.dlang.org/show_bug.cgi?id=5534 |
| 3874 |
|
| 3875 |
void doStuff(byte start, byte end, uint increment = 1U) { |
| 3876 |
auto output = new byte[3]; |
| 3877 |
|
| 3878 |
size_t count = 0; |
| 3879 |
for(byte i = start; i < end; i += increment) { |
| 3880 |
output[count++] = i; |
| 3881 |
} |
| 3882 |
} |
| 3883 |
|
| 3884 |
void test226() { |
| 3885 |
doStuff(0, 3); |
| 3886 |
} |
| 3887 |
|
| 3888 |
/***************************************************/ |
| 3889 |
// https://issues.dlang.org/show_bug.cgi?id=5536 |
| 3890 |
|
| 3891 |
void test227() |
| 3892 |
{ |
| 3893 |
int[] as = [111, 666]; |
| 3894 |
as ~= as[$ - 2]; |
| 3895 |
assert(as.length == 3); |
| 3896 |
assert(as[2] == 111); |
| 3897 |
} |
| 3898 |
|
| 3899 |
/***************************************************/ |
| 3900 |
// https://issues.dlang.org/show_bug.cgi?id=4017 |
| 3901 |
|
| 3902 |
struct _A |
| 3903 |
{ |
| 3904 |
uint data; |
| 3905 |
} |
| 3906 |
|
| 3907 |
const A_SIZE = (A4017.sizeof); |
| 3908 |
|
| 3909 |
alias _A A4017; |
| 3910 |
|
| 3911 |
/***************************************************/ |
| 3912 |
// https://issues.dlang.org/show_bug.cgi?id=5455 |
| 3913 |
|
| 3914 |
void thrw(Data *s) { |
| 3915 |
throw new Exception("xxx"); |
| 3916 |
} |
| 3917 |
|
| 3918 |
struct Data { |
| 3919 |
Rapper *w; |
| 3920 |
uint n, m; |
| 3921 |
} |
| 3922 |
|
| 3923 |
struct Rapper { |
| 3924 |
ubyte * dat; |
| 3925 |
ubyte[] con() { |
| 3926 |
return dat[0..1]; |
| 3927 |
} |
| 3928 |
} |
| 3929 |
|
| 3930 |
uint jaz(ubyte[] data) { |
| 3931 |
return cast(uint)data.length; |
| 3932 |
} |
| 3933 |
|
| 3934 |
struct Resp { |
| 3935 |
void set(Data *data, string[] soup) { |
| 3936 |
switch(soup[0]) { |
| 3937 |
default: |
| 3938 |
} |
| 3939 |
uint[] f = [jaz(data.w ? data.w.con[data.n ..data.m] : null), data.m - data.n]; |
| 3940 |
thrw(data); |
| 3941 |
} |
| 3942 |
} |
| 3943 |
|
| 3944 |
/**************************************/ |
| 3945 |
// https://issues.dlang.org/show_bug.cgi?id=5571 |
| 3946 |
|
| 3947 |
void test228() { |
| 3948 |
auto b = new bool; |
| 3949 |
printf("%p\n", b); |
| 3950 |
*b = false; |
| 3951 |
} |
| 3952 |
|
| 3953 |
/***************************************************/ |
| 3954 |
// https://issues.dlang.org/show_bug.cgi?id=5572 |
| 3955 |
|
| 3956 |
void doSynchronized() { |
| 3957 |
printf("In doSynchronized() 1: %p\n", cast(void*) global229); |
| 3958 |
synchronized { |
| 3959 |
printf("In doSynchronized() 2: %p\n", cast(void*) global229); |
| 3960 |
} |
| 3961 |
} |
| 3962 |
|
| 3963 |
__gshared Object global229; |
| 3964 |
|
| 3965 |
void test229() { |
| 3966 |
auto local = new Object; |
| 3967 |
global229 = local; |
| 3968 |
|
| 3969 |
printf("In main() 1: %p\t%p\n", |
| 3970 |
cast(void*) global229, cast(void*) local); |
| 3971 |
doSynchronized(); |
| 3972 |
printf("In main() 1: %p\t%p\n", |
| 3973 |
cast(void*) global229, cast(void*) local); |
| 3974 |
|
| 3975 |
assert(cast(void*) global229 == cast(void*) local); |
| 3976 |
} |
| 3977 |
|
| 3978 |
/***************************************************/ |
| 3979 |
|
| 3980 |
static immutable real[14] negtab = |
| 3981 |
[ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L, |
| 3982 |
1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ]; |
| 3983 |
static immutable real[13] postab = |
| 3984 |
[ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L, |
| 3985 |
1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ]; |
| 3986 |
|
| 3987 |
float parse(ref string p) |
| 3988 |
{ |
| 3989 |
printf("test1\n"); |
| 3990 |
|
| 3991 |
real ldval = 0.0; |
| 3992 |
int exp = 0; |
| 3993 |
long msdec = 0; |
| 3994 |
|
| 3995 |
msdec = 123; |
| 3996 |
exp = 2; |
| 3997 |
|
| 3998 |
ldval = msdec; |
| 3999 |
printf("ldval = %Lg\n", ldval); |
| 4000 |
if (ldval) |
| 4001 |
{ |
| 4002 |
uint u = 0; |
| 4003 |
int pow = 4096; |
| 4004 |
|
| 4005 |
while (exp > 0) |
| 4006 |
{ |
| 4007 |
while (exp >= pow) |
| 4008 |
{ |
| 4009 |
ldval *= postab[u]; |
| 4010 |
exp -= pow; |
| 4011 |
} |
| 4012 |
pow >>= 1; |
| 4013 |
u++; |
| 4014 |
} |
| 4015 |
while (exp < 0) |
| 4016 |
{ |
| 4017 |
while (exp <= -pow) |
| 4018 |
{ |
| 4019 |
ldval *= negtab[u]; |
| 4020 |
exp += pow; |
| 4021 |
} |
| 4022 |
pow >>= 1; |
| 4023 |
u++; |
| 4024 |
} |
| 4025 |
} |
| 4026 |
return ldval; |
| 4027 |
} |
| 4028 |
|
| 4029 |
void test230() |
| 4030 |
{ |
| 4031 |
float f; |
| 4032 |
string s = "123e+2"; |
| 4033 |
f = parse( s ); |
| 4034 |
//printf("f = %g\n", f); |
| 4035 |
assert( f == 123e+2f ); |
| 4036 |
} |
| 4037 |
|
| 4038 |
/***************************************************/ |
| 4039 |
|
| 4040 |
class Bug4033 {} |
| 4041 |
|
| 4042 |
class Template4033(T) { |
| 4043 |
static assert(is(T : Bug4033)); |
| 4044 |
} |
| 4045 |
|
| 4046 |
alias Template4033!(Z4033) Bla; |
| 4047 |
|
| 4048 |
class Z4033 : Bug4033 { } |
| 4049 |
|
| 4050 |
/***************************************************/ |
| 4051 |
|
| 4052 |
struct Bug4322 { |
| 4053 |
int[1] a = void; |
| 4054 |
} |
| 4055 |
|
| 4056 |
void bug4322() { |
| 4057 |
Bug4322 f = Bug4322(); |
| 4058 |
Bug4322 g = Bug4322.init; |
| 4059 |
} |
| 4060 |
|
| 4061 |
/***************************************************/ |
| 4062 |
|
| 4063 |
bool bug5672(long v) |
| 4064 |
{ |
| 4065 |
return (v & 1) == 1; |
| 4066 |
return (v & 1) == 1; |
| 4067 |
} |
| 4068 |
|
| 4069 |
/***************************************************/ |
| 4070 |
|
| 4071 |
void bug5717() |
| 4072 |
{ |
| 4073 |
string s, s2; |
| 4074 |
s = "Привет"; |
| 4075 |
for (int i=0; i<s.length; i++) |
| 4076 |
s2 ~= s[i]; |
| 4077 |
assert(s == s2); |
| 4078 |
} |
| 4079 |
|
| 4080 |
/***************************************************/ |
| 4081 |
// https://issues.dlang.org/show_bug.cgi?id=3086 |
| 4082 |
|
| 4083 |
class X231 { |
| 4084 |
void a() {} |
| 4085 |
void b(int z, short c) {} |
| 4086 |
void c(int z, short d) {} |
| 4087 |
} |
| 4088 |
|
| 4089 |
void test231() { |
| 4090 |
auto z = new X231(); |
| 4091 |
TypeInfo a = typeid(typeof(&z.a)); |
| 4092 |
TypeInfo b = typeid(typeof(&z.b)); |
| 4093 |
TypeInfo c = typeid(typeof(&z.c)); |
| 4094 |
|
| 4095 |
assert(a !is b, "1"); |
| 4096 |
assert(a != b, "2"); |
| 4097 |
assert(b == c, "3"); |
| 4098 |
} |
| 4099 |
|
| 4100 |
/***************************************************/ |
| 4101 |
// https://issues.dlang.org/show_bug.cgi?id=4140 |
| 4102 |
|
| 4103 |
const A232 = [1,2,3]; |
| 4104 |
const B232 = A232[1..A232.length]; |
| 4105 |
const C232 = A232[1..$]; |
| 4106 |
|
| 4107 |
void test232() |
| 4108 |
{ |
| 4109 |
assert(A232[0] == 1); |
| 4110 |
assert(A232[1] == 2); |
| 4111 |
assert(A232[2] == 3); |
| 4112 |
assert(B232[0] == 2); |
| 4113 |
assert(B232[1] == 3); |
| 4114 |
assert(C232[0] == 2); |
| 4115 |
assert(C232[1] == 3); |
| 4116 |
} |
| 4117 |
|
| 4118 |
/***************************************************/ |
| 4119 |
// https://issues.dlang.org/show_bug.cgi?id=1389 |
| 4120 |
|
| 4121 |
void test233() |
| 4122 |
{ |
| 4123 |
int a; |
| 4124 |
mixin("a") = 666; |
| 4125 |
} |
| 4126 |
|
| 4127 |
/***************************************************/ |
| 4128 |
// https://issues.dlang.org/show_bug.cgi?id=5735 |
| 4129 |
|
| 4130 |
struct A234 {} |
| 4131 |
|
| 4132 |
void foo234(bool cond){} |
| 4133 |
|
| 4134 |
void test234() |
| 4135 |
{ |
| 4136 |
A234 a; |
| 4137 |
int i; |
| 4138 |
|
| 4139 |
static assert(!__traits(compiles, assert(a))); // type A does not have a boolean value |
| 4140 |
static assert(!__traits(compiles, assert(i || a))); // type A does not have a boolean value |
| 4141 |
static assert(!__traits(compiles, assert(0 || a))); // OK |
| 4142 |
|
| 4143 |
// if(a) {} // type A does not have a boolean value |
| 4144 |
// if(i || a) {} // type A does not have a boolean value |
| 4145 |
// if(0 || a) {} // type A does not have a boolean value |
| 4146 |
|
| 4147 |
static assert(!__traits(compiles, foo234(a))); // cannot implicitly convert type A to bool |
| 4148 |
static assert(!__traits(compiles, foo234(i || a))); // OK |
| 4149 |
static assert(!__traits(compiles, foo234(0 || a))); // OK |
| 4150 |
} |
| 4151 |
|
| 4152 |
|
| 4153 |
/***************************************************/ |
| 4154 |
|
| 4155 |
int space() { return 4001; } |
| 4156 |
|
| 4157 |
void oddity4001() |
| 4158 |
{ |
| 4159 |
const int bowie = space(); |
| 4160 |
static assert(space() == 4001); // OK |
| 4161 |
static assert(bowie == 4001); // doesn't compile |
| 4162 |
} |
| 4163 |
|
| 4164 |
/***************************************************/ |
| 4165 |
// https://issues.dlang.org/show_bug.cgi?id=3809 |
| 4166 |
|
| 4167 |
int bug3809() |
| 4168 |
{ |
| 4169 |
static int a = 0; |
| 4170 |
return a; |
| 4171 |
} |
| 4172 |
|
| 4173 |
struct BUG3809 |
| 4174 |
{ |
| 4175 |
int xx; |
| 4176 |
} |
| 4177 |
|
| 4178 |
void bug3809b() |
| 4179 |
{ |
| 4180 |
BUG3809 b = { bug3809() }; |
| 4181 |
} |
| 4182 |
|
| 4183 |
/***************************************************/ |
| 4184 |
// |
| 4185 |
|
| 4186 |
void bug6184() |
| 4187 |
{ |
| 4188 |
bool cmp(ref int[3] a, ref int[3] b) |
| 4189 |
{ |
| 4190 |
return a[] is b[]; |
| 4191 |
} |
| 4192 |
|
| 4193 |
static struct Ary |
| 4194 |
{ |
| 4195 |
int[3] ary; |
| 4196 |
} |
| 4197 |
|
| 4198 |
auto a = new Ary; |
| 4199 |
auto b = new Ary; |
| 4200 |
assert(!cmp(a.ary, b.ary)); |
| 4201 |
b = a; |
| 4202 |
assert(cmp(a.ary, b.ary)); |
| 4203 |
|
| 4204 |
// change high bit of ary address |
| 4205 |
*(cast(size_t*)&b) ^= (1UL << (size_t.sizeof * 4)); |
| 4206 |
assert(!cmp(a.ary, b.ary)); |
| 4207 |
} |
| 4208 |
|
| 4209 |
/***************************************************/ |
| 4210 |
// https://issues.dlang.org/show_bug.cgi?id=6229 |
| 4211 |
|
| 4212 |
int test6229() |
| 4213 |
{ |
| 4214 |
{ |
| 4215 |
ubyte a = 2; |
| 4216 |
ubyte b = 4; |
| 4217 |
b += a; |
| 4218 |
} |
| 4219 |
|
| 4220 |
char a = 2; |
| 4221 |
char b = 4; |
| 4222 |
b += a; |
| 4223 |
|
| 4224 |
wchar c = 2; |
| 4225 |
wchar d = 4; |
| 4226 |
c /= d; |
| 4227 |
|
| 4228 |
return b; |
| 4229 |
} |
| 4230 |
|
| 4231 |
/***************************************************/ |
| 4232 |
// XMMBug |
| 4233 |
|
| 4234 |
class XMMPainter |
| 4235 |
{ |
| 4236 |
float call() |
| 4237 |
{ |
| 4238 |
return sumFloats(0.0f, 0.0f); |
| 4239 |
} |
| 4240 |
|
| 4241 |
static float sumFloats(float a, float b) |
| 4242 |
{ |
| 4243 |
return a + b; |
| 4244 |
} |
| 4245 |
} |
| 4246 |
|
| 4247 |
void test6270() |
| 4248 |
{ |
| 4249 |
auto painter = new XMMPainter; |
| 4250 |
assert(XMMPainter.sumFloats(20, painter.call()) == 20.0f); |
| 4251 |
auto dg = () { return XMMPainter.sumFloats(0.0f, 0.0f); }; |
| 4252 |
assert(XMMPainter.sumFloats(20, dg()) == 20.0f); |
| 4253 |
} |
| 4254 |
|
| 4255 |
/***************************************************/ |
| 4256 |
|
| 4257 |
void testrolror(int shift) |
| 4258 |
{ |
| 4259 |
uint a = 7; |
| 4260 |
uint r; |
| 4261 |
r = (a >> shift) | (a << (int.sizeof * 8 - shift)); |
| 4262 |
assert(r == 0x8000_0003); |
| 4263 |
r = (r << shift) | (r >> (int.sizeof * 8 - shift)); |
| 4264 |
assert(r == 7); |
| 4265 |
} |
| 4266 |
|
| 4267 |
void test236() |
| 4268 |
{ |
| 4269 |
testrolror(1); |
| 4270 |
} |
| 4271 |
|
| 4272 |
|
| 4273 |
/***************************************************/ |
| 4274 |
// https://issues.dlang.org/show_bug.cgi?id=4460 |
| 4275 |
|
| 4276 |
void test237() |
| 4277 |
{ |
| 4278 |
foreach (s, i; [ "a":1, "b":2 ]) |
| 4279 |
{ |
| 4280 |
//writeln(s, i); |
| 4281 |
} |
| 4282 |
} |
| 4283 |
|
| 4284 |
|
| 4285 |
/***************************************************/ |
| 4286 |
|
| 4287 |
void foo238(long a, long b) |
| 4288 |
{ |
| 4289 |
while (1) // prevent inlining |
| 4290 |
{ |
| 4291 |
long x = a / b; |
| 4292 |
long y = a % b; |
| 4293 |
assert(x == 3); |
| 4294 |
assert(y == 1); |
| 4295 |
break; |
| 4296 |
} |
| 4297 |
} |
| 4298 |
|
| 4299 |
void test238() |
| 4300 |
{ |
| 4301 |
long a, b; |
| 4302 |
a = 10; |
| 4303 |
b = 3; |
| 4304 |
long x = a / b; |
| 4305 |
long y = a % b; // evaluate at compile time |
| 4306 |
assert(x == 3); |
| 4307 |
assert(y == 1); |
| 4308 |
|
| 4309 |
foo238(a, b); |
| 4310 |
} |
| 4311 |
|
| 4312 |
/***************************************************/ |
| 4313 |
// https://issues.dlang.org/show_bug.cgi?id=5239 |
| 4314 |
|
| 4315 |
struct S239 { int x; } |
| 4316 |
|
| 4317 |
int test239() |
| 4318 |
{ |
| 4319 |
S239[4] w = void; |
| 4320 |
w[$-2].x = 217; |
| 4321 |
return w[2].x; |
| 4322 |
} |
| 4323 |
|
| 4324 |
|
| 4325 |
/***************************************************/ |
| 4326 |
|
| 4327 |
void enforce6506b(bool condition, void delegate() m) { |
| 4328 |
assert(!condition); |
| 4329 |
} |
| 4330 |
void toImpl6506b(int value) { |
| 4331 |
void f(){} |
| 4332 |
enforce6506b(value >= 0, &f); |
| 4333 |
} |
| 4334 |
void test6506() { |
| 4335 |
toImpl6506b(-112345); |
| 4336 |
} |
| 4337 |
|
| 4338 |
/***************************************************/ |
| 4339 |
// https://issues.dlang.org/show_bug.cgi?id=6505 |
| 4340 |
|
| 4341 |
double foo240() { |
| 4342 |
return 1.0; |
| 4343 |
} |
| 4344 |
|
| 4345 |
void test240() { |
| 4346 |
double a = void; |
| 4347 |
double b = void; |
| 4348 |
double x = void; |
| 4349 |
a = foo240(); |
| 4350 |
b = foo240(); |
| 4351 |
x = a*a + a*a + a*a + a*a + a*a + a*a + a*a + |
| 4352 |
a*b + a*b; |
| 4353 |
assert(x > 0); |
| 4354 |
} |
| 4355 |
|
| 4356 |
/***************************************************/ |
| 4357 |
// https://issues.dlang.org/show_bug.cgi?id=6563 |
| 4358 |
|
| 4359 |
int foo6563(float a, float b, float c, float d, float e, float f, float g, float h) |
| 4360 |
{ |
| 4361 |
assert(a == 1); |
| 4362 |
return 0; // return something to prevent folding |
| 4363 |
} |
| 4364 |
|
| 4365 |
void test6563() |
| 4366 |
{ |
| 4367 |
auto res = foo6563(1, 1, 1, 1, 1, 1, 1, 1); |
| 4368 |
} |
| 4369 |
|
| 4370 |
/***************************************************/ |
| 4371 |
|
| 4372 |
ubyte foo241(ubyte[] data) |
| 4373 |
{ |
| 4374 |
ubyte a, b, c, d; |
| 4375 |
|
| 4376 |
a = data[0]; |
| 4377 |
b = data[1]; |
| 4378 |
c = data[2]; |
| 4379 |
d = data[3]; |
| 4380 |
|
| 4381 |
c <<= 1; |
| 4382 |
if (c & 0x80) |
| 4383 |
c >>= 1; |
| 4384 |
d <<= 1; |
| 4385 |
if (d & 0x80) |
| 4386 |
d >>= 1; |
| 4387 |
|
| 4388 |
return d; |
| 4389 |
} |
| 4390 |
|
| 4391 |
void test241() |
| 4392 |
{ |
| 4393 |
ubyte[4] data; |
| 4394 |
data[3] = 0x40; |
| 4395 |
assert(foo241(data[]) == 0x40); |
| 4396 |
data[3] = 0x20; |
| 4397 |
assert(foo241(data[]) == 0x40); |
| 4398 |
} |
| 4399 |
|
| 4400 |
/***************************************************/ |
| 4401 |
|
| 4402 |
struct Foo6665 |
| 4403 |
{ |
| 4404 |
double[2][2] dat; |
| 4405 |
|
| 4406 |
double foo(size_t i, size_t j) |
| 4407 |
{ |
| 4408 |
return dat[i][j] = 0; |
| 4409 |
} |
| 4410 |
} |
| 4411 |
|
| 4412 |
void test6665() |
| 4413 |
{ |
| 4414 |
Foo6665 a; |
| 4415 |
} |
| 4416 |
|
| 4417 |
/***************************************************/ |
| 4418 |
|
| 4419 |
double entropy(double[] probs) { |
| 4420 |
double result = 0; |
| 4421 |
foreach (p; probs) { |
| 4422 |
if (!p) continue; |
| 4423 |
result -= p; |
| 4424 |
} |
| 4425 |
return result; |
| 4426 |
} |
| 4427 |
|
| 4428 |
/***************************************************/ |
| 4429 |
|
| 4430 |
long b5364(long bmax){ |
| 4431 |
if(true){ |
| 4432 |
} |
| 4433 |
if(bmax >= 0) bmax = -1; |
| 4434 |
return bmax; |
| 4435 |
} |
| 4436 |
|
| 4437 |
void test5364() |
| 4438 |
{ |
| 4439 |
assert(b5364(0) == -1L); |
| 4440 |
} |
| 4441 |
|
| 4442 |
|
| 4443 |
/***************************************************/ |
| 4444 |
|
| 4445 |
struct FPoint { |
| 4446 |
float x, y; |
| 4447 |
} |
| 4448 |
|
| 4449 |
void constructBezier(FPoint p0, FPoint p1, FPoint p2, ref FPoint[3] quad) { |
| 4450 |
quad[0] = p0; |
| 4451 |
quad[1] = FPoint(p1.x, p1.y); |
| 4452 |
quad[$-1] = p2; |
| 4453 |
} |
| 4454 |
|
| 4455 |
void test6189() { |
| 4456 |
auto p0 = FPoint(0, 0); |
| 4457 |
auto p1 = FPoint(1, 1); |
| 4458 |
auto p2 = FPoint(2, 2); |
| 4459 |
|
| 4460 |
// avoid inline of call |
| 4461 |
FPoint[3] quad; |
| 4462 |
auto f = &constructBezier; |
| 4463 |
f(p0, p1, p2, quad); |
| 4464 |
|
| 4465 |
assert(quad == [p0, p1, p2]); |
| 4466 |
} |
| 4467 |
|
| 4468 |
/***************************************************/ |
| 4469 |
// https://issues.dlang.org/show_bug.cgi?id=6997 |
| 4470 |
|
| 4471 |
long fun6997(long a,long b,long c) |
| 4472 |
{ |
| 4473 |
return a < b ? a < c ? a : b < c ? b : c : b; |
| 4474 |
} |
| 4475 |
|
| 4476 |
long baz6997(long a, long b) |
| 4477 |
{ |
| 4478 |
bool s = (a<0) != (b<0); |
| 4479 |
a = a > 0 ? a : -a; |
| 4480 |
return s ? a : a; |
| 4481 |
} |
| 4482 |
|
| 4483 |
struct S6997 |
| 4484 |
{ |
| 4485 |
ulong bar, qux; |
| 4486 |
bool c; |
| 4487 |
|
| 4488 |
S6997 foo() |
| 4489 |
{ |
| 4490 |
if(!c) |
| 4491 |
{ |
| 4492 |
long a = baz6997(bar, 0), |
| 4493 |
b = baz6997(bar, 0), |
| 4494 |
c = baz6997(bar, 0); |
| 4495 |
return S6997(fun6997(a,b,c), fun6997(a,b,c)); |
| 4496 |
} |
| 4497 |
return S6997(); |
| 4498 |
} |
| 4499 |
} |
| 4500 |
|
| 4501 |
void test6997() |
| 4502 |
{ |
| 4503 |
auto x = S6997().foo(); |
| 4504 |
} |
| 4505 |
|
| 4506 |
|
| 4507 |
/***************************************************/ |
| 4508 |
|
| 4509 |
ubyte foo7026(uint n) { |
| 4510 |
ubyte[5] buf = void; |
| 4511 |
ubyte wsize; |
| 4512 |
|
| 4513 |
while (true) { |
| 4514 |
if ((n & ~0x7F) == 0) { |
| 4515 |
buf[wsize++] = cast(ubyte)n; |
| 4516 |
break; |
| 4517 |
} else { |
| 4518 |
buf[wsize++] = cast(ubyte)((n & 0x7F) | 0x80); |
| 4519 |
n >>= 7; |
| 4520 |
} |
| 4521 |
} |
| 4522 |
|
| 4523 |
printf("%hhu\n", wsize); |
| 4524 |
return buf[0]; |
| 4525 |
} |
| 4526 |
|
| 4527 |
void test7026() { |
| 4528 |
if (foo7026(3) != 3) |
| 4529 |
assert(0); |
| 4530 |
} |
| 4531 |
|
| 4532 |
|
| 4533 |
/***************************************************/ |
| 4534 |
|
| 4535 |
void test6354() |
| 4536 |
{ |
| 4537 |
foreach(j; 0 .. 2) |
| 4538 |
{ |
| 4539 |
scope(failure) int i = 0; |
| 4540 |
|
| 4541 |
ushort left = 0xffU; |
| 4542 |
left <<= (ushort.sizeof - 1) * 8; |
| 4543 |
|
| 4544 |
assert((((left & 0xff00U) >> 8) | ((left & 0x00ffU) << 8)) == 0xffu); |
| 4545 |
} |
| 4546 |
} |
| 4547 |
|
| 4548 |
/***************************************************/ |
| 4549 |
|
| 4550 |
struct S7072 |
| 4551 |
{ |
| 4552 |
this(A)(A args) { } |
| 4553 |
} |
| 4554 |
|
| 4555 |
void test7072() { |
| 4556 |
auto s = S7072( null ); |
| 4557 |
} |
| 4558 |
|
| 4559 |
/***************************************************/ |
| 4560 |
|
| 4561 |
struct Point6881 |
| 4562 |
{ |
| 4563 |
float _x, _y; |
| 4564 |
|
| 4565 |
void rotateCCW() |
| 4566 |
{ |
| 4567 |
float tmp = -_x; |
| 4568 |
_x = _y; |
| 4569 |
_y = tmp; |
| 4570 |
} |
| 4571 |
} |
| 4572 |
|
| 4573 |
/***************************************************/ |
| 4574 |
// https://issues.dlang.org/show_bug.cgi?id=7212 |
| 4575 |
void foo7212(scope int delegate(int a) dg) |
| 4576 |
{ |
| 4577 |
} |
| 4578 |
|
| 4579 |
void foo7212(bool a) |
| 4580 |
{ |
| 4581 |
} |
| 4582 |
|
| 4583 |
void test7212() |
| 4584 |
{ |
| 4585 |
foo7212((int a) => a); |
| 4586 |
} |
| 4587 |
|
| 4588 |
/***************************************************/ |
| 4589 |
|
| 4590 |
void test242() |
| 4591 |
{ |
| 4592 |
foreach(v; long.max / 8 .. long.max / 8 + 1) |
| 4593 |
{ |
| 4594 |
immutable long t1 = v; |
| 4595 |
long t2 = t1 + t1; |
| 4596 |
t2 *= 1L << 1; |
| 4597 |
assert(t2 > long.max / 4); |
| 4598 |
} |
| 4599 |
} |
| 4600 |
|
| 4601 |
/***************************************************/ |
| 4602 |
// https://issues.dlang.org/show_bug.cgi?id=7290 |
| 4603 |
|
| 4604 |
void foo7290a(alias dg)() |
| 4605 |
{ |
| 4606 |
assert(dg(5) == 7); |
| 4607 |
} |
| 4608 |
|
| 4609 |
void foo7290b(scope int delegate(int a) dg) |
| 4610 |
{ |
| 4611 |
assert(dg(5) == 7); |
| 4612 |
} |
| 4613 |
|
| 4614 |
void foo7290c(int delegate(int a) dg) |
| 4615 |
{ |
| 4616 |
assert(dg(5) == 7); |
| 4617 |
} |
| 4618 |
|
| 4619 |
void test7290() |
| 4620 |
{ |
| 4621 |
int add = 2; |
| 4622 |
scope dg = (int a) => a + add; |
| 4623 |
|
| 4624 |
// This will break with -preview=dip1000 because a closure will no longer be allocated |
| 4625 |
assert(GC.addrOf(dg.ptr) == null); |
| 4626 |
|
| 4627 |
foo7290a!dg(); |
| 4628 |
foo7290b(dg); |
| 4629 |
foo7290c(dg); // this will fail with -preview=dip1000 and @safe because a scope delegate gets |
| 4630 |
// assigned to @system delegate, but no closure was allocated |
| 4631 |
} |
| 4632 |
|
| 4633 |
/***************************************************/ |
| 4634 |
|
| 4635 |
void test7367() |
| 4636 |
{ |
| 4637 |
char a = '\x00'; |
| 4638 |
char b = '\xFF'; |
| 4639 |
assert(a < b); |
| 4640 |
} |
| 4641 |
|
| 4642 |
/***************************************************/ |
| 4643 |
// https://issues.dlang.org/show_bug.cgi?id=7375 |
| 4644 |
|
| 4645 |
class A7375 {} |
| 4646 |
class B7375(int i) : A7375 {} |
| 4647 |
class C7375(int i) : B7375!i {} |
| 4648 |
|
| 4649 |
template DerivedAlias(int i) |
| 4650 |
{ |
| 4651 |
alias B7375!i DerivedAlias; |
| 4652 |
} |
| 4653 |
|
| 4654 |
alias DerivedAlias!22 X7375; |
| 4655 |
|
| 4656 |
void test7375() |
| 4657 |
{ |
| 4658 |
A7375 foo = new C7375!11(); |
| 4659 |
assert(cast(B7375!22)foo is null); |
| 4660 |
} |
| 4661 |
|
| 4662 |
/***************************************************/ |
| 4663 |
|
| 4664 |
void test6504() |
| 4665 |
{ |
| 4666 |
for (int i=0; i<3; ++i) |
| 4667 |
{ |
| 4668 |
/+ |
| 4669 |
char[] x2 = "xxx" ~ ['c']; |
| 4670 |
if (i == 0) |
| 4671 |
assert(x2[1] == 'x'); |
| 4672 |
x2[1] = 'q'; |
| 4673 |
+/ |
| 4674 |
} |
| 4675 |
} |
| 4676 |
|
| 4677 |
/***************************************************/ |
| 4678 |
|
| 4679 |
struct S7424a |
| 4680 |
{ |
| 4681 |
@property inout(int) g()() inout { return 7424; } |
| 4682 |
void test1() |
| 4683 |
{ |
| 4684 |
int f = g; |
| 4685 |
assert(f == 7424); |
| 4686 |
assert(g == 7424); |
| 4687 |
} |
| 4688 |
void test2() const |
| 4689 |
{ |
| 4690 |
int f = g; |
| 4691 |
assert(f == 7424); |
| 4692 |
assert(g == 7424); |
| 4693 |
} |
| 4694 |
void test3() immutable |
| 4695 |
{ |
| 4696 |
int f = g; |
| 4697 |
assert(f == 7424); |
| 4698 |
assert(g == 7424); |
| 4699 |
} |
| 4700 |
} |
| 4701 |
struct S7425 |
| 4702 |
{ |
| 4703 |
inout(T) g(T)(T x) inout |
| 4704 |
{ |
| 4705 |
return x; |
| 4706 |
} |
| 4707 |
void test1() |
| 4708 |
{ |
| 4709 |
int f = g(2); |
| 4710 |
assert(f == 2); |
| 4711 |
} |
| 4712 |
void test2() const |
| 4713 |
{ |
| 4714 |
double y = g(4.5); |
| 4715 |
assert(y == 4.5); |
| 4716 |
} |
| 4717 |
} |
| 4718 |
void test7424() |
| 4719 |
{ |
| 4720 |
S7424a s1; |
| 4721 |
s1.test1(); |
| 4722 |
s1.test2(); |
| 4723 |
|
| 4724 |
immutable(S7424a) s2; |
| 4725 |
s2.test2(); |
| 4726 |
s2.test3(); |
| 4727 |
|
| 4728 |
const(S7424a) s3; |
| 4729 |
s3.test2(); |
| 4730 |
|
| 4731 |
S7425 s4; |
| 4732 |
s4.test1(); |
| 4733 |
s4.test2(); |
| 4734 |
} |
| 4735 |
|
| 4736 |
/***************************************************/ |
| 4737 |
|
| 4738 |
struct Logger { |
| 4739 |
static bool info()() { |
| 4740 |
return false; |
| 4741 |
} |
| 4742 |
} |
| 4743 |
|
| 4744 |
void test7422() { |
| 4745 |
if (Logger.info()) { |
| 4746 |
} |
| 4747 |
} |
| 4748 |
|
| 4749 |
/***************************************************/ |
| 4750 |
|
| 4751 |
struct S7502 |
| 4752 |
{ |
| 4753 |
int[0x1000] arr; |
| 4754 |
} |
| 4755 |
|
| 4756 |
S7502 s7502; |
| 4757 |
|
| 4758 |
void test7502() |
| 4759 |
{ |
| 4760 |
s7502 = s7502.init; |
| 4761 |
} |
| 4762 |
|
| 4763 |
/***************************************************/ |
| 4764 |
|
| 4765 |
void nextis(void delegate() dg = {}) {} |
| 4766 |
|
| 4767 |
void test4820() { |
| 4768 |
nextis(); |
| 4769 |
} |
| 4770 |
|
| 4771 |
/***************************************************/ |
| 4772 |
|
| 4773 |
void test4820_2() { |
| 4774 |
|
| 4775 |
void nextis(void delegate() dg = {}) {} |
| 4776 |
nextis(); |
| 4777 |
} |
| 4778 |
|
| 4779 |
/***************************************************/ |
| 4780 |
|
| 4781 |
template T3509(bool b) { static assert (b); } |
| 4782 |
|
| 4783 |
template Mix3509() { void f() {} } |
| 4784 |
|
| 4785 |
class C3509 { |
| 4786 |
alias T3509!(is(typeof(M.f))) U; |
| 4787 |
mixin Mix3509!() M; |
| 4788 |
} |
| 4789 |
|
| 4790 |
/***************************************************/ |
| 4791 |
|
| 4792 |
struct S3510(int x) {} |
| 4793 |
|
| 4794 |
template Mix3510() { Sa s; } |
| 4795 |
|
| 4796 |
class C3510 { |
| 4797 |
mixin Mix3510!(); |
| 4798 |
alias S3510!(0) Sa; |
| 4799 |
} |
| 4800 |
|
| 4801 |
/***************************************************/ |
| 4802 |
|
| 4803 |
struct Array243(T) if (is(T == bool)) |
| 4804 |
{ |
| 4805 |
struct Range |
| 4806 |
{ |
| 4807 |
Array243!bool _outer; |
| 4808 |
ulong _a, _b, _c; |
| 4809 |
ulong _d; |
| 4810 |
} |
| 4811 |
|
| 4812 |
Range opSlice() |
| 4813 |
{ |
| 4814 |
return Range(this, 0, 3); |
| 4815 |
} |
| 4816 |
|
| 4817 |
} |
| 4818 |
|
| 4819 |
|
| 4820 |
void test243() { |
| 4821 |
Array243!bool a; |
| 4822 |
} |
| 4823 |
|
| 4824 |
/***************************************************/ |
| 4825 |
// https://issues.dlang.org/show_bug.cgi?id=7742 |
| 4826 |
|
| 4827 |
struct Foo7742 { |
| 4828 |
static immutable f = Foo7742(1, 2); |
| 4829 |
int x, y; |
| 4830 |
} |
| 4831 |
|
| 4832 |
struct Bar7742 { |
| 4833 |
int x, y; |
| 4834 |
static immutable f = Bar7742(1, 2); |
| 4835 |
} |
| 4836 |
|
| 4837 |
void test7742() |
| 4838 |
{ |
| 4839 |
assert(Foo7742.f.x == 1); |
| 4840 |
assert(Foo7742.f.y == 2); |
| 4841 |
|
| 4842 |
assert(Bar7742.f.x == 1); |
| 4843 |
assert(Bar7742.f.y == 2); |
| 4844 |
} |
| 4845 |
|
| 4846 |
/***************************************************/ |
| 4847 |
// https://issues.dlang.org/show_bug.cgi?id=7807 |
| 4848 |
|
| 4849 |
interface Interface7807 |
| 4850 |
{ |
| 4851 |
Interface7807 getNext(); |
| 4852 |
const(Interface7807) getNext() const; |
| 4853 |
} |
| 4854 |
|
| 4855 |
class Implementation7807 : Interface7807 |
| 4856 |
{ |
| 4857 |
Implementation7807 getNext() |
| 4858 |
{ |
| 4859 |
return this; |
| 4860 |
} |
| 4861 |
|
| 4862 |
const(Implementation7807) getNext() const |
| 4863 |
{ |
| 4864 |
return null; |
| 4865 |
} |
| 4866 |
} |
| 4867 |
|
| 4868 |
void test7807() |
| 4869 |
{ |
| 4870 |
auto mc = new Implementation7807(); |
| 4871 |
assert(mc.getNext() is mc); |
| 4872 |
Interface7807 mi = mc; |
| 4873 |
assert(mi.getNext() is mi); |
| 4874 |
|
| 4875 |
auto cc = new const(Implementation7807)(); |
| 4876 |
assert(cc.getNext() is null); |
| 4877 |
const(Interface7807) ci = cc; |
| 4878 |
assert(ci.getNext() is null); |
| 4879 |
} |
| 4880 |
|
| 4881 |
/***************************************************/ |
| 4882 |
// https://issues.dlang.org/show_bug.cgi?id=7815 |
| 4883 |
|
| 4884 |
enum Closure { |
| 4885 |
Matrix |
| 4886 |
} |
| 4887 |
|
| 4888 |
struct BasicMatrix { |
| 4889 |
mixin Operand!( Closure.Matrix ); |
| 4890 |
} |
| 4891 |
|
| 4892 |
template Operand( Closure closure_ ) { |
| 4893 |
alias closure_ closure; |
| 4894 |
} |
| 4895 |
|
| 4896 |
struct Expression( string op_, Lhs, Rhs = void ) { |
| 4897 |
enum lhsClosure = closureOf!Lhs; |
| 4898 |
} |
| 4899 |
|
| 4900 |
template closureOf( T ) { |
| 4901 |
enum closureOf = T.closure; |
| 4902 |
} |
| 4903 |
|
| 4904 |
alias Expression!("+", BasicMatrix) Foo7815; |
| 4905 |
|
| 4906 |
/***************************************************/ |
| 4907 |
|
| 4908 |
struct Test244 { |
| 4909 |
static immutable c = Test244(); |
| 4910 |
static if( true ){} |
| 4911 |
} |
| 4912 |
|
| 4913 |
/***************************************************/ |
| 4914 |
|
| 4915 |
int noswap245(ubyte *data) |
| 4916 |
{ |
| 4917 |
version (LittleEndian) |
| 4918 |
return |
| 4919 |
(data[0]<< 0) | |
| 4920 |
(data[1]<< 8) | |
| 4921 |
(data[2]<< 16) | |
| 4922 |
(data[3]<< 24); |
| 4923 |
version (BigEndian) |
| 4924 |
return |
| 4925 |
(data[0]<< 24) | |
| 4926 |
(data[1]<< 16) | |
| 4927 |
(data[2]<< 8) | |
| 4928 |
(data[3]<< 0); |
| 4929 |
|
| 4930 |
} |
| 4931 |
|
| 4932 |
int bswap245(ubyte *data) |
| 4933 |
{ |
| 4934 |
version (LittleEndian) |
| 4935 |
return |
| 4936 |
(data[0]<< 24) | |
| 4937 |
(data[1]<< 16) | |
| 4938 |
(data[2]<< 8) | |
| 4939 |
(data[3]<< 0); |
| 4940 |
version (BigEndian) |
| 4941 |
return |
| 4942 |
(data[0]<< 0) | |
| 4943 |
(data[1]<< 8) | |
| 4944 |
(data[2]<< 16) | |
| 4945 |
(data[3]<< 24); |
| 4946 |
} |
| 4947 |
|
| 4948 |
void test245() |
| 4949 |
{ |
| 4950 |
int x1 = 0x01234567; |
| 4951 |
x1 = noswap245(cast(ubyte *)&x1); |
| 4952 |
assert(x1 == 0x01234567); |
| 4953 |
x1 = bswap245(cast(ubyte *)&x1); |
| 4954 |
assert(x1 == 0x67452301); |
| 4955 |
} |
| 4956 |
|
| 4957 |
/***************************************************/ |
| 4958 |
|
| 4959 |
mixin template mix7974() |
| 4960 |
{ |
| 4961 |
uint _x; |
| 4962 |
} |
| 4963 |
|
| 4964 |
struct Foo7974 |
| 4965 |
{ |
| 4966 |
static immutable Foo7974 fa = Foo7974(0); |
| 4967 |
|
| 4968 |
this(uint x) |
| 4969 |
{ |
| 4970 |
_x = x; |
| 4971 |
} |
| 4972 |
|
| 4973 |
mixin mix7974!(); |
| 4974 |
} |
| 4975 |
|
| 4976 |
/***************************************************/ |
| 4977 |
// https://issues.dlang.org/show_bug.cgi?id=4155 |
| 4978 |
|
| 4979 |
|
| 4980 |
float getnanf() { return float.nan; } |
| 4981 |
double getnand() { return double.nan; } |
| 4982 |
real getnanr() { return real.nan; } |
| 4983 |
|
| 4984 |
void test4155() |
| 4985 |
{ |
| 4986 |
assert(getnanf() != 0); |
| 4987 |
assert(getnand() != 0); |
| 4988 |
assert(getnanr() != 0); |
| 4989 |
} |
| 4990 |
|
| 4991 |
/***************************************************/ |
| 4992 |
// https://issues.dlang.org/show_bug.cgi?id=7911 |
| 4993 |
|
| 4994 |
struct Klass7911 |
| 4995 |
{ |
| 4996 |
double value; |
| 4997 |
|
| 4998 |
//static const Klass zero; // Does not trigger bug! |
| 4999 |
static const Klass7911 zero = {0}; // Bug trigger #1 |
| 5000 |
|
| 5001 |
static if (true) // Bug trigger #2 |
| 5002 |
static if (true) |
| 5003 |
Klass7911 foo() { return Klass7911(); } |
| 5004 |
} |
| 5005 |
|
| 5006 |
void test7911() |
| 5007 |
{ |
| 5008 |
auto a = Klass7911().foo(); |
| 5009 |
} |
| 5010 |
|
| 5011 |
/***************************************************/ |
| 5012 |
// https://issues.dlang.org/show_bug.cgi?id=8429 |
| 5013 |
|
| 5014 |
static if(true) |
| 5015 |
version = Foo8429; |
| 5016 |
static if(true) |
| 5017 |
version(Foo8429) {} |
| 5018 |
|
| 5019 |
/***************************************************/ |
| 5020 |
// https://issues.dlang.org/show_bug.cgi?id=8069 |
| 5021 |
|
| 5022 |
interface I8069 |
| 5023 |
{ |
| 5024 |
void f(); |
| 5025 |
} |
| 5026 |
struct A8069 |
| 5027 |
{ |
| 5028 |
final class B8069 : I8069 |
| 5029 |
{ |
| 5030 |
A8069 a; |
| 5031 |
void f() {} |
| 5032 |
} |
| 5033 |
} |
| 5034 |
|
| 5035 |
/***************************************************/ |
| 5036 |
// https://issues.dlang.org/show_bug.cgi?id=8095 |
| 5037 |
|
| 5038 |
void bug8095(int p0, int *p1, int z, int edx, int *p4, int p5) |
| 5039 |
{ |
| 5040 |
int x = z / 3; |
| 5041 |
if (z) { |
| 5042 |
int c = p5 + *p1 + p0; // *p1 segfaults -- it does *z !! |
| 5043 |
if ( z / 5 ) |
| 5044 |
c = 1; |
| 5045 |
*p4 = c; |
| 5046 |
x = c; |
| 5047 |
} |
| 5048 |
void never_used() { |
| 5049 |
++x; |
| 5050 |
int * unused = p1; // kills p4 somehow |
| 5051 |
} |
| 5052 |
} |
| 5053 |
|
| 5054 |
void test8095() { |
| 5055 |
int x, y; |
| 5056 |
bug8095(0, &x, 1, 0, &y, 0); |
| 5057 |
} |
| 5058 |
|
| 5059 |
/***************************************************/ |
| 5060 |
// https://issues.dlang.org/show_bug.cgi?id=8091 |
| 5061 |
|
| 5062 |
int solve1(int n) { |
| 5063 |
int a; |
| 5064 |
return ((a = n ? (n>=1u) : 1) != 0) ? a : 0; |
| 5065 |
// return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0; |
| 5066 |
} |
| 5067 |
|
| 5068 |
int solve2(int n) { |
| 5069 |
int a; |
| 5070 |
// return ((a = n ? (n>=1u) : 1) != 0) ? a : 0; |
| 5071 |
return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0; |
| 5072 |
} |
| 5073 |
|
| 5074 |
void test8091() { |
| 5075 |
assert(solve1(1) == 1); |
| 5076 |
assert(solve2(1) == 1); |
| 5077 |
} |
| 5078 |
|
| 5079 |
/***************************************************/ |
| 5080 |
|
| 5081 |
struct IPoint { |
| 5082 |
int x, y; |
| 5083 |
} |
| 5084 |
|
| 5085 |
void bug6189_2(uint half, IPoint pos, float[4] *pts, uint unused) { |
| 5086 |
pos.y += half; |
| 5087 |
float xo = pos.x; |
| 5088 |
float yo = pos.y; |
| 5089 |
|
| 5090 |
(*pts)[0] = xo; |
| 5091 |
(*pts)[1] = yo; |
| 5092 |
(*pts)[2] = xo; |
| 5093 |
} |
| 5094 |
|
| 5095 |
void test6189_2() |
| 5096 |
{ |
| 5097 |
auto pos = IPoint(2, 2); |
| 5098 |
float[4] pts; |
| 5099 |
pts[0] = pts[1] = pts[2] = pts[3] = 0; |
| 5100 |
bug6189_2(0, pos, &pts, 0); |
| 5101 |
|
| 5102 |
assert(pts[0] == 2); |
| 5103 |
} |
| 5104 |
|
| 5105 |
/***************************************************/ |
| 5106 |
// https://issues.dlang.org/show_bug.cgi?id=8199 |
| 5107 |
|
| 5108 |
version (D_InlineAsm_X86_64) |
| 5109 |
{ |
| 5110 |
version = Check; |
| 5111 |
enum Align = 0x8; |
| 5112 |
} |
| 5113 |
else version (D_InlineAsm_X86) |
| 5114 |
{ |
| 5115 |
version = Check; |
| 5116 |
version (OSX) |
| 5117 |
enum Align = 0xC; |
| 5118 |
// version (linux) |
| 5119 |
// enum Align = 0xC; |
| 5120 |
} |
| 5121 |
|
| 5122 |
void onFailure() |
| 5123 |
{ |
| 5124 |
assert(0, "alignment failure"); |
| 5125 |
} |
| 5126 |
|
| 5127 |
void checkAlign() |
| 5128 |
{ |
| 5129 |
version (Check) |
| 5130 |
{ |
| 5131 |
static if (is(typeof(Align))) |
| 5132 |
asm |
| 5133 |
{ |
| 5134 |
naked; |
| 5135 |
mov EAX, ESP; |
| 5136 |
and EAX, 0xF; |
| 5137 |
cmp EAX, Align; |
| 5138 |
je Lpass; |
| 5139 |
call onFailure; |
| 5140 |
Lpass: |
| 5141 |
ret; |
| 5142 |
} |
| 5143 |
} |
| 5144 |
else |
| 5145 |
return; |
| 5146 |
} |
| 5147 |
|
| 5148 |
void foo8199() |
| 5149 |
{ |
| 5150 |
} |
| 5151 |
|
| 5152 |
void test8199() |
| 5153 |
{ |
| 5154 |
try |
| 5155 |
foo8199(); |
| 5156 |
finally |
| 5157 |
checkAlign(); |
| 5158 |
} |
| 5159 |
|
| 5160 |
/***************************************************/ |
| 5161 |
// https://issues.dlang.org/show_bug.cgi?id=13285 |
| 5162 |
void test13285() |
| 5163 |
{ |
| 5164 |
static struct S |
| 5165 |
{ |
| 5166 |
~this() |
| 5167 |
{ |
| 5168 |
checkAlign(); |
| 5169 |
} |
| 5170 |
} |
| 5171 |
S s; // correct alignment of RSP when calling ~this() |
| 5172 |
S(); // incorrect alignment |
| 5173 |
} |
| 5174 |
|
| 5175 |
/***************************************************/ |
| 5176 |
|
| 5177 |
void test246() |
| 5178 |
{ |
| 5179 |
struct Struct |
| 5180 |
{ |
| 5181 |
void method() {} |
| 5182 |
} |
| 5183 |
auto val = Struct(); |
| 5184 |
} |
| 5185 |
|
| 5186 |
/***************************************************/ |
| 5187 |
// https://issues.dlang.org/show_bug.cgi?id=8423 |
| 5188 |
|
| 5189 |
struct S8423 |
| 5190 |
{ |
| 5191 |
int opCmp(S8423 rhs) |
| 5192 |
{ |
| 5193 |
return 1; |
| 5194 |
} |
| 5195 |
} |
| 5196 |
|
| 5197 |
void enforce8423(bool value, string a, string b) |
| 5198 |
{ |
| 5199 |
if (!value) assert(false); |
| 5200 |
} |
| 5201 |
|
| 5202 |
void test8423() |
| 5203 |
{ |
| 5204 |
auto a = S8423(); |
| 5205 |
auto b = S8423(); |
| 5206 |
enforce8423(a > b, null, null); |
| 5207 |
} |
| 5208 |
|
| 5209 |
/***************************************************/ |
| 5210 |
class Foo8496 |
| 5211 |
{ |
| 5212 |
public: |
| 5213 |
void foo(uint value) |
| 5214 |
{ |
| 5215 |
ubyte size = value < (0x7fU << 0 ) ? 1 : |
| 5216 |
value < (0x7fU << 14) ? 2 : |
| 5217 |
3; |
| 5218 |
printf("%u\n", size); |
| 5219 |
assert(size == 2); |
| 5220 |
} |
| 5221 |
} |
| 5222 |
|
| 5223 |
void test8496() |
| 5224 |
{ |
| 5225 |
Foo8496 f = new Foo8496(); |
| 5226 |
f.foo(1000000); |
| 5227 |
} |
| 5228 |
|
| 5229 |
/***************************************************/ |
| 5230 |
|
| 5231 |
long foo8840() { return 4; } |
| 5232 |
|
| 5233 |
int bar8840(long g) { assert(g == 4); return printf("%llx\n", g); } |
| 5234 |
|
| 5235 |
void test8840() |
| 5236 |
{ |
| 5237 |
long f1 = foo8840(); |
| 5238 |
long f2 = foo8840(); |
| 5239 |
|
| 5240 |
long f = (f1 < f2 ? f1 : f2); |
| 5241 |
int len = (f == 0 ? 0 : bar8840(f)); |
| 5242 |
} |
| 5243 |
|
| 5244 |
/***************************************************/ |
| 5245 |
|
| 5246 |
struct S8889 |
| 5247 |
{ |
| 5248 |
real f; |
| 5249 |
int i; |
| 5250 |
} |
| 5251 |
|
| 5252 |
void test8889() |
| 5253 |
{ |
| 5254 |
} |
| 5255 |
|
| 5256 |
/***************************************************/ |
| 5257 |
|
| 5258 |
struct S8870 |
| 5259 |
{ |
| 5260 |
float x = 0; |
| 5261 |
float y = 0; |
| 5262 |
float z = 0; |
| 5263 |
float w = 0; |
| 5264 |
} |
| 5265 |
|
| 5266 |
void test8870() |
| 5267 |
{ |
| 5268 |
S8870 r1 = S8870(1,2,3,4); |
| 5269 |
S8870 r2 = S8870(5,6,7,8); |
| 5270 |
|
| 5271 |
foo8870(r1, r2, false, 1); |
| 5272 |
bar8870(r1, r2, false, 1); |
| 5273 |
} |
| 5274 |
|
| 5275 |
//extern (C) |
| 5276 |
void foo8870(S8870 t1, S8870 t2, bool someBool, float finalFloat) |
| 5277 |
{ |
| 5278 |
printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w); |
| 5279 |
printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w); |
| 5280 |
printf("someBool: %d\n", someBool); |
| 5281 |
printf("finalFloat: %g\n", finalFloat); |
| 5282 |
|
| 5283 |
assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4); |
| 5284 |
assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8); |
| 5285 |
assert(someBool == false); |
| 5286 |
assert(finalFloat == 1); |
| 5287 |
} |
| 5288 |
|
| 5289 |
extern (C) |
| 5290 |
void bar8870(S8870 t1, S8870 t2, bool someBool, float finalFloat) |
| 5291 |
{ |
| 5292 |
printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w); |
| 5293 |
printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w); |
| 5294 |
printf("someBool: %d\n", someBool); |
| 5295 |
printf("finalFloat: %g\n", finalFloat); |
| 5296 |
|
| 5297 |
assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4); |
| 5298 |
assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8); |
| 5299 |
assert(someBool == false); |
| 5300 |
assert(finalFloat == 1); |
| 5301 |
} |
| 5302 |
|
| 5303 |
/***************************************************/ |
| 5304 |
|
| 5305 |
int foo9781(int[1] x) |
| 5306 |
{ |
| 5307 |
return x[0] * x[0]; |
| 5308 |
} |
| 5309 |
|
| 5310 |
void test9781() |
| 5311 |
{ |
| 5312 |
foo9781([7]); |
| 5313 |
} |
| 5314 |
|
| 5315 |
/***************************************************/ |
| 5316 |
|
| 5317 |
struct S247 { size_t length; size_t ptr; } |
| 5318 |
|
| 5319 |
S247 foo247() |
| 5320 |
{ |
| 5321 |
S247 f; |
| 5322 |
f.length = 7; |
| 5323 |
f.ptr = 8; |
| 5324 |
return f; |
| 5325 |
} |
| 5326 |
|
| 5327 |
void test247() |
| 5328 |
{ |
| 5329 |
S247 f; |
| 5330 |
f = foo247(); |
| 5331 |
assert(f.length == 7); |
| 5332 |
assert(f.ptr == 8); |
| 5333 |
} |
| 5334 |
|
| 5335 |
/***************************************************/ |
| 5336 |
// https://issues.dlang.org/show_bug.cgi?id=8340 |
| 5337 |
|
| 5338 |
void test8340(){ |
| 5339 |
byte[] ba = [1,2,3,4,5]; |
| 5340 |
short[] sa = [1,2,3,4,5]; |
| 5341 |
int[] ia = [1,2,3,4,5]; |
| 5342 |
long[] la = [1,2,3,4,5]; |
| 5343 |
|
| 5344 |
ba[2] *= -1; |
| 5345 |
sa[2] *= -1; |
| 5346 |
ia[2] *= -1; |
| 5347 |
la[2] *= -1; |
| 5348 |
|
| 5349 |
assert(ba == [1,2,-3,4,5]); |
| 5350 |
assert(sa == [1,2,-3,4,5]); |
| 5351 |
assert(ia == [1,2,-3,4,5]); |
| 5352 |
assert(la == [1,2,-3,4,5]); |
| 5353 |
} |
| 5354 |
|
| 5355 |
/***************************************************/ |
| 5356 |
// https://issues.dlang.org/show_bug.cgi?id=8376 |
| 5357 |
|
| 5358 |
void test8376() { |
| 5359 |
int i = 0; |
| 5360 |
int[2] a; |
| 5361 |
a[1]=1; |
| 5362 |
while(!a[0]){ |
| 5363 |
if(a[i]) continue; |
| 5364 |
a[i] = 1; |
| 5365 |
} |
| 5366 |
} |
| 5367 |
|
| 5368 |
/***************************************************/ |
| 5369 |
|
| 5370 |
// Don't call, compile only |
| 5371 |
void test8987(){ |
| 5372 |
int last = 0; |
| 5373 |
int count = 0; |
| 5374 |
int d; |
| 5375 |
|
| 5376 |
for (int x = 0; count < 100; x++){ |
| 5377 |
d = 3; |
| 5378 |
|
| 5379 |
while (x / d) |
| 5380 |
d += 2; |
| 5381 |
|
| 5382 |
if (x & d) { |
| 5383 |
last = x; |
| 5384 |
count++; |
| 5385 |
} |
| 5386 |
} |
| 5387 |
|
| 5388 |
printf("Last: %d\n", last); |
| 5389 |
} |
| 5390 |
|
| 5391 |
/***************************************************/ |
| 5392 |
// https://issues.dlang.org/show_bug.cgi?id=8796 |
| 5393 |
|
| 5394 |
int* wrong8796(int* p) |
| 5395 |
{ |
| 5396 |
*p++ = 1; |
| 5397 |
return p; |
| 5398 |
} |
| 5399 |
|
| 5400 |
void test8796() |
| 5401 |
{ |
| 5402 |
int[3] arr; |
| 5403 |
int* q = arr.ptr; |
| 5404 |
q = wrong8796(q); |
| 5405 |
assert(q != arr.ptr); |
| 5406 |
} |
| 5407 |
|
| 5408 |
/***************************************************/ |
| 5409 |
// https://issues.dlang.org/show_bug.cgi?id=9171 |
| 5410 |
|
| 5411 |
ulong bitcomb9171(ulong v) |
| 5412 |
{ |
| 5413 |
if(v) |
| 5414 |
{ |
| 5415 |
ulong result; |
| 5416 |
if(v & 1) |
| 5417 |
{ |
| 5418 |
auto r = bitcomb9171(v >> 1); |
| 5419 |
printf("r=%016llx\n", r); |
| 5420 |
|
| 5421 |
auto z = ((r & (r-1) ^ r)); |
| 5422 |
check9171("str", z>>1); |
| 5423 |
// printf("z=%016llx\n", z>>1); |
| 5424 |
return r; |
| 5425 |
} |
| 5426 |
else |
| 5427 |
{ |
| 5428 |
auto fb = v & (v-1) ^ v; |
| 5429 |
result = (fb >> 1) | (v ^ fb); |
| 5430 |
} |
| 5431 |
return result; |
| 5432 |
} |
| 5433 |
return 0; |
| 5434 |
} |
| 5435 |
|
| 5436 |
void check9171(const char *s, ulong v) |
| 5437 |
{ |
| 5438 |
assert(v == 0x80000000); |
| 5439 |
} |
| 5440 |
|
| 5441 |
void test9171() |
| 5442 |
{ |
| 5443 |
bitcomb9171(0b1110000000000000010000000000000000000000000000000001); |
| 5444 |
} |
| 5445 |
|
| 5446 |
/***************************************************/ |
| 5447 |
// https://issues.dlang.org/show_bug.cgi?id=9248 |
| 5448 |
|
| 5449 |
void test9248() |
| 5450 |
{ |
| 5451 |
void*[] a = [cast(void*)1]; |
| 5452 |
void*[] b = [cast(void*)2]; |
| 5453 |
auto c = a ~ b; |
| 5454 |
assert(c == [cast(void*)1, cast(void*)2]); |
| 5455 |
} |
| 5456 |
|
| 5457 |
/***************************************************/ |
| 5458 |
// https://issues.dlang.org/show_bug.cgi?id=14682 |
| 5459 |
|
| 5460 |
void test14682a() |
| 5461 |
{ |
| 5462 |
// operands |
| 5463 |
int[] a1; |
| 5464 |
int[][] a2; |
| 5465 |
int[][][] a3; |
| 5466 |
int[][][][] a4; |
| 5467 |
|
| 5468 |
// results |
| 5469 |
int[] r1w = []; assert(r1w.length == 0); |
| 5470 |
int[][] r2w = []; assert(r2w.length == 0); |
| 5471 |
int[][][] r3w = []; assert(r3w.length == 0); |
| 5472 |
int[][][][] r4w = []; assert(r4w.length == 0); |
| 5473 |
// ---- |
| 5474 |
int[][] r2x = [[]]; assert(r2x.length == 1 && r2x[0].length == 0); |
| 5475 |
int[][][] r3x = [[]]; assert(r3x.length == 1 && r3x[0].length == 0); |
| 5476 |
int[][][][] r4x = [[]]; assert(r4x.length == 1 && r4x[0].length == 0); |
| 5477 |
// ---- |
| 5478 |
int[][][] r3y = [[[]]]; assert(r3y.length == 1 && r3y[0].length == 1 && r3y[0][0].length == 0); |
| 5479 |
int[][][][] r4y = [[[]]]; assert(r4y.length == 1 && r4y[0].length == 1 && r4y[0][0].length == 0); |
| 5480 |
// ---- |
| 5481 |
int[][][][] r4z = [[[[]]]]; assert(r4z.length == 1 && r4z[0].length == 1 && r4z[0][0].length == 1 && r4z[0][0][0].length == 0); |
| 5482 |
|
| 5483 |
// ArrayLiteralExp conforms to the type of LHS. |
| 5484 |
{ auto x = a1 ~ [] ; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity |
| 5485 |
{ auto x = a2 ~ [] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity |
| 5486 |
{ auto x = a3 ~ [] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity |
| 5487 |
{ auto x = a4 ~ [] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity |
| 5488 |
// ---- |
| 5489 |
//{ auto x = a1 ~ [[]] ; } // (see test14682b) |
| 5490 |
{ auto x = a2 ~ [[]] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity |
| 5491 |
{ auto x = a3 ~ [[]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity |
| 5492 |
{ auto x = a4 ~ [[]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity |
| 5493 |
// ---- |
| 5494 |
static assert(!__traits(compiles, { auto x = a1 ~ [[[]]] ; })); |
| 5495 |
//{ auto x = a2 ~ [[[]]] ; } // (see test14682b) |
| 5496 |
{ auto x = a3 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity |
| 5497 |
{ auto x = a4 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity |
| 5498 |
// ---- |
| 5499 |
static assert(!__traits(compiles, { auto x = a1 ~ [[[[]]]]; })); |
| 5500 |
static assert(!__traits(compiles, { auto x = a2 ~ [[[[]]]]; })); |
| 5501 |
//{ auto x = a3 ~ [[[[]]]]; } // (see test14682b) |
| 5502 |
{ auto x = a4 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity |
| 5503 |
|
| 5504 |
// ArrayLiteralExp conforms to the type of RHS. |
| 5505 |
{ auto x = [] ~ a1; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity |
| 5506 |
{ auto x = [] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity |
| 5507 |
{ auto x = [] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity |
| 5508 |
{ auto x = [] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity |
| 5509 |
// ---- |
| 5510 |
//{ auto x = [[]] ~ a1; } // (see test14682b) |
| 5511 |
{ auto x = [[]] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity |
| 5512 |
{ auto x = [[]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity |
| 5513 |
{ auto x = [[]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity |
| 5514 |
// ---- |
| 5515 |
static assert(!__traits(compiles, { auto x = [[[]]] ~ a1; })); |
| 5516 |
//{ auto x = [[[]]] ~ a2; } // (see test14682b) |
| 5517 |
{ auto x = [[[]]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity |
| 5518 |
{ auto x = [[[]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity |
| 5519 |
// ---- |
| 5520 |
static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a1; })); |
| 5521 |
static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a2; })); |
| 5522 |
//{ auto x = [[[[]]]] ~ a3; } // (see test14682b) |
| 5523 |
{ auto x = [[[[]]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity |
| 5524 |
} |
| 5525 |
|
| 5526 |
void test14682b() |
| 5527 |
{ |
| 5528 |
// operands |
| 5529 |
int[] a1; |
| 5530 |
int[][] a2; |
| 5531 |
int[][][] a3; |
| 5532 |
int[][][][] a4; |
| 5533 |
|
| 5534 |
// results |
| 5535 |
int[][] r2a = [[], [] ]; assert(r2a.length == 2 && r2a[0].length == 0 && r2a[1].length == 0); |
| 5536 |
//int[][][] r3a = [[], [[]] ]; // should work, but doesn't |
| 5537 |
//int[][][][] r4a = [[], [[[]]]]; // should work, but doesn't |
| 5538 |
int[][][] r3a; { r3a.length = 2; r3a[0] = []; r3a[1] = [[]] ; } |
| 5539 |
assert(r3a.length == 2 && r3a[0].length == 0 && r3a[1].length == 1 && r3a[1][0].length == 0); |
| 5540 |
int[][][][] r4a; { r4a.length = 2; r4a[0] = []; r4a[1] = [[[]]]; } |
| 5541 |
assert(r4a.length == 2 && r4a[0].length == 0 && r4a[1].length == 1 && r4a[1][0].length == 1 && r4a[1][0][0].length == 0); |
| 5542 |
// ---- |
| 5543 |
int[][] r2b = [ [] , []]; assert(r2b.length == 2 && r2b[1].length == 0 && r2b[0].length == 0); |
| 5544 |
//int[][][] r3b = [ [[]] , []]; // should work, but doesn't |
| 5545 |
//int[][][][] r4b = [[[[]]], []]; // should work, but doesn't |
| 5546 |
int[][][] r3b; { r3b.length = 2; r3b[0] = [[]] ; r3b[1] = []; } |
| 5547 |
assert(r3b.length == 2 && r3b[1].length == 0 && r3b[0].length == 1 && r3b[0][0].length == 0); |
| 5548 |
int[][][][] r4b; { r4b.length = 2; r4b[0] = [[[]]]; r4b[1] = []; } |
| 5549 |
assert(r4b.length == 2 && r4b[1].length == 0 && r4b[0].length == 1 && r4b[0][0].length == 1 && r4b[0][0][0].length == 0); |
| 5550 |
|
| 5551 |
// ArrayLiteralExp conforms to the typeof(LHS)->arrayOf(). |
| 5552 |
{ auto x = a1 ~ [[]] ; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2a); } // fix |
| 5553 |
{ auto x = a2 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3a); } // fix |
| 5554 |
{ auto x = a3 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4a); } // fix |
| 5555 |
|
| 5556 |
// ArrayLiteralExp conforms to the typeof(RHS)->arrayOf(). |
| 5557 |
{ auto x = [[]] ~ a1; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2b); } // fix |
| 5558 |
{ auto x = [[[]]] ~ a2; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3b); } // fix |
| 5559 |
{ auto x = [[[[]]]] ~ a3; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4b); } // fix |
| 5560 |
} |
| 5561 |
|
| 5562 |
|
| 5563 |
/***************************************************/ |
| 5564 |
// https://issues.dlang.org/show_bug.cgi?id=9739 |
| 5565 |
|
| 5566 |
class Foo9739 |
| 5567 |
{ |
| 5568 |
int val = 1; |
| 5569 |
this(int arg = 2) { val = arg; } |
| 5570 |
} |
| 5571 |
|
| 5572 |
class Bar9739 : Foo9739 { } |
| 5573 |
|
| 5574 |
void test9739() |
| 5575 |
{ |
| 5576 |
Bar9739 bar = new Bar9739; |
| 5577 |
assert(bar.val == 2); |
| 5578 |
} |
| 5579 |
|
| 5580 |
/***************************************************/ |
| 5581 |
// https://issues.dlang.org/show_bug.cgi?id=6057 |
| 5582 |
void test6057() |
| 5583 |
{ |
| 5584 |
enum Foo { A=1, B=2 } |
| 5585 |
Foo[] bar = [cast(Foo)1]; |
| 5586 |
} |
| 5587 |
|
| 5588 |
/***************************************************/ |
| 5589 |
|
| 5590 |
ulong d2ulong(double u) |
| 5591 |
{ |
| 5592 |
return cast(ulong)u; |
| 5593 |
} |
| 5594 |
|
| 5595 |
void testdbl_to_ulong() |
| 5596 |
{ |
| 5597 |
auto u = d2ulong(12345.6); |
| 5598 |
//writeln(u); |
| 5599 |
assert(u == 12345); |
| 5600 |
|
| 5601 |
static if (real.mant_dig <= 64) |
| 5602 |
{ |
| 5603 |
real adjust = 1.0L/real.epsilon; |
| 5604 |
u = d2ulong(adjust); |
| 5605 |
//writefln("%s %s", adjust, u); |
| 5606 |
static if(real.mant_dig == 64) |
| 5607 |
assert(u == 9223372036854775808UL); |
| 5608 |
else static if(real.mant_dig == 53) |
| 5609 |
assert(u == 4503599627370496UL); |
| 5610 |
else |
| 5611 |
static assert(false, "Test not implemented for this architecture"); |
| 5612 |
|
| 5613 |
auto v = d2ulong(adjust * 1.1); |
| 5614 |
//writefln("%s %s %s", adjust, v, u + u/10); |
| 5615 |
|
| 5616 |
// The following can vary in the last bits with different optimization settings, |
| 5617 |
// i.e. the conversion from real to double may not happen. |
| 5618 |
//assert(v == 10145709240540254208UL); |
| 5619 |
} |
| 5620 |
} |
| 5621 |
|
| 5622 |
/***************************************************/ |
| 5623 |
|
| 5624 |
|
| 5625 |
|
| 5626 |
uint d2uint(double u) |
| 5627 |
{ |
| 5628 |
return cast(uint)u; |
| 5629 |
} |
| 5630 |
|
| 5631 |
void testdbl_to_uint() |
| 5632 |
{ |
| 5633 |
auto u = d2uint(12345.6); |
| 5634 |
//writeln(u); |
| 5635 |
assert(u == 12345); |
| 5636 |
} |
| 5637 |
|
| 5638 |
/***************************************************/ |
| 5639 |
|
| 5640 |
ulong r2ulong(real u) |
| 5641 |
{ |
| 5642 |
return cast(ulong)u; |
| 5643 |
} |
| 5644 |
|
| 5645 |
void testreal_to_ulong() |
| 5646 |
{ |
| 5647 |
auto u = r2ulong(12345.6L); |
| 5648 |
//writeln(u); |
| 5649 |
assert(u == 12345); |
| 5650 |
|
| 5651 |
real adjust = 1.0L/real.epsilon; |
| 5652 |
u = r2ulong(adjust); |
| 5653 |
//writefln("%s %s", adjust, u); |
| 5654 |
static if(real.mant_dig == 113) |
| 5655 |
assert(u == 18446744073709551615UL); |
| 5656 |
else static if(real.mant_dig == 106) |
| 5657 |
assert(u == 18446744073709551615UL); |
| 5658 |
else static if(real.mant_dig == 64) |
| 5659 |
assert(u == 9223372036854775808UL); |
| 5660 |
else static if(real.mant_dig == 53) |
| 5661 |
assert(u == 4503599627370496UL); |
| 5662 |
else |
| 5663 |
static assert(false, "Test not implemented for this architecture"); |
| 5664 |
|
| 5665 |
auto v = r2ulong(adjust * 1.1); |
| 5666 |
//writefln("%s %s %s", adjust, v, u + u/10); |
| 5667 |
|
| 5668 |
//assert(v == 10145709240540253389UL); |
| 5669 |
} |
| 5670 |
|
| 5671 |
/***************************************************/ |
| 5672 |
|
| 5673 |
long testbt1(long a, long b, int c) |
| 5674 |
{ |
| 5675 |
return a + ((b >> c) & 1); |
| 5676 |
// return a + ((b & (1L << c)) != 0); |
| 5677 |
} |
| 5678 |
|
| 5679 |
|
| 5680 |
long testbt2(long a, long b, int c) |
| 5681 |
{ |
| 5682 |
// return a + ((b >> c) & 1); |
| 5683 |
return a + ((b & (1L << c)) != 0); |
| 5684 |
} |
| 5685 |
|
| 5686 |
int testbt3(int a, int b, int c) |
| 5687 |
{ |
| 5688 |
return a + ((b >> c) & 1); |
| 5689 |
// return a + ((b & (1 << c)) != 0); |
| 5690 |
} |
| 5691 |
|
| 5692 |
int testbt4(int a, int b, int c) |
| 5693 |
{ |
| 5694 |
// return a + ((b >> c) & 1); |
| 5695 |
return a + ((b & (1 << c)) != 0); |
| 5696 |
} |
| 5697 |
|
| 5698 |
|
| 5699 |
void test248() |
| 5700 |
{ |
| 5701 |
auto a1 = testbt1(3, 4, 2); |
| 5702 |
assert(a1 == 4); |
| 5703 |
a1 = testbt2(3, 4, 2); |
| 5704 |
assert(a1 == 4); |
| 5705 |
a1 = testbt3(3, 4, 2); |
| 5706 |
assert(a1 == 4); |
| 5707 |
a1 = testbt4(3, 4, 2); |
| 5708 |
assert(a1 == 4); |
| 5709 |
|
| 5710 |
a1 = testbt1(3, 8, 2); |
| 5711 |
assert(a1 == 3); |
| 5712 |
a1 = testbt2(3, 8, 2); |
| 5713 |
assert(a1 == 3); |
| 5714 |
a1 = testbt3(3, 8, 2); |
| 5715 |
assert(a1 == 3); |
| 5716 |
a1 = testbt4(3, 8, 2); |
| 5717 |
assert(a1 == 3); |
| 5718 |
} |
| 5719 |
|
| 5720 |
/***************************************************/ |
| 5721 |
|
| 5722 |
int foo249(int a, int b) |
| 5723 |
{ |
| 5724 |
return a + ((b & 0x80) != 0); |
| 5725 |
} |
| 5726 |
|
| 5727 |
long bar249(long a, int b) |
| 5728 |
{ |
| 5729 |
return a + ((b & 0x80) != 0); |
| 5730 |
} |
| 5731 |
|
| 5732 |
void test249() |
| 5733 |
{ |
| 5734 |
{ |
| 5735 |
auto i = foo249(3, 6); |
| 5736 |
assert(i == 3); |
| 5737 |
i = foo249(3, 0x88); |
| 5738 |
assert(i == 4); |
| 5739 |
} |
| 5740 |
{ |
| 5741 |
auto i = bar249(3, 6); |
| 5742 |
assert(i == 3); |
| 5743 |
i = bar249(3, 0x88); |
| 5744 |
assert(i == 4); |
| 5745 |
} |
| 5746 |
} |
| 5747 |
|
| 5748 |
/***************************************************/ |
| 5749 |
|
| 5750 |
// These should all compile to a BT instruction when -O, for -m32 and -m64 |
| 5751 |
|
| 5752 |
int bt32(uint *p, uint b) { return ((p[b >> 5] & (1 << (b & 0x1F)))) != 0; } |
| 5753 |
|
| 5754 |
int bt64a(ulong *p, uint b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; } |
| 5755 |
|
| 5756 |
int bt64b(ulong *p, size_t b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; } |
| 5757 |
|
| 5758 |
void test250() |
| 5759 |
{ |
| 5760 |
static uint[2] a1 = [0x1001_1100, 0x0220_0012]; |
| 5761 |
|
| 5762 |
if ( bt32(a1.ptr,30)) assert(0); |
| 5763 |
if (!bt32(a1.ptr,8)) assert(0); |
| 5764 |
if ( bt32(a1.ptr,30+32)) assert(0); |
| 5765 |
if (!bt32(a1.ptr,1+32)) assert(0); |
| 5766 |
|
| 5767 |
static ulong[2] a2 = [0x1001_1100_12345678, 0x0220_0012_12345678]; |
| 5768 |
|
| 5769 |
if ( bt64a(a2.ptr,30+32)) assert(0); |
| 5770 |
if (!bt64a(a2.ptr,8+32)) assert(0); |
| 5771 |
if ( bt64a(a2.ptr,30+32+64)) assert(0); |
| 5772 |
if (!bt64a(a2.ptr,1+32+64)) assert(0); |
| 5773 |
|
| 5774 |
if ( bt64b(a2.ptr,30+32)) assert(0); |
| 5775 |
if (!bt64b(a2.ptr,8+32)) assert(0); |
| 5776 |
if ( bt64b(a2.ptr,30+32+64)) assert(0); |
| 5777 |
if (!bt64b(a2.ptr,1+32+64)) assert(0); |
| 5778 |
} |
| 5779 |
|
| 5780 |
/***************************************************/ |
| 5781 |
|
| 5782 |
struct S251 { int a,b,c,d; } |
| 5783 |
|
| 5784 |
S251 foo251(S251 s) |
| 5785 |
{ |
| 5786 |
S251 a = s; |
| 5787 |
S251 b = a; // copy propagation |
| 5788 |
S251 c = b; |
| 5789 |
S251 d = c; |
| 5790 |
S251 e = d; // dead assignment |
| 5791 |
return d; |
| 5792 |
} |
| 5793 |
|
| 5794 |
void test251() |
| 5795 |
{ |
| 5796 |
S251 a; |
| 5797 |
a.a = 1; |
| 5798 |
a.b = 2; |
| 5799 |
a.c = 3; |
| 5800 |
a.d = 4; |
| 5801 |
a = foo251(a); |
| 5802 |
assert(a.a == 1); |
| 5803 |
assert(a.b == 2); |
| 5804 |
assert(a.c == 3); |
| 5805 |
assert(a.d == 4); |
| 5806 |
} |
| 5807 |
|
| 5808 |
/***************************************************/ |
| 5809 |
// https://issues.dlang.org/show_bug.cgi?id=9387 |
| 5810 |
|
| 5811 |
void bug9387a(double x) { } |
| 5812 |
|
| 5813 |
void ice9387() |
| 5814 |
{ |
| 5815 |
double x = 0.3; |
| 5816 |
double r = x*0.1; |
| 5817 |
double q = x*0.1 + r; |
| 5818 |
double p = x*0.1 + r*0.2; |
| 5819 |
if ( q ) |
| 5820 |
p = -p; |
| 5821 |
bug9387a(p); |
| 5822 |
} |
| 5823 |
|
| 5824 |
/***************************************************/ |
| 5825 |
|
| 5826 |
void bug6962(string value) |
| 5827 |
{ |
| 5828 |
string v = value; |
| 5829 |
try |
| 5830 |
{ |
| 5831 |
v = v[0LU..0LU]; |
| 5832 |
return; |
| 5833 |
} |
| 5834 |
finally |
| 5835 |
{ |
| 5836 |
assert(!v.length); |
| 5837 |
} |
| 5838 |
} |
| 5839 |
|
| 5840 |
void test6962() |
| 5841 |
{ |
| 5842 |
bug6962("42"); |
| 5843 |
} |
| 5844 |
|
| 5845 |
/***************************************************/ |
| 5846 |
|
| 5847 |
int[1] foo4414() { |
| 5848 |
return [7]; |
| 5849 |
} |
| 5850 |
|
| 5851 |
ubyte[4] bytes4414() |
| 5852 |
{ |
| 5853 |
ubyte[4] x; |
| 5854 |
x[0] = 7; |
| 5855 |
x[1] = 8; |
| 5856 |
x[2] = 9; |
| 5857 |
x[3] = 10; |
| 5858 |
return x; |
| 5859 |
} |
| 5860 |
|
| 5861 |
void test4414() { |
| 5862 |
{ |
| 5863 |
int x = foo4414()[0]; |
| 5864 |
assert(x == 7); |
| 5865 |
} |
| 5866 |
{ |
| 5867 |
auto u = bytes4414(); |
| 5868 |
auto x = u[0..4]; |
| 5869 |
if (x[0] != 7 || x[1] != 8 || x[2] != 9 || x[3] != 10) |
| 5870 |
assert(0); |
| 5871 |
} |
| 5872 |
assert(bytes4414()[0] == 7); |
| 5873 |
assert(bytes4414()[1] == 8); |
| 5874 |
assert(bytes4414()[2] == 9); |
| 5875 |
assert(bytes4414()[3] == 10); |
| 5876 |
} |
| 5877 |
|
| 5878 |
/***************************************************/ |
| 5879 |
|
| 5880 |
void test9844() { |
| 5881 |
int a = -1; |
| 5882 |
long b = -1; |
| 5883 |
assert(a == -1); |
| 5884 |
assert(b == -1L); |
| 5885 |
} |
| 5886 |
|
| 5887 |
/***************************************************/ |
| 5888 |
// https://issues.dlang.org/show_bug.cgi?id=10628 |
| 5889 |
|
| 5890 |
abstract class B10628 |
| 5891 |
{ |
| 5892 |
static if (! __traits(isVirtualMethod, foo)) |
| 5893 |
{ |
| 5894 |
} |
| 5895 |
|
| 5896 |
private bool _bar; |
| 5897 |
public void foo(); |
| 5898 |
} |
| 5899 |
|
| 5900 |
class D10628 : B10628 |
| 5901 |
{ |
| 5902 |
public override void foo() {} |
| 5903 |
} |
| 5904 |
|
| 5905 |
void test10628() |
| 5906 |
{ |
| 5907 |
assert(typeid(D10628).vtbl.length - typeid(Object).vtbl.length == 1); |
| 5908 |
} |
| 5909 |
|
| 5910 |
/***************************************************/ |
| 5911 |
// https://issues.dlang.org/show_bug.cgi?id=11265 |
| 5912 |
|
| 5913 |
struct S11265 |
| 5914 |
{ |
| 5915 |
class InnerClass |
| 5916 |
{ |
| 5917 |
S11265 s; |
| 5918 |
|
| 5919 |
bool empty() |
| 5920 |
{ |
| 5921 |
return true; |
| 5922 |
} |
| 5923 |
} |
| 5924 |
} |
| 5925 |
|
| 5926 |
void test11265() |
| 5927 |
{ |
| 5928 |
S11265.InnerClass trav = new S11265.InnerClass(); |
| 5929 |
trav.empty(); |
| 5930 |
} |
| 5931 |
|
| 5932 |
/***************************************************/ |
| 5933 |
|
| 5934 |
struct TimeOfDay |
| 5935 |
{ |
| 5936 |
void roll(int value) |
| 5937 |
{ |
| 5938 |
value %= 60; |
| 5939 |
auto newVal = _seconds + value; |
| 5940 |
|
| 5941 |
if(newVal < 0) |
| 5942 |
newVal += 60; |
| 5943 |
else if(newVal >= 60) |
| 5944 |
newVal -= 60; |
| 5945 |
|
| 5946 |
_seconds = cast(ubyte)newVal; |
| 5947 |
} |
| 5948 |
|
| 5949 |
ubyte _seconds; |
| 5950 |
} |
| 5951 |
|
| 5952 |
|
| 5953 |
void test10633() |
| 5954 |
{ |
| 5955 |
TimeOfDay tod = TimeOfDay(0); |
| 5956 |
tod.roll(-1); |
| 5957 |
assert(tod._seconds == 59); |
| 5958 |
} |
| 5959 |
|
| 5960 |
/***************************************************/ |
| 5961 |
|
| 5962 |
void _assertEq (ubyte lhs, short rhs, string msg, string file, size_t line) |
| 5963 |
{ |
| 5964 |
immutable result = lhs == rhs; |
| 5965 |
|
| 5966 |
if(!result) |
| 5967 |
{ |
| 5968 |
string op = "=="; |
| 5969 |
if(msg.length > 0) |
| 5970 |
printf("_assertEq failed: [%u] is not [%d].\n", lhs, rhs); |
| 5971 |
else |
| 5972 |
printf("_assertEq failed: [%u] is not [%d]: %.*s\n", lhs, rhs, cast(int)msg.length, msg.ptr); |
| 5973 |
} |
| 5974 |
|
| 5975 |
assert(result); |
| 5976 |
} |
| 5977 |
|
| 5978 |
struct Date |
| 5979 |
{ |
| 5980 |
short year; |
| 5981 |
ubyte month; |
| 5982 |
ubyte day; |
| 5983 |
} |
| 5984 |
|
| 5985 |
struct MonthDay |
| 5986 |
{ |
| 5987 |
ubyte month; |
| 5988 |
short day; |
| 5989 |
} |
| 5990 |
|
| 5991 |
void test10642() |
| 5992 |
{ |
| 5993 |
static void test(Date date, int day, MonthDay expected, size_t line = __LINE__) |
| 5994 |
{ |
| 5995 |
_assertEq(date.day, expected.day, "", __FILE__, line); |
| 5996 |
} |
| 5997 |
|
| 5998 |
test(Date(1999, 1, 1), 1, MonthDay(1,1)); |
| 5999 |
} |
| 6000 |
|
| 6001 |
/***************************************************/ |
| 6002 |
// https://issues.dlang.org/show_bug.cgi?id=11581 |
| 6003 |
|
| 6004 |
alias TT11581(T...) = T; |
| 6005 |
|
| 6006 |
void test11581() |
| 6007 |
{ |
| 6008 |
static class A {} |
| 6009 |
|
| 6010 |
static class C { alias Types = TT11581!(4, int); } |
| 6011 |
static C makeC() { return null; } |
| 6012 |
|
| 6013 |
alias T = TT11581!(A); |
| 6014 |
|
| 6015 |
// edim == IntergerExp(0) |
| 6016 |
auto a1 = new T[0]; |
| 6017 |
static assert(is(typeof(a1) == A)); |
| 6018 |
|
| 6019 |
enum d2 = 0; |
| 6020 |
|
| 6021 |
// edim == TypeIdentifier('d2') --> IdentifierExp |
| 6022 |
auto a2 = new T[d2]; |
| 6023 |
static assert(is(typeof(a2) == A)); |
| 6024 |
|
| 6025 |
alias U = int; |
| 6026 |
int d3 = 3; |
| 6027 |
|
| 6028 |
// edim == TypeIdentifier('d3') --> IdentifierExp |
| 6029 |
auto a3 = new U[d3]; |
| 6030 |
static assert(is(typeof(a3) == U[])); |
| 6031 |
assert(a3.length == d3); |
| 6032 |
|
| 6033 |
// edim == IndexExp(DotIdExp(CallExp(makeC, []), 'Types'), 0) |
| 6034 |
auto a4 = new U[makeC().Types[0]]; |
| 6035 |
static assert(is(typeof(a4) == U[])); |
| 6036 |
assert(a4.length == C.Types[0]); |
| 6037 |
} |
| 6038 |
|
| 6039 |
/***************************************************/ |
| 6040 |
// https://issues.dlang.org/show_bug.cgi?id=7436 |
| 6041 |
|
| 6042 |
void test7436() |
| 6043 |
{ |
| 6044 |
ubyte a = 10; |
| 6045 |
float f = 6; |
| 6046 |
ubyte b = a += f; |
| 6047 |
assert(b == 16); |
| 6048 |
} |
| 6049 |
|
| 6050 |
/***************************************************/ |
| 6051 |
// https://issues.dlang.org/show_bug.cgi?id=12138 |
| 6052 |
|
| 6053 |
struct S12138 |
| 6054 |
{ |
| 6055 |
int num; |
| 6056 |
this(int n) { num = n; } |
| 6057 |
~this() { num = 0; } |
| 6058 |
} |
| 6059 |
|
| 6060 |
void test12138() |
| 6061 |
{ |
| 6062 |
label: |
| 6063 |
auto s = S12138(10); |
| 6064 |
assert(s.num == 10); |
| 6065 |
} |
| 6066 |
|
| 6067 |
/***************************************************/ |
| 6068 |
// https://issues.dlang.org/show_bug.cgi?id=14430 |
| 6069 |
|
| 6070 |
void setCookie(long x = 1L << 32L, string y = null){ |
| 6071 |
assert(y.ptr is null); |
| 6072 |
} |
| 6073 |
|
| 6074 |
void test14430(){ |
| 6075 |
setCookie(); |
| 6076 |
} |
| 6077 |
|
| 6078 |
/***************************************************/ |
| 6079 |
// https://issues.dlang.org/show_bug.cgi?id=14510 |
| 6080 |
|
| 6081 |
alias Vector14510 = ulong[3]; |
| 6082 |
|
| 6083 |
void fun14510(Vector14510 vec, bool recursive = false) |
| 6084 |
{ |
| 6085 |
assert(vec[2] == 0); |
| 6086 |
if (recursive) |
| 6087 |
return; |
| 6088 |
fun14510(vec, true); |
| 6089 |
} |
| 6090 |
|
| 6091 |
void test14510() |
| 6092 |
{ |
| 6093 |
Vector14510 vec; |
| 6094 |
fun14510(vec); |
| 6095 |
} |
| 6096 |
|
| 6097 |
/***************************************************/ |
| 6098 |
// https://issues.dlang.org/show_bug.cgi?id=16027 |
| 6099 |
|
| 6100 |
void test16027() |
| 6101 |
{ |
| 6102 |
double value = 1.0; |
| 6103 |
value *= -1.0; |
| 6104 |
assert(value == -1.0); // fails, value is +1.0 |
| 6105 |
|
| 6106 |
value = 1.0; |
| 6107 |
value = value * -1.0; |
| 6108 |
assert(value == -1.0); |
| 6109 |
} |
| 6110 |
|
| 6111 |
/***************************************************/ |
| 6112 |
// https://issues.dlang.org/show_bug.cgi?id=16530 |
| 6113 |
|
| 6114 |
double entropy2(double[] probs) |
| 6115 |
{ |
| 6116 |
double result = 0; |
| 6117 |
foreach (p; probs) |
| 6118 |
{ |
| 6119 |
__gshared int x; |
| 6120 |
++x; |
| 6121 |
if (!p) continue; |
| 6122 |
import core.stdc.math : log2; |
| 6123 |
result -= p * log2(p); |
| 6124 |
} |
| 6125 |
return result; |
| 6126 |
} |
| 6127 |
|
| 6128 |
void test16530() |
| 6129 |
{ |
| 6130 |
if (entropy2([1.0, 0, 0]) != 0.0) |
| 6131 |
assert(0); |
| 6132 |
} |
| 6133 |
|
| 6134 |
/***************************************************/ |
| 6135 |
|
| 6136 |
void test252() |
| 6137 |
{ |
| 6138 |
__gshared int x = 7; |
| 6139 |
__gshared long y = 217; |
| 6140 |
if ((-1 - x) != ~x) |
| 6141 |
assert(0); |
| 6142 |
if ((-1 - y) != ~y) |
| 6143 |
assert(0); |
| 6144 |
} |
| 6145 |
|
| 6146 |
/***************************************************/ |
| 6147 |
// https://issues.dlang.org/show_bug.cgi?id=7997 |
| 6148 |
|
| 6149 |
void test7997() |
| 6150 |
{ |
| 6151 |
__gshared int[0] foos; |
| 6152 |
foreach (f; foos) {} |
| 6153 |
} |
| 6154 |
|
| 6155 |
/***************************************************/ |
| 6156 |
// https://issues.dlang.org/show_bug.cgi?id=5332 |
| 6157 |
|
| 6158 |
int[0] arr5332; |
| 6159 |
|
| 6160 |
void test5332() |
| 6161 |
{ |
| 6162 |
auto a = arr5332; |
| 6163 |
} |
| 6164 |
|
| 6165 |
/***************************************************/ |
| 6166 |
// https://issues.dlang.org/show_bug.cgi?id=11742 |
| 6167 |
|
| 6168 |
const int x11472 = void; |
| 6169 |
|
| 6170 |
shared static this() { x11472 = 10; } |
| 6171 |
|
| 6172 |
void test11472() |
| 6173 |
{ |
| 6174 |
assert(x11472 == 10); |
| 6175 |
} |
| 6176 |
|
| 6177 |
|
| 6178 |
/***************************************************/ |
| 6179 |
|
| 6180 |
int main() |
| 6181 |
{ |
| 6182 |
checkAlign(); |
| 6183 |
test1(); |
| 6184 |
test2(); |
| 6185 |
test3(); |
| 6186 |
test4(); |
| 6187 |
test5(); |
| 6188 |
test6(); |
| 6189 |
test7(); |
| 6190 |
test8(); |
| 6191 |
test9(); |
| 6192 |
test10(); |
| 6193 |
test11(); |
| 6194 |
test12(); |
| 6195 |
test13(); |
| 6196 |
test14(); |
| 6197 |
test15(); |
| 6198 |
test16(); |
| 6199 |
test17(); |
| 6200 |
test18(); |
| 6201 |
test19(); |
| 6202 |
test20(); |
| 6203 |
test21(); |
| 6204 |
test22(); |
| 6205 |
test23(); |
| 6206 |
test24(); |
| 6207 |
test25(); |
| 6208 |
test27(); |
| 6209 |
test28(); |
| 6210 |
test29(); |
| 6211 |
test31(); |
| 6212 |
test32(); |
| 6213 |
test33(); |
| 6214 |
test34(); |
| 6215 |
test35(); |
| 6216 |
test36(); |
| 6217 |
test37(); |
| 6218 |
test38(); |
| 6219 |
test39(); |
| 6220 |
test40(); |
| 6221 |
test41(); |
| 6222 |
test42(); |
| 6223 |
test43(); |
| 6224 |
test45(); |
| 6225 |
test46(); |
| 6226 |
test47(); |
| 6227 |
test48(); |
| 6228 |
test49(); |
| 6229 |
test50(); |
| 6230 |
test51(); |
| 6231 |
test52(); |
| 6232 |
test53(); |
| 6233 |
test54(); |
| 6234 |
test55(); |
| 6235 |
test56(); |
| 6236 |
test57(); |
| 6237 |
test58(); |
| 6238 |
test59(); |
| 6239 |
test60(); |
| 6240 |
test61(); |
| 6241 |
test62(); |
| 6242 |
test63(); |
| 6243 |
test64(); |
| 6244 |
test65(); |
| 6245 |
test66(); |
| 6246 |
test67(); |
| 6247 |
test68(); |
| 6248 |
test69(); |
| 6249 |
test70(); |
| 6250 |
test71(); |
| 6251 |
test72(); |
| 6252 |
test73(); |
| 6253 |
test74(); |
| 6254 |
test75(); |
| 6255 |
test76(); |
| 6256 |
test77(); |
| 6257 |
test78(); |
| 6258 |
test79(); |
| 6259 |
test80(); |
| 6260 |
test81(); |
| 6261 |
test82(); |
| 6262 |
test83(); |
| 6263 |
test84(); |
| 6264 |
test85(); |
| 6265 |
test86(); |
| 6266 |
test87(); |
| 6267 |
test88(); |
| 6268 |
test89(); |
| 6269 |
test90(); |
| 6270 |
test91(); |
| 6271 |
test92(); |
| 6272 |
test93(); |
| 6273 |
test94(); |
| 6274 |
test95(); |
| 6275 |
test96(); |
| 6276 |
test97(); |
| 6277 |
test98(); |
| 6278 |
test99(); |
| 6279 |
test100(); |
| 6280 |
test101(); |
| 6281 |
test103(); |
| 6282 |
test104(); |
| 6283 |
test105(); |
| 6284 |
test107(); |
| 6285 |
test108(); |
| 6286 |
test109(); |
| 6287 |
test110(); |
| 6288 |
test111(); |
| 6289 |
test112(); |
| 6290 |
test113(); |
| 6291 |
test114(); |
| 6292 |
test115(); |
| 6293 |
test116(); |
| 6294 |
test117(); |
| 6295 |
test118(); |
| 6296 |
test119(); |
| 6297 |
test120(); |
| 6298 |
test121(); |
| 6299 |
//test122(); |
| 6300 |
test123(); |
| 6301 |
test124(); |
| 6302 |
test125(); |
| 6303 |
test126(); |
| 6304 |
test127(); |
| 6305 |
test128(); |
| 6306 |
test129(); |
| 6307 |
test130(); |
| 6308 |
test131(); |
| 6309 |
test132(); |
| 6310 |
test133(); |
| 6311 |
|
| 6312 |
// test135(); |
| 6313 |
test136(); |
| 6314 |
test137(); |
| 6315 |
|
| 6316 |
test139(); |
| 6317 |
test140(); |
| 6318 |
|
| 6319 |
test142(); |
| 6320 |
test143(); |
| 6321 |
test144(); |
| 6322 |
test145(); |
| 6323 |
test146(); |
| 6324 |
test147(); |
| 6325 |
test148(); |
| 6326 |
test149(); |
| 6327 |
|
| 6328 |
test151(); |
| 6329 |
test152(); |
| 6330 |
test153(); |
| 6331 |
test154(); |
| 6332 |
|
| 6333 |
test156(); |
| 6334 |
test157(); |
| 6335 |
|
| 6336 |
test160(); |
| 6337 |
|
| 6338 |
test163(); |
| 6339 |
|
| 6340 |
|
| 6341 |
test169(); |
| 6342 |
|
| 6343 |
test171(); |
| 6344 |
|
| 6345 |
test173(); |
| 6346 |
test174(); |
| 6347 |
|
| 6348 |
test176(); |
| 6349 |
test177(); |
| 6350 |
|
| 6351 |
test179(); |
| 6352 |
|
| 6353 |
test181(); |
| 6354 |
test182(); |
| 6355 |
|
| 6356 |
test188(); |
| 6357 |
test189(); |
| 6358 |
test190(); |
| 6359 |
test191(); |
| 6360 |
|
| 6361 |
test193(); |
| 6362 |
test194(); |
| 6363 |
|
| 6364 |
test198(); |
| 6365 |
|
| 6366 |
test200(); |
| 6367 |
test201(); |
| 6368 |
test202(); |
| 6369 |
test203(); |
| 6370 |
|
| 6371 |
// test208(); |
| 6372 |
|
| 6373 |
test210(); |
| 6374 |
|
| 6375 |
test212(); |
| 6376 |
test213(); |
| 6377 |
test214(); |
| 6378 |
test215(); |
| 6379 |
test216(); |
| 6380 |
test217(); |
| 6381 |
test218(); |
| 6382 |
test219(); |
| 6383 |
test220(); |
| 6384 |
|
| 6385 |
test222(); |
| 6386 |
test223(); |
| 6387 |
test224(); |
| 6388 |
test225(); |
| 6389 |
test226(); |
| 6390 |
test227(); |
| 6391 |
test228(); |
| 6392 |
test229(); |
| 6393 |
test230(); |
| 6394 |
test230(); |
| 6395 |
bug5717(); |
| 6396 |
test231(); |
| 6397 |
test232(); |
| 6398 |
test233(); |
| 6399 |
bug6184(); |
| 6400 |
test236(); |
| 6401 |
test237(); |
| 6402 |
test238(); |
| 6403 |
test239(); |
| 6404 |
test6229(); |
| 6405 |
test6270(); |
| 6406 |
test6506(); |
| 6407 |
test240(); |
| 6408 |
test6563(); |
| 6409 |
test241(); |
| 6410 |
test6665(); |
| 6411 |
test5364(); |
| 6412 |
test6189(); |
| 6413 |
test6997(); |
| 6414 |
test7026(); |
| 6415 |
test6354(); |
| 6416 |
test7072(); |
| 6417 |
test7212(); |
| 6418 |
test242(); |
| 6419 |
test7290(); |
| 6420 |
test7367(); |
| 6421 |
test7375(); |
| 6422 |
test6504(); |
| 6423 |
test7422(); |
| 6424 |
test7424(); |
| 6425 |
test7502(); |
| 6426 |
test4820(); |
| 6427 |
test4820_2(); |
| 6428 |
test243(); |
| 6429 |
test7742(); |
| 6430 |
test245(); |
| 6431 |
test7807(); |
| 6432 |
test4155(); |
| 6433 |
test7911(); |
| 6434 |
test8095(); |
| 6435 |
test8091(); |
| 6436 |
test6189_2(); |
| 6437 |
test8199(); |
| 6438 |
test246(); |
| 6439 |
test8423(); |
| 6440 |
test8496(); |
| 6441 |
test8840(); |
| 6442 |
test8889(); |
| 6443 |
test8870(); |
| 6444 |
test9781(); |
| 6445 |
test247(); |
| 6446 |
test8340(); |
| 6447 |
test8376(); |
| 6448 |
test8796(); |
| 6449 |
test9171(); |
| 6450 |
test9248(); |
| 6451 |
test14682a(); |
| 6452 |
test14682b(); |
| 6453 |
test9739(); |
| 6454 |
testdbl_to_ulong(); |
| 6455 |
testdbl_to_uint(); |
| 6456 |
testreal_to_ulong(); |
| 6457 |
test248(); |
| 6458 |
test249(); |
| 6459 |
test250(); |
| 6460 |
test6057(); |
| 6461 |
test251(); |
| 6462 |
test6962(); |
| 6463 |
test4414(); |
| 6464 |
test9844(); |
| 6465 |
test10628(); |
| 6466 |
test11265(); |
| 6467 |
test10633(); |
| 6468 |
test10642(); |
| 6469 |
test11581(); |
| 6470 |
test7436(); |
| 6471 |
test12138(); |
| 6472 |
test14430(); |
| 6473 |
test14510(); |
| 6474 |
test16027(); |
| 6475 |
test16530(); |
| 6476 |
test252(); |
| 6477 |
test7997(); |
| 6478 |
test5332(); |
| 6479 |
test11472(); |
| 6480 |
test13285(); |
| 6481 |
|
| 6482 |
printf("Success\n"); |
| 6483 |
return 0; |
| 6484 |
} |