1 /** 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.mozilla.org/MPL/MPL-1.1.html 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import org.as2lib.test.unit.AbstractAssertInfo; 18 19 /** 20 * Information holder and examiner of a assertNotUndefined call. 21 * 22 * @author Martin Heidegger. 23 */ 24 class org.as2lib.test.unit.info.AssertNotUndefinedInfo extends AbstractAssertInfo { 25 26 /** Internal holder of the variable value. */ 27 private var val; 28 29 /** 30 * Constructs a new AssertNotUndefinedInfo. 31 * 32 * @param message Message if the assertion fails. 33 * @param val Value that should not be undefined. 34 */ 35 public function AssertNotUndefinedInfo(message:String, val) { 36 super(message); 37 this.val = val; 38 } 39 40 /** 41 * Overriding of @see AbstractAssertInfo#execute 42 * 43 * @return True if the execution fails. 44 */ 45 public function execute(Void):Boolean { 46 return(val === undefined); 47 } 48 49 /** 50 * Implementation of @see AbstractAssertInfo#getFailureMessage 51 * 52 * @return Message on failure 53 */ 54 private function getFailureMessage(Void):String { 55 var result:String = "assertNotUndefined failed"; 56 if(hasMessage()) { 57 result += " with message: "+message; 58 } 59 result += "!\n" 60 + " "+val+" === undefined"; 61 return result; 62 } 63 64 /** 65 * Implementation of @see AbstractAssertInfo#getSuccessMessage 66 * 67 * @return Message on success 68 */ 69 private function getSuccessMessage(Void):String { 70 return ("assertNotUndefined executed. "+val+" !== undefined."); 71 } 72 }