develooper Front page | perl.dbi.changes | Postings from March 2013

[svn:dbi] r15588 - dbi/trunk/t

From:
hmbrand
Date:
March 25, 2013 17:37
Subject:
[svn:dbi] r15588 - dbi/trunk/t
Message ID:
20130325173728.BC6AD184BB9@xx12.develooper.com
Author: hmbrand
Date: Mon Mar 25 10:37:27 2013
New Revision: 15588

Modified:
   dbi/trunk/t/90sql_type_cast.t

Log:
Ignore space issues of JSON formatting

The tests are about quotation of the value. Strip all leading/trailing
whitespace that is not part of the test,  treating '[99]' identical to
' [ 99 ] ' or '[99   ]'

reason is that the layout is not part of the test,  and formatters are
free to add/remove leading/trailing whitespace

These tests are only run if JSON::XS is installed.

Modified: dbi/trunk/t/90sql_type_cast.t
==============================================================================
--- dbi/trunk/t/90sql_type_cast.t	(original)
+++ dbi/trunk/t/90sql_type_cast.t	Mon Mar 25 10:37:27 2013
@@ -118,6 +118,11 @@
 
             my $json = JSON::XS->new->encode([$val]);
             #diag(neat($val), ",", $json);
+            # This test is about quotation of the value, not about the
+            # style/formatting of JSON. Strip all leading/trailing
+            # whitespace that is not part of the test, treating '[99]'
+            # identical to ' [ 99 ] ' or '[99   ]'
+            $json =~ s{^\s*\[\s*(.*?)\s*\]\s*$}{[$1]};
             is($json, $test->[5], "json $test->[0]");
         };
     }



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