Merge lp:~nbrinza/zorba/bugs2 into lp:zorba

Proposed by Nicolae Brinza
Status: Merged
Approved by: Chris Hillery
Approved revision: 11013
Merged at revision: 11336
Proposed branch: lp:~nbrinza/zorba/bugs2
Merge into: lp:zorba
Diff against target: 384 lines (+126/-41)
15 files modified
src/diagnostics/diagnostic_en.xml (+1/-1)
src/diagnostics/pregenerated/dict_en.cpp (+1/-1)
src/runtime/core/arithmetic_impl.cpp (+20/-4)
src/zorbatypes/datetime/duration.cpp (+49/-19)
test/fots/CMakeLists.txt (+0/-11)
test/rbkt/ExpQueryResults/zorba/HigherOrder/combinator-02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res (+2/-0)
test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec (+1/-0)
test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq (+7/-0)
test/rbkt/Queries/zorba/HigherOrder/combinator-02.xq (+2/-5)
test/rbkt/Queries/zorba/HigherOrder/hof-101.xq (+27/-0)
test/rbkt/Queries/zorba/HigherOrder/hof-104.xq (+9/-0)
test/rbkt/Queries/zorba/HigherOrder/hof-105.spec (+1/-0)
test/rbkt/Queries/zorba/HigherOrder/hof-105.xq (+3/-0)
To merge this branch: bzr merge lp:~nbrinza/zorba/bugs2
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Paul J. Lucas Approve
Nicolae Brinza Approve
Review via email: mp+156732@code.launchpad.net

This proposal supersedes a proposal from 2013-04-02.

Commit message

Fixed the duration arithemtic bug.
Added missing testcases for HoF bugs.

Description of the change

Fixed the duration arithemtic bug.
Added missing testcases for HoF bugs.

To post a comment you must log in.
Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~nbrinza/zorba/bugs2 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bugs2-2012-09-28T08-24-10.715Z is finished. The final
  status was:

  5 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job bugs2-2012-09-28T09-31-14.134Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

Added Markos as a reviewer.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote : Posted in a previous version of this proposal

I approve, but I think more memory leaks of the kind fixed around xquery_parser.y:2506 exist. For example, the Expr rule has 2 "error" productions. deletes were added in one of them, but not the other.

Nicolae, can you open a bug (to yourself) to go through all of the error procuctions in the parser and fix the memory leaks, if any?

Revision history for this message
Markos Zaharioudakis (markos-za) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job bugs2-2012-09-29T04-24-59.058Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Paul J. Lucas (paul-lucas) wrote : Posted in a previous version of this proposal

How can the constant for seconds_per_year be correct? It can't be a constant since its correct value is: 60 * 60 * 24 * (365 + is_leap(year))

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~nbrinza/zorba/bugs2 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bugs2-2013-03-27T14-36-03.816Z is finished. The final
  status was:

  8 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Nicolae Brinza (nbrinza) wrote : Posted in a previous version of this proposal

It's a duration. It does not have a start/end date. So you cannot possibly know if you're in a leap year.

I've searched a bit, but I cannot find the spec where it says how to perform the duration normalization, but the code in Duration::normalize() assumes a year has 60 * 60 * 24 * 30 * 12 seconds.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Paul J. Lucas (paul-lucas) wrote : Posted in a previous version of this proposal

> It's a duration. It does not have a start/end date. So you cannot possibly
> know if you're in a leap year.

True, but the fact remains that having a constant for the number of seconds in a year is non-sensical for a duration.

> I've searched a bit, but I cannot find the spec where it says how to perform
> the duration normalization ...

Did you ask the W3C? Or file a bug against the spec?

> ... but the code in Duration::normalize() assumes a year has 60 * 60 * 24 * 30 * 12 seconds.

So? Where did that code come from? What makes you think that code is correct?

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~nbrinza/zorba/bugs2 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bugs2-2013-03-27T15-35-01.739Z is finished. The final
  status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Nicolae Brinza (nbrinza) wrote : Posted in a previous version of this proposal

