ditto
1 debug scope(failure) writefln("Unittest Failure :%s(%s) ", __FILE__, __LINE__); 2 debug scope(success) {writefln("Unittest Success :%s(%s)", __FILE__, __LINE__); stdout.flush();} 3 4 auto r1 = [1, 3, 2, 4, 0, 0]; 5 auto s = "abc".dup; 6 auto tm1 = tmap!("a", "b", (a, b) => b.repeat(a).array().idup)(r1, s); 7 assert(equal(tm1, [tuple(1, 'a', "a"d), 8 tuple(3, 'b', "bbb"d), 9 tuple(2, 'c', "cc"d)])); 10 11 assert(tmap!"a"(r1, s, "").empty); 12 13 auto r3 = [1, 2, 3]; 14 //first element of [0] expresses r3 is used as range, but second element expresses "abcd" is not used as range. 15 auto ss = tmap!("b[a]", [0])(r3, "abcd"); 16 assert(equal(ss, ['b', 'c', 'd'][])); 17 assert(ss.length == 3); 18 assert(equal(ss, ss.save)); 19 20 static assert(isForwardRange!(typeof(ss))); 21 static assert(!isBidirectionalRange!(typeof(ss))); 22 static assert(!isRandomAccessRange!(typeof(ss))); 23 24 auto ss_b = ss.asBidirectional; 25 static assert(isBidirectionalRange!(typeof(ss_b))); 26 static assert(isRandomAccessRange!(typeof(ss_b))); 27 assert(equal(ss_b.retro, ['d', 'c', 'b'])); 28 29 ///multi function and range-choose test 30 auto tm5 = tmap!("b[a]", "b[a-1]", [0])(r3, "abcd"); 31 assert(equal(tm5, [tuple('b', 'a'), tuple('c', 'b'), tuple('d', 'c')][]));
tmap