aboutsummaryrefslogtreecommitdiff
path: root/libphobos/testsuite/libphobos.phobos/std_package.d
blob: 46a4f866484cda49db46bafb05358ae9b76b254f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@safe unittest
{
    import std;

    import std;

    int len;
    const r = 6.iota
              .filter!(a => a % 2) // 1 3 5
              .map!(a => a * 2) // 2 6 10
              .tee!(_ => len++)
              .substitute(6, -6) // 2 -6 10
              .sum
              .reverseArgs!format("Sum: %d");

    assert(len == 3);
    assert(r == "Sum: 6");
}

@safe unittest
{
    import std;

    import std;
    assert(10.iota.map!(a => pow(2, a)).sum == 1023);
}