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