develooper Front page | perl.perl6.internals | Postings from July 2002

Re: [PATCH] 3-arg chopn

Thread Previous | Thread Next
From:
Simon Glover
Date:
July 2, 2002 14:16
Subject:
Re: [PATCH] 3-arg chopn
Message ID:
Pine.GSO.4.43.0207021713420.2787-100000@egg.amnh.org

On Tue, 2 Jul 2002, Dan Sugalski wrote:

> At 2:37 PM -0500 7/2/02, brian wheeler wrote:
> >I saw this was a TODO item in core.ops.
>
> Applied, thanks.
>
> Tests, from anyone, would be much appreciated.

 Will these do?

 Simon


--- t/op/string.t.old	Tue Jul  2 16:59:23 2002
+++ t/op/string.t	Tue Jul  2 17:13:10 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 83;
+use Parrot::Test tests => 85;
 use Test::More;

 output_is( <<'CODE', <<OUTPUT, "set_s_s|sc" );
@@ -97,6 +97,84 @@ A string of lengt
 ** nothing **
 OUTPUT

+output_is(<<'CODE', <<OUTPUT, "Three argument chopn");
+	set	S1, "Parrot"
+
+	chopn	S2, S1, 0
+	print	S1
+	print	"\n"
+	print	S2
+	print	"\n"
+
+	chopn	S2, S1, 1
+	print	S1
+	print	"\n"
+	print	S2
+	print	"\n"
+
+        set     I0, 2
+	chopn	S2, S1, I0
+	print	S1
+	print	"\n"
+	print	S2
+	print	"\n"
+
+	chopn	S2, "Parrot", 3
+	print	S2
+	print	"\n"
+
+	chopn	S1, S1, 5
+	print	S1
+	print	"\n"
+
+        set     S1, "Parrot"
+        set     S3, S1
+        chopn   S2, S1, 3
+        print   S3
+	print	"\n"
+
+        set     S3, S1
+        chopn   S1, 3
+        print   S3
+	print	"\n"
+
+	end
+CODE
+Parrot
+Parrot
+Parrot
+Parro
+Parrot
+Parr
+Par
+P
+Parrot
+Par
+OUTPUT
+
+output_is(<<'CODE', <<OUTPUT, "Three argument chopn, OOB values");
+	set	S1, "Parrot"
+
+	chopn	S2, S1, 7
+	print	S1
+	print	"\n"
+	print	S2
+	print	"\n"
+
+	chopn	S2, S1, -1
+	print	S1
+	print	"\n"
+	print	S2
+	print	"\n"
+
+	end
+CODE
+Parrot
+
+Parrot
+Parrot
+OUTPUT
+
 output_is( <<'CODE', <<'OUTPUT', "substr_s_s|sc_i|ic_i|ic" );
 	set	S4, "12345JAPH01"
 	set	I4, 5


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About