Sha256: 1fd9d2d3a6099e7c4c6aeac884de9114a53eccb273e455eab70d692fcb151d34

Contents?: true

Size: 1.78 KB

Versions: 396

Compression:

Stored size: 1.78 KB

Contents

Imports NUnit.Framework

<TestFixture>
Public Class AccumulateTest
    <Test>
    Public Sub EmptyAccumulationProducesEmptyAccumulation()
        Assert.That(New Integer() {}.Accumulate(Function(x) x * x), [Is].EqualTo(New Integer() {}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateSquares()
        Assert.That({1, 2, 3}.Accumulate(Function(x) x * x), [Is].EqualTo({1, 4, 9}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateUpcases()
        Assert.That(New List(Of String)() From {
            "hello",
            "world"
        }.Accumulate(Function(x) x.ToUpper()), [Is].EqualTo(New List(Of String) From {
            "HELLO",
            "WORLD"
        }))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateReversedStrings()
        Assert.That("the quick brown fox etc".Split(" "c).Accumulate(AddressOf Reverse), [Is].EqualTo("eht kciuq nworb xof cte".Split(" "c)))
    End Sub

    Private Shared Function Reverse(value As String) As String
        Dim chars = value.ToCharArray()
        Array.Reverse(chars)
        Return New String(chars)
    End Function

    <Ignore>
    <Test>
    Public Sub AccumulateWithinAccumulate()
        Dim actual = New String() {"a", "b", "c"}.Accumulate(Function(c) String.Join(" ", New String() {"1", "2", "3"}.Accumulate(Function(d) c & d)))
        Assert.That(actual, [Is].EqualTo(New String() {"a1 a2 a3", "b1 b2 b3", "c1 c2 c3"}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateIsLazy()
        Dim counter = 0
        Dim accumulation = New Integer() {1, 2, 3}.Accumulate(Function(x) x * System.Math.Max(System.Threading.Interlocked.Increment(counter), counter - 1))

        Assert.That(counter, [Is].EqualTo(0))
        accumulation.ToList()
        Assert.That(counter, [Is].EqualTo(3))
    End Sub
End Class

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.179 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.178 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.177 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.176 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.175 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.174 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.173 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.172 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.171 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.170 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.169 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.167 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.166 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.165 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.164 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.163 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.162 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.161 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.160 tracks/vbnet/exercises/accumulate/AccumulateTest.vb