Nicolas Cannasse 17 éve
szülő
commit
5bcd1ecae7
3 módosított fájl, 32 hozzáadás és 0 törlés
  1. 1 0
      tests/unit/Test.hx
  2. 30 0
      tests/unit/TestEReg.hx
  3. 1 0
      tests/unit/unit.hxp

+ 1 - 0
tests/unit/Test.hx

@@ -174,6 +174,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			new TestSerialize(),
 			new TestSerialize(),
 			new TestMisc(),
 			new TestMisc(),
 			new TestResource(),
 			new TestResource(),
+			new TestEReg(),
 //			new TestRemoting(),
 //			new TestRemoting(),
 		];
 		];
 		var current = null;
 		var current = null;

+ 30 - 0
tests/unit/TestEReg.hx

@@ -0,0 +1,30 @@
+package unit;
+
+class TestEReg extends Test {
+
+
+	function test() {
+		#if !flash8
+		var r = ~/a+(b)?(c*)a+/;
+		f( r.match("") );
+		f( r.match("xxyy") );
+		t( r.match("xxaabcayyy") );
+		eq( r.matched(0), "aabca" );
+		eq( r.matched(1), "b" );
+		eq( r.matched(2), "c" );
+		eq( r.matchedLeft(), "xx" );
+		eq( r.matchedRight(), "yyy" );
+		eq( r.matchedPos().pos, 2 );
+		eq( r.matchedPos().len, 5 );
+
+		t( r.match("aaa") );
+		eq( r.matched(0), "aaa" );
+		eq( r.matchedLeft(), "" );
+		eq( r.matchedRight(), "" );
+		eq( r.matched(1), null );
+		eq( r.matched(2), "" );
+		exc(function() r.matched(3));
+		#end
+	}
+
+}

+ 1 - 0
tests/unit/unit.hxp

@@ -30,6 +30,7 @@
     <file path="RemotingServer.hx" />
     <file path="RemotingServer.hx" />
     <file path="Test.hx" />
     <file path="Test.hx" />
     <file path="TestBytes.hx" />
     <file path="TestBytes.hx" />
+    <file path="TestEReg.hx" />
     <file path="TestInt32.hx" />
     <file path="TestInt32.hx" />
     <file path="TestIO.hx" />
     <file path="TestIO.hx" />
     <file path="TestLocals.hx" />
     <file path="TestLocals.hx" />