compile the assertions and a test case to QUnit on JS and got a working example to run the unit test case - yay!
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package java.lang
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Iterator
|
||||
import js.library
|
||||
|
||||
library
|
||||
|
||||
@@ -2,3 +2,4 @@ package org.junit;
|
||||
|
||||
native
|
||||
annotation class Test(name : String = "") {}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package QUnit
|
||||
|
||||
import js.native
|
||||
|
||||
/**
|
||||
* The [QUnit](http://qunitjs.com/) API
|
||||
*/
|
||||
|
||||
native
|
||||
fun ok(actual: Boolean, message: String): Unit = js.noImpl;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package kotlin.test
|
||||
|
||||
/**
|
||||
* Comments out a block of test code until it is implemented while keeping a link to the code
|
||||
* to implement in your unit test output
|
||||
*/
|
||||
public inline fun todo(block: ()-> Any) {
|
||||
// println("TODO at " + (Exception() as java.lang.Throwable).getStackTrace()?.get(1) + " for " + block)
|
||||
println("TODO at " + block)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides the JS implementation of asserter using [QUnit](http://QUnitjs.com/)
|
||||
*/
|
||||
public var asserter: Asserter = QUnitAsserter()
|
||||
|
||||
public class QUnitAsserter(): Asserter {
|
||||
|
||||
public override fun assertTrue(message: String, actual: Boolean) {
|
||||
QUnit.ok(actual, message)
|
||||
}
|
||||
|
||||
public override fun assertEquals(message: String, expected: Any?, actual: Any?) {
|
||||
QUnit.ok(expected == actual, "$message. Expected <$expected> actual <$actual>")
|
||||
}
|
||||
|
||||
public override fun assertNotNull(message: String, actual: Any?) {
|
||||
QUnit.ok(actual != null, message)
|
||||
}
|
||||
|
||||
public override fun assertNull(message: String, actual: Any?) {
|
||||
QUnit.ok(actual == null, message)
|
||||
}
|
||||
|
||||
public override fun fail(message: String) {
|
||||
QUnit.ok(false, message)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user