9 int printf(const char*, ...);
10 size_t strlen(const char*);
13 int _snprintf(char*, size_t, const char*, ...);
14 alias _snprintf snprintf;
17 int snprintf(char*, size_t, const char*, ...);
20 /***********************************/
37 /***********************************/
55 /***********************************/
59 static int bar() { return 3; }
67 assert(Foo3.bar() == 3);
71 /***********************************/
75 static int bar() { return 3; }
83 assert(Foo4.bar() == 3);
88 /***********************************/
92 int bar() { return y + 3; }
100 assert(f.bar() == 7);
103 /***********************************/
107 int bar() { return y + 3; }
108 final int abc() { return y + 8; }
114 override int bar() { return y + 5; }
119 Foo6 f = new FooX6();
121 assert(f.bar() == 9);
122 assert(f.abc() == 12);
126 /***********************************/
128 void bar7(char[3] cad)
130 assert(cad.length == 3);
131 printf("cad[0] = %d\n", cad[0]);
132 assert(cad[0] == 0xFF);
134 assert(cad[2] == 0xFF);
146 /***********************************/
152 assert(cad[0] == 0xFF);
154 assert(cad[2] == 0xFF);
168 /***********************************/
173 //printf ("test of imag*imag = %Lf\n",imag*imag);
174 real f = imag * imag;
178 /***********************************/
185 printf ("e = %Lf\n", e);
190 /***********************************/
219 Foo11 f = new Foo11();
225 /***********************************/
229 protected void foo() { }
234 override void foo() { super.foo(); }
241 /***********************************/
245 const HWND hWnd = cast(HWND)(null);
251 /***********************************/
270 /***********************************/
280 /***********************************/
284 static int function() fp = &func16;
295 /***********************************/
297 string returnSameString(string inputstr)
304 return returnSameString("First string" ~ "Concatenated with second");
307 string butThisWorks()
309 string s = "Third string";
310 s = s ~ "Concatenated with fourth";
311 return returnSameString(s);
319 printf("passString() = %.*s\n", s.length, s.ptr);
320 assert(s == "First stringConcatenated with second");
323 printf("butThisWorks() = %.*s\n", s.length, s.ptr);
324 assert(s == "Third stringConcatenated with fourth");
327 /***********************************/
337 int foo(B20 j) { return j.b; }
346 int bar(A20 j) { return j.a; }
353 /***********************************/
364 /***********************************/
382 //printf("left = %d\n", pos.theRect.left);
383 assert(pos.theRect.left == 1);
384 assert(pos.theRect.top == 2);
385 assert(pos.theRect.right == 3);
386 assert(pos.theRect.bottom == 4);
401 Window w = new Window();
405 /***********************************/
420 printf("Inside: %d,%d\n",foo.width,foo.height);
431 printf("Outside: %d,%d\n",bar.width,bar.height);
432 assert(bar.width == 12);
433 assert(bar.height == 34);
436 /***********************************/
447 /***********************************/
466 /***********************************/
510 /***********************************/
512 const char[1] sep = '/';
514 string testx28(string s, string t)
516 return cast(string)(s ~ sep ~ t);
523 r = testx28("ab", "cd");
524 assert(r == "ab/cd");
527 /***********************************/
534 /***********************************/
536 bool func30(int x, int y)
553 /***********************************/
563 /***********************************/
570 foo = new string[45];
571 for (i = 0; i < 45; i++)
573 for (i = 0; i < 45; i++)
574 assert(foo[i] == "hello");
578 /***********************************/
586 for (i = 0; i < 45; i++)
588 for (i = 0; i < 45; i++)
589 assert(foo[i] == "hello");
593 /***********************************/
601 for (i = 0; i < 4; i++)
602 for (j = 0; j < 3; j++)
603 assert(a[i][j] == 0);
605 for (i = 0; i < 6; i++)
606 for (j = 0; j < 5; j++)
607 assert(b[i][j] == 16);
611 /***********************************/
615 ifloat b = cast(ifloat)1i;
625 /***********************************/
630 snprintf(buffer.ptr, 32, "%d", i);
631 return buffer[0 .. strlen(buffer.ptr)].idup;
634 string testa36(int i, int j, string a, string b, string c)
636 string s = "string 0;" ~ itoa(i) ~
637 "string 1;" ~ itoa(j) ~
638 "string 2;" ~ itoa(i) ~
641 // string s = a ~ b ~ c;
647 string s = testa36(26, 47, "a", "b", "c");
649 printf("s = '%.*s'\n", s.length, s.ptr);
650 assert(s == "string 0;26string 1;47string 2;26string 3;");
653 /***********************************/
658 ulong v1 = 297321415603;
659 ulong v2 = 331681153971;
661 printf( "%llx %llx\n", v1, v2 );
666 /***********************************/
671 static char flags[8192 + 1];
681 for (i = 2; i <= 8192; i++)
682 flags[cast(size_t)i] = 1;
684 for (i = 2; i <= 8192; i++)
686 if (flags[cast(size_t)i])
688 for (k = i+i; k <= 8192; k += i)
689 flags[cast(size_t)k] = 0;
696 printf("Count: %d\n", count);
697 assert(count == 1028);
701 printf("Exception: %d\n", k);
707 /***********************************/
722 printf("%p %d\n", c, c.x);
724 printf("%p\n", cast(I39) c);
725 c = cast(C39) cast(I39) c;
731 /***********************************/
742 /***********************************/
744 int foo42(const(char) *x, ...)
748 va_start!(typeof(x))(ap, x);
749 //printf("&x = %p, ap = %p\n", &x, ap); // XBUG: static array va_lists (eg: x86_64) cannot be passed as vararg.
752 i = va_arg!(typeof(i))(ap);
753 printf("i = %d\n", i);
756 l = va_arg!(typeof(l))(ap);
757 printf("l = %lld\n", l);
760 k = va_arg!(typeof(k))(ap);
761 printf("k = %u\n", k);
765 return cast(int)(i + l + k);
772 j = foo42("hello", 3, 23L, 4);
773 printf("j = %d\n", j);
777 /***********************************/
792 /***********************************/
797 this() { printf("A44 ctor\n"); x44 += 1; }
798 ~this() { printf("A44 dtor\n"); x44 += 0x100; }
802 void foo44() { scope B44 b = new B44; }
806 printf("foo44...\n");
808 printf("...foo44\n");
809 assert(x44 == 0x101);
812 /***********************************/
818 int unFormat( bool delegate( out dchar ) getc,
819 bool delegate( dchar ) ungetc,
820 TypeInfo[] arguments,
826 if( arguments[arg] is typeid( string ) )
827 fmt = toUTF32( va_arg!(string)( argptr ) );
828 else if( arguments[arg] is typeid( wchar[] ) )
829 fmt = toUTF32( va_arg!(wchar[])( argptr ) );
830 else if( arguments[arg] is typeid( dchar[] ) )
831 fmt = va_arg!(dchar[])( argptr );
841 /***********************************/
845 va_arg!(string)( _argptr );
852 printf( "hello world\n" );
855 /***********************************/
865 /***********************************/
871 debug{printf("test");}
874 /***********************************/
884 /***********************************/
895 cdouble a = (2-2i)*(2-2i);
902 writeln((2-2i)*(2-2i));
905 foo51((2-2i)*(2-2i));
916 assert((2-2i)*(2-2i) == -8i);
918 cdouble a = (2-2i)*(2-2i);
921 foo51((2-2i)*(2-2i));
924 /***********************************/