4 runnable/test8.d(261): Deprecation: identity comparison of static arrays implicitly coerces them to slices, which are compared by reference
14 int atoi(const char*);
15 int printf(const char*, ...);
16 size_t
strlen(const char*);
19 int _snprintf(char*, size_t
, const char*, ...);
20 alias _snprintf snprintf
;
23 int snprintf(char*, size_t
, const char*, ...);
26 /***********************************/
43 /***********************************/
61 /***********************************/
65 static int bar() { return 3; }
73 assert(Foo3
.bar() == 3);
77 /***********************************/
81 static int bar() { return 3; }
89 assert(Foo4
.bar() == 3);
94 /***********************************/
98 int bar() { return y
+ 3; }
106 assert(f
.bar() == 7);
109 /***********************************/
113 int bar() { return y
+ 3; }
114 final int abc() { return y
+ 8; }
120 override int bar() { return y
+ 5; }
125 Foo6 f
= new FooX6();
127 assert(f
.bar() == 9);
128 assert(f
.abc() == 12);
132 /***********************************/
134 void bar7(char[3] cad
)
136 assert(cad
.length
== 3);
137 printf("cad[0] = %d\n", cad
[0]);
138 assert(cad
[0] == 0xFF);
140 assert(cad
[2] == 0xFF);
152 /***********************************/
158 assert(cad
[0] == 0xFF);
160 assert(cad
[2] == 0xFF);
174 /***********************************/
203 Foo11 f
= new Foo11();
209 /***********************************/
213 protected void foo() { }
218 override void foo() { super.foo(); }
225 /***********************************/
229 const HWND hWnd
= cast(HWND
)(null);
235 /***********************************/
254 /***********************************/
264 /***********************************/
268 static int function() fp
= &func16
;
279 /***********************************/
281 string
returnSameString(string inputstr
)
288 return returnSameString("First string" ~ "Concatenated with second");
291 string
butThisWorks()
293 string s
= "Third string";
294 s
= s
~ "Concatenated with fourth";
295 return returnSameString(s
);
303 printf("passString() = %.*s\n", cast(int)s
.length
, s
.ptr
);
304 assert(s
== "First stringConcatenated with second");
307 printf("butThisWorks() = %.*s\n", cast(int)s
.length
, s
.ptr
);
308 assert(s
== "Third stringConcatenated with fourth");
311 /***********************************/
321 int foo(B20 j
) { return j
.b
; }
330 int bar(A20 j
) { return j
.a
; }
337 /***********************************/
348 /***********************************/
366 //printf("left = %d\n", pos.theRect.left);
367 assert(pos
.theRect
.left
== 1);
368 assert(pos
.theRect
.top
== 2);
369 assert(pos
.theRect
.right
== 3);
370 assert(pos
.theRect
.bottom
== 4);
385 Window w
= new Window();
389 /***********************************/
404 printf("Inside: %d,%d\n",foo
.width
,foo
.height
);
415 printf("Outside: %d,%d\n",bar
.width
,bar
.height
);
416 assert(bar
.width
== 12);
417 assert(bar
.height
== 34);
420 /***********************************/
431 /***********************************/
450 /***********************************/
494 /***********************************/
496 const char[1] sep
= '/';
498 string
testx28(string s
, string t
)
500 return cast(string
)(s
~ sep
~ t
);
507 r
= testx28("ab", "cd");
508 assert(r
== "ab/cd");
511 /***********************************/
518 /***********************************/
520 bool func30(int x
, int y
)
537 /***********************************/
547 /***********************************/
554 foo
= new string
[45];
555 for (i
= 0; i
< 45; i
++)
557 for (i
= 0; i
< 45; i
++)
558 assert(foo
[i
] == "hello");
562 /***********************************/
570 for (i
= 0; i
< 45; i
++)
572 for (i
= 0; i
< 45; i
++)
573 assert(foo
[i
] == "hello");
577 /***********************************/
585 for (i
= 0; i
< 4; i
++)
586 for (j
= 0; j
< 3; j
++)
587 assert(a
[i
][j
] == 0);
589 for (i
= 0; i
< 6; i
++)
590 for (j
= 0; j
< 5; j
++)
591 assert(b
[i
][j
] == 16);
594 /***********************************/
595 // https://issues.dlang.org/show_bug.cgi?id=19178
597 float[3][4] arr2f
= 10;
598 Int3_4
[1] arr3i
= 20;
599 short[3][4][1][1] arr4s
= 30;
605 enum Int3_4
: Int3
[4] {
611 int[3][3] arr
= [2, 1];
616 for (int i
= 0; i
< 4; i
++)
618 for (int j
= 0; j
< 3; j
++)
620 // printf("[%d %d]: %f %d %d\n", i, j, arr2f[i][j], arr3i[0][i][j], arr4s[0][0][i][j]);
621 assert(arr2f
[i
][j
] == 10);
622 assert(arr3i
[0][i
][j
] == 20);
623 assert(arr4s
[0][0][i
][j
] == 30);
628 assert(t
.arr
[0] == [2, 2, 2]);
629 assert(t
.arr
[1] == [1, 1, 1]);
630 assert(t
.arr
[2] == [0, 0, 0]);
632 /***********************************/
637 snprintf(buffer
.ptr
, 32, "%d", i
);
638 return buffer
[0 .. strlen(buffer
.ptr
)].idup
;
641 string
testa36(int i
, int j
, string a
, string b
, string c
)
643 string s
= "string 0;" ~ itoa(i
) ~
644 "string 1;" ~ itoa(j
) ~
645 "string 2;" ~ itoa(i
) ~
648 // string s = a ~ b ~ c;
654 string s
= testa36(26, 47, "a", "b", "c");
656 printf("s = '%.*s'\n", cast(int)s
.length
, s
.ptr
);
657 assert(s
== "string 0;26string 1;47string 2;26string 3;");
660 /***********************************/
665 ulong v1
= 297321415603;
666 ulong v2
= 331681153971;
668 printf( "%llx %llx\n", v1
, v2
);
673 /***********************************/
678 static char[8192 + 1] flags
;
688 for (i
= 2; i
<= 8192; i
++)
689 flags
[cast(size_t
)i
] = 1;
691 for (i
= 2; i
<= 8192; i
++)
693 if (flags
[cast(size_t
)i
])
695 for (k
= i
+i
; k
<= 8192; k
+= i
)
696 flags
[cast(size_t
)k
] = 0;
703 printf("Count: %d\n", count
);
704 assert(count
== 1028);
708 printf("Exception: %lld\n", k
);
714 /***********************************/
729 printf("%p %d\n", c
, c
.x
);
731 printf("%p\n", cast(I39
) c
);
732 c
= cast(C39
) cast(I39
) c
;
738 /***********************************/
749 /***********************************/
751 int foo42(const(char) *x
, ...)
755 va_start
!(typeof(x
))(ap
, x
);
756 assert(ap
!= va_list
.init
);
759 i
= va_arg
!(typeof(i
))(ap
);
763 l
= va_arg
!(typeof(l
))(ap
);
767 k
= va_arg
!(typeof(k
))(ap
);
772 return cast(int)(i
+ l
+ k
);
779 j
= foo42("hello", 3, 23L, 4);
780 printf("j = %d\n", j
);
784 /***********************************/
789 this() scope { printf("A44 ctor\n"); x44
+= 1; }
790 ~this() scope { printf("A44 dtor\n"); x44
+= 0x100; }
794 void foo44() { scope B44 b
= new B44
; }
798 printf("foo44...\n");
800 printf("...foo44\n");
801 assert(x44
== 0x101);
804 /***********************************/
810 int unFormat( bool delegate( out dchar ) getc,
811 bool delegate( dchar ) ungetc,
812 TypeInfo[] arguments,
818 if( arguments[arg] is typeid( string ) )
819 fmt = toUTF32( va_arg!(string)( argptr ) );
820 else if( arguments[arg] is typeid( wchar[] ) )
821 fmt = toUTF32( va_arg!(wchar[])( argptr ) );
822 else if( arguments[arg] is typeid( dchar[] ) )
823 fmt = va_arg!(dchar[])( argptr );
833 /***********************************/
837 va_arg
!(string
)( _argptr
);
844 printf( "hello world\n" );
847 /***********************************/
857 /***********************************/
863 debug{printf("test");}
866 /***********************************/
876 /***********************************/