[svn:parrot] r44393 - in trunk: src/pmc t/pmc

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Tue Feb 23 17:39:17 UTC 2010


Author: pmichaud
Date: Tue Feb 23 17:39:14 2010
New Revision: 44393
URL: https://trac.parrot.org/parrot/changeset/44393

Log:
[core]:  Add get_number vtable to FixedStringArray PMC.  Resolves TT #1445.

Modified:
   trunk/src/pmc/fixedstringarray.pmc
   trunk/t/pmc/fixedstringarray.t

Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc	Tue Feb 23 16:14:09 2010	(r44392)
+++ trunk/src/pmc/fixedstringarray.pmc	Tue Feb 23 17:39:14 2010	(r44393)
@@ -183,6 +183,20 @@
         return SELF.elements();
     }
 
+/*
+
+=item C<FLOATVAL get_number()>
+
+Returns the number of elements in the array.
+
+=cut
+
+*/
+
+    VTABLE FLOATVAL get_number() {
+        const INTVAL e = SELF.elements();
+        return (FLOATVAL)e;
+    }
 
 /*
 

Modified: trunk/t/pmc/fixedstringarray.t
==============================================================================
--- trunk/t/pmc/fixedstringarray.t	Tue Feb 23 16:14:09 2010	(r44392)
+++ trunk/t/pmc/fixedstringarray.t	Tue Feb 23 17:39:14 2010	(r44393)
@@ -19,7 +19,7 @@
 
 .sub 'main' :main
     .include 'test_more.pir'
-    plan(44)
+    plan(46)
 
     'test_set_size'()       # 2 tests
     'test_reset_size'()     # 1 test
@@ -37,6 +37,7 @@
     'test_get_string'()     # 1 test
     'test_equality'()       # 5 tests
     'test_gc'()             # 4 tests
+    'test_number'()         # 2 tests
 .end
 
 .sub 'test_set_size'
@@ -364,6 +365,18 @@
 .end
 
 
+.sub 'test_number'
+    .local pmc fsa
+    fsa = new ['FixedStringArray']
+    fsa = 3
+
+    $I0 = fsa
+    is($I0, 3, "get_integer returns correct size")
+    $N0 = fsa
+    is($N0, 3.0, "get_number returns correct size")
+.end
+
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list