I've looked into it. It is not a spec issue, it's an implementation choice. The multiply/divide are only defined on the yearMonthDuration and dayTimeDuration data types. For both of these types, and for the purpose of multiplication/division, assuming a year has 60 * 60 * 24 * 30 * 12 seconds works perfectly.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job bugs2-2013-03-27T16-25-10.723Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 3 Pending.

Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Paul J. Lucas (paul-lucas) wrote : Posted in a previous version of this proposal

When you throw FODT0002, you don't include either the value that's responsible for the error nor the location.

review: Needs Fixing
Revision history for this message
Nicolae Brinza (nbrinza) wrote : Posted in a previous version of this proposal

I have added the location and the value.

Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job bugs2-2013-04-01T21-56-14.821Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Chris Hillery (ceejatec) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Paul J. Lucas (paul-lucas) wrote : Posted in a previous version of this proposal

The TRY_XS_INT_CONVERT should probably be more like:

 #define TRY_XS_INT_CONVERT(target, value, xs_type) \
   { \
     XS_TYPE const res( value ); \
     try { \
       target = to_xs_int(res); \
     } catch (std::range_error const&) { \
       throw XQUERY_EXCEPTION(err::FODT0002, ERROR_PARAMS(res.toString())); \
     } \
   }

Revision history for this message
Nicolae Brinza (nbrinza) wrote : Posted in a previous version of this proposal

No, I believe the construction of "res" and the conversion will be useless in the most common case where the error does not happen. But I've copy pasted your suggestion anyway.

Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in test/fots/CMakeLists.txt

Revision history for this message
Paul J. Lucas (paul-lucas) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Nicolae Brinza (nbrinza) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Paul J. Lucas (paul-lucas) wrote : Posted in a previous version of this proposal

BTW: You don't have to keep creating new merge proposals every time you want to merge even when there are errors or merge conflicts. This way, you don't need to seek our approval multiple times. A single merge proposal is all you need.

Revision history for this message
Paul J. Lucas (paul-lucas) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~nbrinza/zorba/bugs2 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bugs2-2013-04-02T21-42-03.655Z is finished. The final
  status was:

  5 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2013-04-03T04-27-07.239Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2013-04-03T06-44-58.934Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-04-01 02:22:49 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-04-03 03:40:32 +0000
