Skip to content

Commit

Permalink
Fixing also #1647
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed May 27, 2019
1 parent e8f25ea commit ce53b15
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
9 changes: 7 additions & 2 deletions org.uqbar.project.wollok.lib/src/wollok/lib.wlk
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import wollok.vm.*

/**
* Console is a global wollok object that implements a character-based console device
* called "standard input/output" stream
Expand Down Expand Up @@ -74,6 +72,13 @@ object assert {
if (value) throw new AssertionException("Value was not false")
}

/*
* This method avoids confusion with equals definition in Object
*/
override method equals(value) {
throw new AssertionException("assert.equals(expected, actual): missing second parameter")
}

/**
* Tests whether two values are equal, based on wollok ==, != methods
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ class AssertTestCase extends AbstractWollokInterpreterTestCase {
'''.test
}

@Test
def void assertWithOneParameterShouldFail() {
'''
assert.throwsExceptionLike(
new AssertionException("assert.equals(expected, actual): missing second parameter"),
{ => assert.equals(4) }
)
'''.test
}

@Test
def void assertEqualsWhenEqualsWorks() {
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ program natives {
} catch e {
assert.equals(e.getStackTraceAsString(),
"wollok.lib.AssertionException: Expected [1] but found [true]
at [/lib.wlk:86]
at [/lib.wlk:91]
at [/assertTest.wpgm:3]
"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SetTest extends CollectionTestCase {
assert.equals(#{1,2,3}, set.asSet())
const list = set.asList()
assert.equals(3, list.size())
[1,2,3].forEach{i=>assert.equals(list.contains(i))}
[1,2,3].forEach{i=>assert.that(list.contains(i))}
'''.test
}

Expand Down

0 comments on commit ce53b15

Please sign in to comment.