PageRenderTime 620ms CodeModel.GetById 342ms app.highlight 3ms RepoModel.GetById 175ms app.codeStats 1ms

/flash-src/third-party/com/hurlant/crypto/tests/TestCase.as

http://github.com/gimite/web-socket-js
ActionScript | 42 lines | 29 code | 4 blank | 9 comment | 1 complexity | fef1e46d9e0afd35910ab8d2c0174688 MD5 | raw file
 1/**
 2 * TestCase
 3 * 
 4 * Embryonic unit test support class.
 5 * Copyright (c) 2007 Henri Torgemane
 6 * 
 7 * See LICENSE.txt for full license information.
 8 */
 9package com.hurlant.crypto.tests
10{
11	public class TestCase 
12	{
13		public var harness:ITestHarness;
14		
15		public function TestCase(h:ITestHarness, title:String) {
16			harness = h;
17			harness.beginTestCase(title);
18		}
19		
20		
21		public function assert(msg:String, value:Boolean):void {
22			if (value) {
23//				TestHarness.print("+ ",msg);
24				return;
25			}
26			throw new Error("Test Failure:"+msg);
27		}
28		
29		public function runTest(f:Function, title:String):void {
30			harness.beginTest(title);
31			try {
32				f();
33			} catch (e:Error) {
34				trace("EXCEPTION THROWN: "+e);
35				trace(e.getStackTrace());
36				harness.failTest(e.toString());
37				return;
38			}
39			harness.passTest();
40		}
41	}
42}