OLD | NEW |
1 /** | 1 /** |
2 * Mock4JS 0.2 | 2 * Mock4JS 0.2 |
3 * http://mock4js.sourceforge.net/ | 3 * http://mock4js.sourceforge.net/ |
4 */ | 4 */ |
5 | 5 |
6 Mock4JS = { | 6 Mock4JS = { |
7 _mocksToVerify: [], | 7 _mocksToVerify: [], |
8 _convertToConstraint: function(constraintOrValue) { | 8 _convertToConstraint: function(constraintOrValue) { |
9 if(constraintOrValue.argumentMatches) { | 9 if(constraintOrValue.argumentMatches) { |
10 return constraintOrValue; // it's already an ArgumentMat
cher | 10 return constraintOrValue; // it's already an ArgumentMat
cher |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 toString: function() { | 115 toString: function() { |
116 return this.message; | 116 return this.message; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 /** | 120 /** |
121 * Assert function that makes use of the constraint methods | 121 * Assert function that makes use of the constraint methods |
122 */ | 122 */ |
123 assertThat = function(expected, argumentMatcher) { | 123 assertThat = function(expected, argumentMatcher) { |
124 if(!argumentMatcher.argumentMatches(expected)) { | 124 if(!argumentMatcher.argumentMatches(expected)) { |
125 » » fail("Expected '"+expected+"' to be "+argumentMatcher.describe()
); | 125 » » throw new Mock4JSException("Expected '"+expected+"' to be "+argu
mentMatcher.describe()); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 /** | 129 /** |
130 * CallCounter | 130 * CallCounter |
131 */ | 131 */ |
132 function CallCounter(expectedCount) { | 132 function CallCounter(expectedCount) { |
133 this._expectedCallCount = expectedCount; | 133 this._expectedCallCount = expectedCount; |
134 this._actualCallCount = 0; | 134 this._actualCallCount = 0; |
135 } | 135 } |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 }, | 615 }, |
616 | 616 |
617 _describeMockSetup: function() { | 617 _describeMockSetup: function() { |
618 var msg = "\nAllowed:"; | 618 var msg = "\nAllowed:"; |
619 for(var i=0; i<this._expectedInvocations.length; i++) { | 619 for(var i=0; i<this._expectedInvocations.length; i++) { |
620 var expectedInvocation = this._expectedInvocations[i]; | 620 var expectedInvocation = this._expectedInvocations[i]; |
621 msg += "\n" + expectedInvocation.describe(); | 621 msg += "\n" + expectedInvocation.describe(); |
622 } | 622 } |
623 return msg; | 623 return msg; |
624 } | 624 } |
625 } | 625 } |
OLD | NEW |