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 assertSame call. 21 * 22 * @author Martin Heidegger. 23 */ 24 class org.as2lib.test.unit.info.AssertSameInfo extends AbstractAssertInfo { 25 26 /** Internal holder of the variable value. */ 27 private var val; 28 29 /** Internal holder of the value to compare. */ 30 private var compareTo; 31 32 /** 33 * Constructs a new AssertSameInfo. 34 * 35 * @param message Message if the assertion fails. 36 * @param val Value to be compared. 37 * @param compareTo Value to be compared with. 38 */ 39 public function AssertSameInfo(message:String, val, compareTo) { 40 super(message); 41 this.val = val; 42 this.compareTo = compareTo; 43 } 44 45 /** 46 * Overriding of @see AbstractAssertInfo#execute 47 * 48 * @return True if the execution fails. 49 */ 50 public function execute(Void):Boolean { 51 return(val !== compareTo); 52 } 53 54 /** 55 * Implementation of @see AbstractAssertInfo#getFailureMessage 56 * 57 * @return Message on failure 58 */ 59 private function getFailureMessage(Void):String { 60 var result:String = "assertSame failed"; 61 if(hasMessage()) { 62 result += " with message: "+message; 63 } 64 result += "!\n" 65 + " "+val.toString()+" !== "+compareTo.toString(); 66 return result; 67 } 68 69 /** 70 * Implementation of @see AbstractAssertInfo#getSuccessMessage 71 * 72 * @return Message on success 73 */ 74 private function getSuccessMessage(Void):String { 75 return ("assertSame executed. "+val.toString()+" === "+compareTo.toString()); 76 } 77 }