blob: 0a230c0e74430545d8212d4cb59f8eab47b12240 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/**
* Copyright (c) David Miller. All rights reserved.
* The use and distribution terms for this software are covered by the
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
* which can be found in the file epl-v10.html at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using clojure.lang;
using RMExpect = Rhino.Mocks.Expect;
namespace Clojure.Tests.LibTests
{
[TestFixture]
public class LazyConsTests : AssertionHelper
{
#region C-tor tests
// Couldn't think of anything except to make sure it doesn't throw an exception.
[Test]
public void CtorWorks()
{
LazyCons lc = new LazyCons(null);
Expect(lc, Not.Null);
}
#endregion
}
[TestFixture]
public class LazyCons_ISeq_Tests : ISeqTestHelper
{
MockRepository _mocks ;
IFn _fn;
LazyCons _lc;
object[] _values;
[SetUp]
public void Setup()
{
_mocks = new MockRepository();
_fn = _mocks.StrictMock<IFn>();
RMExpect.Call(_fn.invoke()).Return(10);
RMExpect.Call(_fn.invoke(null)).Return(new Cons(20,null));
_lc = new LazyCons(_fn);
_values = new object[] { 10, 20 };
_mocks.ReplayAll();
}
[TearDown]
public void Teardown()
{
_mocks.VerifyAll();
}
[Test]
public void ISeq_has_proper_values()
{
VerifyISeqContents(_lc, _values);
}
[Test]
public void First_caches()
{
_lc.first();
_lc.first();
// Need to meet expectation that _rest is called.
_lc.rest();
}
[Test]
public void Rest_calcs_first()
{
_lc.rest();
}
[Test]
public void Rest_caches()
{
_lc.rest();
_lc.rest();
}
}
[TestFixture]
public class LazyCons_IObj_Tests : IObjTests
{
[SetUp]
public void Setup()
{
MockRepository mocks = new MockRepository();
IPersistentMap meta = mocks.StrictMock<IPersistentMap>();
IFn fn = mocks.StrictMock<IFn>();
RMExpect.Call(fn.invoke()).Return(10);
RMExpect.Call(fn.invoke(null)).Return(null);
mocks.ReplayAll();
_objWithNullMeta = new LazyCons(fn);
_obj = _objWithNullMeta.withMeta(meta);
_expectedType = typeof(LazyCons);
mocks.VerifyAll();
}
}
}
|