Skip to content

Commit

Permalink
Merge pull request #177 from uqbar-project/add-lang-coverage
Browse files Browse the repository at this point in the history
Add lang coverage
  • Loading branch information
PalumboN authored Mar 20, 2024
2 parents 1c9c6d6 + 234d972 commit c426706
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin
.history
.history
log
5 changes: 5 additions & 0 deletions test/sanity/basics/booleans/literals.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ describe "booleans - tests with literals" {
assert.notThat({false}.apply() || {false}.apply())
}

test "toString" {
assert.equals("true", true.toString())
assert.equals("false", false.toString())
}

}
5 changes: 5 additions & 0 deletions test/sanity/basics/numbers/operators.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,9 @@ describe "Number operators" {
assert.equals(1, +1)
}

test "coerceToInteger" {
assert.equals(2, 2.coerceToInteger())
assert.equals(-1, -1.coerceToInteger())
}

}
5 changes: 5 additions & 0 deletions test/sanity/basics/numbers/roundingDecimals.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,9 @@ describe "Decimal tests"{
assert.equals(-1, (-1.5).round())
}

test "coerceToInteger" {
assert.equals(2, 2.2.coerceToInteger())
assert.equals(2, 2.7.coerceToInteger())
}

}
6 changes: 6 additions & 0 deletions test/sanity/basics/ranges/ranges.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ describe "ranges" {
assert.that(range.contains(anyOne))
}

test "anyOne inverse range" {
const range = new Range(start= 10, end = -5,step = -7)
const anyOne = range.anyOne()
assert.that(range.contains(anyOne))
}

test "anyOne probability" {
const range = 0 .. 10
range.step(2)
Expand Down
8 changes: 6 additions & 2 deletions test/sanity/basics/strings/strings.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ describe "strings" {
assert.throwsException( { "hola".substring(null) })
}

test "substring in first parameter fail" {
test "substring in first parameter should fail" {
assert.throwsException({ "hola".substring("a") })
}

test "substring in second parameter using null should fail" {
assert.throwsException( { "hola".substring(null, null) })
}

test "substring in second parameter fail" {
test "substring in second parameter should fail" {
assert.throwsException({ "hola".substring("a", "e") })
}

test "substring with invalid index should fail" {
assert.throwsException({ "Hola, wollok!".substring(-1, 3) })
}

test "greater than using null should fail" {
assert.throwsException { "hola" > null }
}
Expand Down
18 changes: 18 additions & 0 deletions test/sanity/collections/list.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,22 @@ describe "List tests" {
assert.equals(#{}, set.difference(randomized))
}

test "findOrElse - happy path" {
var encontro = true
const valueFound = numbers.findOrElse({ elem => elem < 22 }, { encontro = false })
assert.that(encontro)
}

test "findOrElse - not found" {
var encontro = true
const valueFound = numbers.findOrElse({ elem => elem > 100 }, { encontro = false })
assert.notThat(encontro)
}

test "join" {
assert.equals([1, 2, 3].join("-"), "1-2-3")
assert.equals([].join("-"), "")
}


}
30 changes: 30 additions & 0 deletions test/sanity/collections/set.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,34 @@ describe "set tests" {
assert.equals(#{22}, numbers)
}

test "findOrElse - happy path" {
var encontro = true
const valueFound = #{1, 2, 3, 4}.findOrElse({ elem => elem < 3 }, { encontro = false })
assert.that(encontro)
}

test "findOrElse - not found" {
var encontro = true
const valueFound = #{1, 2, 3, 4}.findOrElse({ elem => elem > 100 }, { encontro = false })
assert.notThat(encontro)
}

test "max" {
assert.equals(5, #{1, 5, 0, -8, 3}.max())
assert.equals(5, #{5, 1, 0, -8, 3}.max())
assert.equals(5, #{1, 0, -8, 3, 5}.max())
}

test "clear" {
const unSet = #{1, 2, 3}
assert.equals(3, unSet.size())
unSet.clear()
assert.equals(#{}, unSet)
}

test "join" {
assert.equals(#{1, 2, 3}.join("-"), "1-2-3")
assert.equals(#{}.join("-"), "")
}

}

0 comments on commit c426706

Please sign in to comment.