Prev | Current Page 337 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

js
-main Main
-debug
Once compiled the result will be the same on every platform:
Class: TestERegValidator F
* TestERegValidator::testValidateFalse()
ERR: Main.hx:12(TestERegValidator.testValidate) - expected false but was true
// here are omitted some lines of debugging information
// that vary with the different platforms
FAILED 1 tests, 1 failed, 0 success
This was expected; the code compiles but does not work because the validation function always returns
true and the assertion expects a false argument to pass. Therefore, only the code that is needed for the
test to pass is introduced:
class ERegValidator
{
public function new(value:String, pattern:String, ?opt:String) {}
public function validate() : Bool
{
return false;
}
}
Now the execution of the code will report:
Class: TestERegValidator .
OK 1 tests, 0 failed, 1 success
175
Chapter 6: Organizing Your Code
A new failing test is introduced:
public function testValidateTrue()
{
var v = new ERegValidator(???test???, ???t???, null);
assertTrue(v.


Pages:
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349