help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] sunit: Add >>#assert:equals: from Pharo for the


From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH] sunit: Add >>#assert:equals: from Pharo for the Phexample
Date: Mon, 17 Jun 2013 10:09:14 +0200

The above selector is needed for Phexample and in general very
nice to debug failures as the result and expectation is immediately
visible in the debugger.

2013-05-11  Holger Hans Peter Freyther  <address@hidden>

        * packages/sunit/SUnit.st: Add #assert:equals: and
        #comparingStringBetween:and: from Pharo to the TestCase.
---
 packages/sunit/ChangeLog |    5 +++++
 packages/sunit/SUnit.st  |   18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index 56a52cf..bdb12a7 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-11  Holger Hans Peter Freyther  <address@hidden>
+
+       * packages/sunit/SUnit.st: Add #assert:equals: and
+       #comparingStringBetween:and: from Pharo to the TestCase.
+
 2012-08-03  Holger Hans Peter Freyther  <address@hidden>
 
        * packages/sunit/SUnit.st: Use testSelector printString as
diff --git a/packages/sunit/SUnit.st b/packages/sunit/SUnit.st
index 58b3ab0..38a872b 100644
--- a/packages/sunit/SUnit.st
+++ b/packages/sunit/SUnit.st
@@ -847,6 +847,13 @@ When you are writing a test case method, send #assert: 
aBoolean when you want to
                exception sunitSignalWith: aString]
     ]
 
+    assert: actual equals: expected [
+        <category: 'Accessing'>
+       ^ self
+               assert: expected = actual
+               description: [self comparingStringBetween: actual and: expected]
+    ]
+
     deny: aBoolean [
        <category: 'Accessing'>
        self assert: aBoolean not
@@ -1085,6 +1092,17 @@ When you are writing a test case method, send #assert: 
aBoolean when you want to
        testSelector := aSymbol
     ]
 
+    comparingStringBetween: actual and: expected [
+        <category: 'Private'>
+        ^ String streamContents: [:stream |
+                stream
+                    nextPutAll: 'Got ';
+                    nextPutAll: actual printString;
+                    nextPutAll: ' instead of ';
+                    nextPutAll: expected printString;
+                    nextPutAll: '.']
+    ]
+
     addDependentToHierachy: anObject [
        "an empty method. for Composite compability with TestSuite"
 
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]