@@ -1355,7 +1355,7 @@
1355 <comment>1355 <comment>
1356 Overflow/underflow in duration operation.1356 Overflow/underflow in duration operation.
1357 </comment>1357 </comment>
1358 <value>overflow/underflow in duration operation</value>1358 <value>overflow/underflow in duration operation${: 1}</value>
1359 </diagnostic>1359 </diagnostic>
13601360
1361 <diagnostic code="FODT0003">1361 <diagnostic code="FODT0003">
13621362
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-04-01 02:22:49 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-04-03 03:40:32 +0000
@@ -50,7 +50,7 @@
50 { "FODF1280", "\"$1\": invalid decimal format name for fn:format-number()" },50 { "FODF1280", "\"$1\": invalid decimal format name for fn:format-number()" },
51 { "FODF1310", "\"$1\": invalid picture string for decimal/integer${: 2}" },51 { "FODF1310", "\"$1\": invalid picture string for decimal/integer${: 2}" },
52 { "FODT0001", "overflow/underflow in date/time operation" },52 { "FODT0001", "overflow/underflow in date/time operation" },
53 { "FODT0002", "overflow/underflow in duration operation" },53 { "FODT0002", "overflow/underflow in duration operation${: 1}" },
54 { "FODT0003", "\"$1\": invalid timezone value (in seconds)" },54 { "FODT0003", "\"$1\": invalid timezone value (in seconds)" },
55 { "FOER0000", "unidentifier error" },55 { "FOER0000", "unidentifier error" },
56 { "FOFD1340", "\"$1\": invalid picture string for date/time${: 2}" },56 { "FOFD1340", "\"$1\": invalid picture string for date/time${: 2}" },
5757
=== modified file 'src/runtime/core/arithmetic_impl.cpp'
--- src/runtime/core/arithmetic_impl.cpp 2013-03-20 19:12:54 +0000
+++ src/runtime/core/arithmetic_impl.cpp 2013-04-03 03:40:32 +0000
@@ -596,8 +596,12 @@
596 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );596 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );
597 else if (i1->getDoubleValue().isNaN())597 else if (i1->getDoubleValue().isNaN())
598 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );598 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );
599 else599 else try {
600 d.reset(i0->getYearMonthDurationValue() * (i1->getDoubleValue()));600 d.reset(i0->getYearMonthDurationValue() * (i1->getDoubleValue()));
601 } catch (XQueryException& e) {
602 set_source(e, *loc);
603 throw;
604 }
601 605
602 return GENV_ITEMFACTORY->createYearMonthDuration(result, d.get());606 return GENV_ITEMFACTORY->createYearMonthDuration(result, d.get());
603}607}
@@ -618,8 +622,12 @@
618 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );622 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );
619 else if (i1->getDoubleValue().isNaN())623 else if (i1->getDoubleValue().isNaN())
620 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );624 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );
621 else625 else try {
622 d.reset(i0->getDayTimeDurationValue() * (i1->getDoubleValue()));626 d.reset(i0->getDayTimeDurationValue() * (i1->getDoubleValue()));
627 } catch (XQueryException& e) {
628 set_source(e, *loc);
629 throw;
630 }
623 631
624 return GENV_ITEMFACTORY->createDayTimeDuration(result, d.get());632 return GENV_ITEMFACTORY->createDayTimeDuration(result, d.get());
625}633}
@@ -674,8 +682,12 @@
674 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );682 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );
675 else if ( i1->getDoubleValue().isNaN() )683 else if ( i1->getDoubleValue().isNaN() )
676 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );684 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );
677 else685 else try {
678 d = std::auto_ptr<Duration>(i0->getYearMonthDurationValue() / i1->getDoubleValue());686 d = std::auto_ptr<Duration>(i0->getYearMonthDurationValue() / i1->getDoubleValue());
687 } catch (XQueryException& e) {
688 set_source(e, *loc);
689 throw;
690 }
679691
680 return GENV_ITEMFACTORY->createYearMonthDuration(result, d.get());692 return GENV_ITEMFACTORY->createYearMonthDuration(result, d.get());
681}693}
@@ -700,8 +712,12 @@
700 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );712 throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) );
701 else if ( i1->getDoubleValue().isNaN() )713 else if ( i1->getDoubleValue().isNaN() )
702 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );714 throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) );
703 else715 else try {
704 d.reset(i0->getDayTimeDurationValue() / i1->getDoubleValue());716 d.reset(i0->getDayTimeDurationValue() / i1->getDoubleValue());
717 } catch (XQueryException& e) {
718 set_source(e, *loc);
719 throw;
720 }
705721
706 return GENV_ITEMFACTORY->createDayTimeDuration(result, d.get());722 return GENV_ITEMFACTORY->createDayTimeDuration(result, d.get());
707}723}
708724
=== modified file 'src/zorbatypes/datetime/duration.cpp'
--- src/zorbatypes/datetime/duration.cpp 2013-03-11 15:00:50 +0000
+++ src/zorbatypes/datetime/duration.cpp 2013-04-03 03:40:32 +0000
@@ -41,6 +41,7 @@
41 0, 12, 30, 24, 60, 60, Duration::FRAC_SECONDS_UPPER_LIMIT41 0, 12, 30, 24, 60, 60, Duration::FRAC_SECONDS_UPPER_LIMIT
42};42};
4343
44static const long seconds_per_year = 60 * 60 * 24 * 30 * 12;
4445
45/******************************************************************************46/******************************************************************************
46 Parse a 'nS' string, with fractional seconds, returns 0 on success and a47 Parse a 'nS' string, with fractional seconds, returns 0 on success and a
@@ -725,12 +726,24 @@
725}726}
726727
727728
729#define TRY_XS_INT_CONVERT(target, value, xs_type) \
730 { \
731 xs_type const res(value); \
732 try { \
733 target = to_xs_int(res); \
734 } catch (std::range_error const&) { \
735 throw XQUERY_EXCEPTION(err::FODT0002, ERROR_PARAMS(res.toString())); \
736 } \
737 }
738
728Duration* Duration::operator*(const xs_double& value) const739Duration* Duration::operator*(const xs_double& value) const
729{740{
730 xs_double result;741 xs_double result;
731 xs_double dSeconds;742 xs_integer totalSeconds;
743 int32_t years;
732 int32_t seconds;744 int32_t seconds;
733 int32_t frac_seconds;745 int32_t frac_seconds;
746 bool negative = false;
734747
735 if (facet == DURATION_FACET)748 if (facet == DURATION_FACET)
736 {749 {
@@ -738,19 +751,26 @@
738 return NULL;751 return NULL;
739 }752 }
740753
741 Integer significants = Integer(FRAC_SECONDS_UPPER_LIMIT);
742
743 try {754 try {
744 result = getTotalSeconds() * value;755 result = getTotalSeconds() * value;
745 result = result.round(significants);756 } catch (std::range_error const&) {
746 seconds = to_xs_int(result.floor());
747 result = (result - result.floor()) * FRAC_SECONDS_UPPER_LIMIT;
748 frac_seconds = to_xs_int(result.round());
749 } catch ( std::range_error const& ) {
750 throw XQUERY_EXCEPTION(err::FODT0002);757 throw XQUERY_EXCEPTION(err::FODT0002);
751 }758 }
752759
753 Duration* d = new Duration(facet, seconds<0, 0, 0, 0, 0, 0, seconds, frac_seconds);760 if (result < 0)
761 {
762 negative = true;
763 result = -result;
764 }
765 result = result.round(Integer(FRAC_SECONDS_UPPER_LIMIT));
766 totalSeconds = result.floor();
767 result = (result - result.floor()) * FRAC_SECONDS_UPPER_LIMIT;
768
769 TRY_XS_INT_CONVERT(years, totalSeconds / seconds_per_year, xs_integer);
770 TRY_XS_INT_CONVERT(seconds, totalSeconds % seconds_per_year, xs_integer);
771 TRY_XS_INT_CONVERT(frac_seconds, result.round(), xs_double);
772
773 Duration* d = new Duration(facet, negative, years, 0, 0, 0, 0, seconds, frac_seconds);
754 return d;774 return d;
755}775}
756776
@@ -758,9 +778,11 @@
758Duration* Duration::operator/(const xs_double& value) const778Duration* Duration::operator/(const xs_double& value) const
759{779{
760 xs_double result;780 xs_double result;
761 xs_double dSeconds;781 xs_integer totalSeconds;
782 int32_t years;
762 int32_t seconds;783 int32_t seconds;
763 int32_t frac_seconds;784 int32_t frac_seconds;
785 bool negative = false;
764786
765 if (facet == DURATION_FACET)787 if (facet == DURATION_FACET)
766 {788 {
@@ -768,23 +790,31 @@
768 return NULL;790 return NULL;
769 }791 }
770792
771 Integer significants = Integer(FRAC_SECONDS_UPPER_LIMIT);
772
773 try {793 try {
774 result = getTotalSeconds() / value;794 result = getTotalSeconds() / value;
775 result = result.round(significants);795 } catch (std::range_error const&) {
776 dSeconds = result.round();
777 seconds = to_xs_int(dSeconds.floor());
778 result = (result - dSeconds) * FRAC_SECONDS_UPPER_LIMIT;
779 frac_seconds = to_xs_int(result.round());
780 } catch ( std::range_error const& ) {
781 throw XQUERY_EXCEPTION(err::FODT0002);796 throw XQUERY_EXCEPTION(err::FODT0002);
782 }797 }
783798
784 Duration* d = new Duration(facet, seconds<0, 0, 0, 0, 0, 0, seconds, frac_seconds);799 if (result < 0)
800 {
801 negative = true;
802 result = -result;
803 }
804 result = result.round(Integer(FRAC_SECONDS_UPPER_LIMIT));
805 totalSeconds = result.floor();
806 result = (result - result.floor()) * FRAC_SECONDS_UPPER_LIMIT;
807
808 TRY_XS_INT_CONVERT(years, totalSeconds / seconds_per_year, xs_integer);
809 TRY_XS_INT_CONVERT(seconds, totalSeconds % seconds_per_year, xs_integer);
810 TRY_XS_INT_CONVERT(frac_seconds, result.round(), xs_double);
811
812 Duration* d = new Duration(facet, negative, years, 0, 0, 0, 0, seconds, frac_seconds);
785 return d;813 return d;
786}814}
787815
816#undef TRY_XS_INT_CONVERT
817
788818
789Decimal Duration::operator/(const Duration& d) const819Decimal Duration::operator/(const Duration& d) const
790{820{
791821
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-04-02 18:29:15 +0000
+++ test/fots/CMakeLists.txt 2013-04-03 03:40:32 +0000
@@ -133,8 +133,6 @@
133EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-002 0)133EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-002 0)
134EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-003 0)134EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-003 0)
135EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0)135EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0)
136EXPECTED_FOTS_FAILURE (fn-avg cbcl-avg-002 0)
137EXPECTED_FOTS_FAILURE (fn-avg cbcl-avg-003 0)
138EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-36 0)136EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-36 0)
139EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-37 0)137EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-37 0)
140EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-38 0)138EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-38 0)
@@ -144,15 +142,12 @@
144EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0)142EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0)
145EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-006 0)143EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-006 0)
146EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-007 0)144EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-007 0)
147EXPECTED_FOTS_FAILURE (fn-format-date format-date-005 0)
148EXPECTED_FOTS_FAILURE (fn-format-date format-date-006 0)
149EXPECTED_FOTS_FAILURE (fn-format-date format-date-en126 0)145EXPECTED_FOTS_FAILURE (fn-format-date format-date-en126 0)
150EXPECTED_FOTS_FAILURE (fn-format-date format-date-en127 0)146EXPECTED_FOTS_FAILURE (fn-format-date format-date-en127 0)
151EXPECTED_FOTS_FAILURE (fn-format-date format-date-en128 0)147EXPECTED_FOTS_FAILURE (fn-format-date format-date-en128 0)
152EXPECTED_FOTS_FAILURE (fn-format-date format-date-en132 0)148EXPECTED_FOTS_FAILURE (fn-format-date format-date-en132 0)
153EXPECTED_FOTS_FAILURE (fn-format-date format-date-en133 0)149EXPECTED_FOTS_FAILURE (fn-format-date format-date-en133 0)
154EXPECTED_FOTS_FAILURE (fn-format-date format-date-en134 0)150EXPECTED_FOTS_FAILURE (fn-format-date format-date-en134 0)
155EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-005 0)
156EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-006 0)151EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-006 0)
157EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-011 0)152EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-011 0)
158EXPECTED_FOTS_FAILURE (fn-format-integer format-integer-044 1162631)153EXPECTED_FOTS_FAILURE (fn-format-integer format-integer-044 1162631)
@@ -286,12 +281,8 @@
286EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-8 0)281EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-8 0)
287EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-9 0)282EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-9 0)
288EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-1 0)283EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-1 0)
289EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-2 0)
290EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-3 0)
291EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-4 0)284EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-4 0)
292EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-6 0)285EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-6 0)
293EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-7 0)
294EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-8 0)
295EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-9 0)286EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-9 0)
296EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_13 0)287EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_13 0)
297EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_14 0)288EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_14 0)
@@ -321,11 +312,9 @@
321EXPECTED_FOTS_FAILURE (op-date-greater-than cbcl-date-le-001 0)312EXPECTED_FOTS_FAILURE (op-date-greater-than cbcl-date-le-001 0)
322EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-ge-001 0)313EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-ge-001 0)
323EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-lt-001 0)314EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-lt-001 0)
324EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration cbcl-divide-dayTimeDuration-003 0)
325EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-001 0)315EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-001 0)
326EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-002 0)316EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-002 0)
327EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-003 0)317EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-003 0)
328EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration cbcl-divide-yearMonthDuration-003 0)
329EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration-by-yearMonthDuration cbcl-divide-yearMonthDuration-by-yearMonthDuration-001 0)318EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration-by-yearMonthDuration cbcl-divide-yearMonthDuration-by-yearMonthDuration-001 0)
330EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-001 0)319EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-001 0)
331EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-002 0)320EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-002 0)
332321
=== renamed file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.res' => 'test/rbkt/ExpQueryResults/zorba/HigherOrder/combinator-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.res 2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/combinator-02.xml.res 2013-04-03 03:40:32 +0000
@@ -1,1 +1,2 @@
1<?xml version="1.0" encoding="UTF-8"?>1<?xml version="1.0" encoding="UTF-8"?>
21 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 -1
23
=== added file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res'
--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res 2013-04-03 03:40:32 +0000
@@ -0,0 +1,2 @@
1<?xml version="1.0" encoding="UTF-8"?>
2Message: This is a test.
03
=== added file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res'
--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res 2013-04-03 03:40:32 +0000
@@ -0,0 +1,2 @@
1<?xml version="1.0" encoding="UTF-8"?>
2wbua
03
=== added file 'test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec'
--- test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec 2013-04-03 03:40:32 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZXQP0003
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq'
--- test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq 2013-04-03 03:40:32 +0000
@@ -0,0 +1,7 @@
1(: Infinite Y combinator test -- should cause a stack overflow :)
2
3declare function local:Y($f) {
4 function($a) { $f(local:Y($f), $a) }
5};
6
7local:Y(function($f, $a) { $a, $f($a + 1) })(1)
08
=== renamed file 'test/rbkt/Queries/zorba/HigherOrder/hof-101.xq' => 'test/rbkt/Queries/zorba/HigherOrder/combinator-02.xq'
--- test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 2013-02-07 17:24:36 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/combinator-02.xq 2013-04-03 03:40:32 +0000
@@ -1,10 +1,7 @@
1xquery version "3.0";1(: Y combinator test :)
2
3declare namespace o = "http://www.zorba-xquery.com/options/features";
4declare option o:enable "hof";
52
6declare function local:Y($f) {3declare function local:Y($f) {
7function($a) { $f(local:Y($f), $a) }4function($a) { $f(local:Y($f), $a) }
8};5};
96
10local:Y(function($f, $a) { $a, $f($a + 1) })(1)7local:Y(function($f, $a) { $a, if ($a < 500) then $f($a + 1) else -1 })(1)
118
=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-101.xq'
--- test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 2013-04-03 03:40:32 +0000
@@ -0,0 +1,27 @@
1declare namespace an = "http://www.zorba-xquery.com/annotations";
2
3declare %private variable $handlers := ();
4
5declare %an:sequential function local:add($handler)
6{
7 $handlers := ($handlers, $handler);
8};
9
10declare function local:emit($message)
11{
12 for $h in $handlers
13 return $h($message)
14};
15
16declare function local:handle($message)
17{
18 ("Message:", $message)
19};
20
21declare %an:sequential function local:test($message)
22{
23 local:add(local:handle#1);
24 local:emit($message)
25};
26
27local:test("This is a test.")
028
=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-104.xq'
--- test/rbkt/Queries/zorba/HigherOrder/hof-104.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-104.xq 2013-04-03 03:40:32 +0000
@@ -0,0 +1,9 @@
1(: Higher order function as a prolog variable :)
2
3declare variable $func := function($x){translate($x, "abcdefghijklmnopqrstuvwxyz", "nopqrstuvwxyzabcdefghijklm")};
4
5declare function local:scramble($x as function(xs:string) as xs:string, $y as xs:string) as xs:string {
6 $x($y)
7};
8
9local:scramble($func, "john")
010
=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-105.spec'
--- test/rbkt/Queries/zorba/HigherOrder/hof-105.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-105.spec 2013-04-03 03:40:32 +0000
@@ -0,0 +1,1 @@
1Error: http://www.w3.org/2005/xqt-errors:SENR0001
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-105.xq'
--- test/rbkt/Queries/zorba/HigherOrder/hof-105.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/HigherOrder/hof-105.xq 2013-04-03 03:40:32 +0000
@@ -0,0 +1,3 @@
1function($a,$b){
2 function($a1,$b1){ $a1($b1) }
3}(function($a2){$a2}, "test")

Subscribers

People subscribed via source and target branches