Differences From Artifact [3f689d3451f8c1cc]:
- File
tricks/tricks.d
- 2010-11-09 05:19:20 - part of checkin [8de5b49cdf] on branch trunk - split tricks module into a separate package. (user: kinaba) [annotate]
To Artifact [4c996bb5859ed5ea]:
- File
tricks/tricks.d
- 2010-11-09 06:02:32 - part of checkin [7de80acfb8] on branch trunk - Added ultra tenuki REPL (user: kinaba) [annotate]
17 auto writer = appender!string(); 17 auto writer = appender!string();
18 formattedWrite(writer, fmt, params); 18 formattedWrite(writer, fmt, params);
19 return writer.data; 19 return writer.data;
20 } 20 }
21 21
22 unittest 22 unittest
23 { 23 {
24 assert( sprintf!"%s == %d"("1+2", 3) == "1+2 == 3" ); <
25 assert( sprintf!"%s == %04d"("1+2", 3) == "1+2 == 0003" ); | 24 assert_eq( sprintf!"%s == %04d"("1+2", 3), "1+2 == 0003" );
> 25 assert_eq( sprintf!"%2$s == %1$s"("1+2", 5, 8), "5 == 1+2" );
> 26 assert_throw!Error( sprintf!"%s%s"(1) );
26 } 27 }
27 28
28 /// Create an exception with automatically completed filename and lineno informa 29 /// Create an exception with automatically completed filename and lineno informa
29 30
30 auto genex(ExceptionType, string fn=__FILE__, int ln=__LINE__, T...)(T params) 31 auto genex(ExceptionType, string fn=__FILE__, int ln=__LINE__, T...)(T params)
31 { 32 {
32 static if( T.length > 0 && is(T[$-1] : Throwable) ) 33 static if( T.length > 0 && is(T[$-1] : Throwable) )