Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

display line number of failed koan

  • Loading branch information...
commit 85b573e0d8eeadf004b97ced241a6c270c8427d0 1 parent 8e92057
@sl4m sl4m authored
View
1  HISTORY.markdown
@@ -2,6 +2,7 @@
#### 2011-Jul-04
+* display line number of failed koan
* do not display answers by default (use `script/run_and_reveal` to reveal answers)
* removed ClassHierarchy (does not seem that important)
View
4 src/koans/TestAssert.st
@@ -11,8 +11,8 @@ Koan subclass: TestAssert [
testEquality [
| expectedValue | "This is declaring a variable 'expectedValue'"
- expectedValue := fillMeIn. "':=' is an assignment operator"
+ expectedValue := fillMeIn. "':=' is an assignment operator"
"Hint: replace 'fillMeIn' with the expected value."
self expect: expectedValue toEqual: (5 + 5).
@@ -22,6 +22,7 @@ Koan subclass: TestAssert [
testStringEquality [
| expectedValue |
+
expectedValue := fillMeIn.
self expect: expectedValue toEqual: 'hello world!'.
@@ -29,6 +30,7 @@ Koan subclass: TestAssert [
testNotEqual [
| value |
+
value := 'some value'. "make this a different value"
self expect: value toNotEqual: 'some value'.
View
6 src/lib/Koan.st
@@ -18,6 +18,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'It is false, but SHOULD be true.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
yourself).
].
^nil
@@ -30,6 +31,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'It is true, but SHOULD be false.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
yourself).
].
]
@@ -41,6 +43,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'Expected value should equal actual value.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
add: #expected -> expectedValue;
add: #actual -> actualValue;
yourself).
@@ -55,6 +58,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'Expected value should not equal actual value.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
add: #expected -> expectedValue;
add: #actual -> actualValue;
yourself).
@@ -68,6 +72,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'Expected value is not like actual value.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
add: #expected -> expectedValue;
add: #actual -> actualValue;
yourself).
@@ -86,6 +91,7 @@ Object subclass: Koan [
tracker status: false.
tracker error: (Dictionary new
add: #message -> 'Expected exception was not given.';
+ add: #line -> thisContext parentContext currentLineInFile asString;
add: #expected -> expectedException;
add: #actual -> actualException;
yourself).
View
27 src/lib/UI.st
@@ -28,20 +28,21 @@ Object subclass: UI [
^' (an instance of ', (self className: value), ')'
]
- displayClass: klass test: testName [
- | klassName |
+ displayClass: klass test: testName line: line [
+ | klassName lineApprox |
klassName := klass name asString.
+ lineApprox := (line asNumber - 1) asString, '-', line.
output cr;
show: klassName, '#', testName asString, ' has damaged your karma.';
cr;
- show: '(in src/koans/', klassName, '.st)';
+ show: '(in src/koans/', klassName, '.st:', lineApprox, ')';
cr; cr.
]
displayEndMessage: passed failed: failed [
output cr;
- show: '', passed asString, ' passed, ', failed asString, ' failed.';
+ show: passed asString, ' passed, ', failed asString, ' failed.';
cr; cr.
]
@@ -69,14 +70,22 @@ Object subclass: UI [
]
display: dictionary [
- self displayClass: (dictionary at: #class) test: (dictionary at: #test).
- output show: self randomZenMessage, ' ', (dictionary at: #message);
+ | klass test line message passed failed |
+
+ klass := dictionary at: #class.
+ test := dictionary at: #test.
+ line := dictionary at: #line.
+ message := dictionary at: #message.
+ passed := dictionary at: #passed.
+ failed := dictionary at: #failed.
+
+ self displayClass: klass test: test line: line.
+ output show: self randomZenMessage, ' ', message;
cr; cr.
(dictionary includesKey: #expected) & (dictionary includesKey: #actual)
ifTrue: [
- self displayExpected: (dictionary at: #expected)
- actual: (dictionary at: #actual)
+ self displayExpected: (dictionary at: #expected) actual: (dictionary at: #actual)
].
- self displayEndMessage: (dictionary at: #passed) failed: (dictionary at: #failed).
+ self displayEndMessage: passed failed: failed.
]
]
Please sign in to comment.
Something went wrong with that request. Please try again.