[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2395] trunk



Revision: 2395
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2395&view=rev
Author:   einhverfr
Date:     2008-11-13 22:19:16 +0000 (Thu, 13 Nov 2008)

Log Message:
-----------
Correcting t/42 tests and dbobject array parsing.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject.pm

Added Paths:
-----------
    trunk/t/42-dbobject.t

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2008-11-13 17:02:11 UTC (rev 2394)
+++ trunk/LedgerSMB/DBObject.pm	2008-11-13 22:19:16 UTC (rev 2395)
@@ -260,14 +260,10 @@
         $next = "";
         $separator = "";
         if ($value =~ /^\{"/){
-            while ($next eq "" or ($next =~ /\\".$/)){
-                $value =~ s/^\{("[^"]*".)/\{/;
-                $next .= $1;
-                $next =~ /(.)$/;
-                $separator = $1;
-               $next .= "quoted";
-            }
-            $next =~ s/"(.*)"$separator$/$1/;
+            $value =~ s/^\{"(([^"]|\\")*[^\\])"/\{/;
+            $next = $1;
+            $next =~ /(.)$/;
+            $value =~ s/^{,/{/;
 
         } elsif ($value =~ /^{({+)/){
             my $open_braces = $1;
@@ -277,7 +273,6 @@
             $value =~ /^{($open_braces[^}]*$close_braces)/;
             my $parse_next = $1;
             $value =~ s/^{$parse_next/{/;
-           $value =~ s/^{,/{/;
             @$next = $self->_parse_array($parse_next);
             
         } else {

Added: trunk/t/42-dbobject.t
===================================================================
--- trunk/t/42-dbobject.t	                        (rev 0)
+++ trunk/t/42-dbobject.t	2008-11-13 22:19:16 UTC (rev 2395)
@@ -0,0 +1,12 @@
+use LedgerSMB::DBObject;
+use Test::More tests => 4;
+
+# Array parsing tests
+my $test = '{test,"test2\"\",",test3,"test4"}';
+my @vals = ('test', 'test2"",', 'test3', 'test4');
+my $passes = 0;
+for (LedgerSMB::DBObject->_parse_array($test)){
+  is($_, shift @vals, "pass $pass, array parse test");
+}
+
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.