Federico Cavalieri has proposed merging lp:~zorba-coders/zorba/nullcasts into 
lp:zorba.

Commit message:
Fixed casts to and from null

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/nullcasts/+merge/166094

Fixed casts to and from null
-- 
https://code.launchpad.net/~zorba-coders/zorba/nullcasts/+merge/166094
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2013-05-18 14:36:46 +0000
+++ src/types/casting.cpp	2013-05-28 16:10:46 +0000
@@ -1753,6 +1753,11 @@
   aFactory->createString(result, val);
 }
 
+T1_TO_T2(NUL, uA)
+{
+  zstring val("null");
+  str_uA(result, aItem, val, aFactory, nsCtx, errInfo);
+}
 
 /*******************************************************************************
 
@@ -2162,7 +2167,7 @@
   20,  // 42 XS_ANY_URI
   21,  // 43 XS_QNAME
   22,  // 44 XS_NOTATION
-  23,  // 45 JS_NULL
+  24,  // 45 JS_NULL
   25,  // 46 XS_DATETIME_STAMP
 };
 
@@ -2331,7 +2336,7 @@
  0,         &uint_bool,0,         0,         0,         0,         0,        &uint_uint,
  0,         0},
 
-{0,         &NUL_str,  0,         0,         0,         0,         0,        0,
+{&NUL_uA,   &NUL_str,  0,         0,         0,         0,         0,        0,
  0,         0,         0,         0,         0,         0,         0,        0,  
  0,         0,         0,         0,         0,         0,         0,        0,
  &NUL_NUL,  0}, // Nul

=== added file 'test/rbkt/ExpQueryResults/zorba/casting/null.xml.res'
--- test/rbkt/ExpQueryResults/zorba/casting/null.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/casting/null.xml.res	2013-05-28 16:10:46 +0000
@@ -0,0 +1,1 @@
+true true true true true true true
\ No newline at end of file

=== added file 'test/rbkt/ExpQueryResults/zorba/casting/null2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/casting/null2.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/casting/null2.xml.res	2013-05-28 16:10:46 +0000
@@ -0,0 +1,1 @@
+null
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/casting/null.xq'
--- test/rbkt/Queries/zorba/casting/null.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/casting/null.xq	2013-05-28 16:10:46 +0000
@@ -0,0 +1,55 @@
+declare namespace blub = "http://jsoniq.org/types";;
+
+(:  Only null may be cast to null:)
+(: Null may be cast to string or untypedAtomic ("null", its lexical representation) only. :)
+
+variable $test1 :=
+try {
+3.4 cast as blub:null
+}
+catch XPTY0004
+{true()};
+
+variable $test2 :=
+try {
+"3.4" cast as blub:null
+}
+catch XPTY0004
+{true()}; 
+
+variable $test3 :=
+try {
+3 cast as blub:null
+}
+catch XPTY0004
+{true()};
+
+variable $test4 :=
+try {
+(null cast as blub:null) eq null
+}
+catch *
+{false()};
+
+variable $test5 :=
+try {
+null cast as xs:integer
+}
+catch XPTY0004
+{true()};
+
+variable $test6 :=
+try {
+null cast as xs:float
+}
+catch XPTY0004
+{true()};
+
+variable $test7 :=
+try {
+(null cast as xs:string) eq "null"
+}
+catch *
+{false()};
+
+($test1, $test2, $test3, $test4,$test5, $test6, $test7)

=== added file 'test/rbkt/Queries/zorba/casting/null2.xq'
--- test/rbkt/Queries/zorba/casting/null2.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/casting/null2.xq	2013-05-28 16:10:46 +0000
@@ -0,0 +1,6 @@
+declare namespace blub = "http://jsoniq.org/types";;
+
+(:  Only null may be cast to null:)
+(: Null may be cast to string or untypedAtomic ("null", its lexical representation) only. :)
+
+null cast as xs:untypedAtomic

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to