zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #20202
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
Nicolae Brinza has proposed merging lp:~nbrinza/zorba/bugs2 into lp:zorba.
Commit message:
More datetime/duration fixes.
Requested reviews:
Nicolae Brinza (nbrinza)
Chris Hillery (ceejatec)
Related bugs:
Bug #898792 in Zorba: "xs:QName fails for non-literal input"
https://bugs.launchpad.net/zorba/+bug/898792
Bug #931501 in Zorba: "improve error message for fn:format-number"
https://bugs.launchpad.net/zorba/+bug/931501
Bug #1123836 in Zorba: "arithmetic operators on durations, dates and times failures (at least 46)"
https://bugs.launchpad.net/zorba/+bug/1123836
Bug #1154367 in Zorba: "yearMonthDuration arithmetic bug"
https://bugs.launchpad.net/zorba/+bug/1154367
For more details, see:
https://code.launchpad.net/~nbrinza/zorba/bugs2/+merge/157752
More datetime/duration fixes.
--
https://code.launchpad.net/~nbrinza/zorba/bugs2/+merge/157752
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/core/arithmetic_impl.cpp'
--- src/runtime/core/arithmetic_impl.cpp 2013-04-01 21:52:20 +0000
+++ src/runtime/core/arithmetic_impl.cpp 2013-04-08 21:02:33 +0000
@@ -260,10 +260,16 @@
compute<store::XS_DATETIME,store::XS_DATETIME>
(result, dctx, tm, &aLoc, n0, n1);
}
- else if (TypeOps::is_subtype(tm, *type1, *rtm.DURATION_TYPE_ONE ))
- {
- return Operation::template
- compute<store::XS_DATETIME,store::XS_DURATION>
+ else if (TypeOps::is_subtype(tm, *type1, *rtm.YM_DURATION_TYPE_ONE ))
+ {
+ return Operation::template
+ compute<store::XS_DATETIME,store::XS_YM_DURATION>
+ (result, dctx, tm, &aLoc, n0, n1);
+ }
+ else if (TypeOps::is_subtype(tm, *type1, *rtm.DT_DURATION_TYPE_ONE ))
+ {
+ return Operation::template
+ compute<store::XS_DATETIME,store::XS_DT_DURATION>
(result, dctx, tm, &aLoc, n0, n1);
}
}
@@ -275,10 +281,16 @@
compute<store::XS_DATE,store::XS_DATE>
(result, dctx, tm, &aLoc, n0, n1);
}
- else if (TypeOps::is_subtype(tm, *type1, *rtm.DURATION_TYPE_ONE))
- {
- return Operation::template
- compute<store::XS_DATE,store::XS_DURATION>
+ else if (TypeOps::is_subtype(tm, *type1, *rtm.YM_DURATION_TYPE_ONE))
+ {
+ return Operation::template
+ compute<store::XS_DATE,store::XS_YM_DURATION>
+ (result, dctx, tm, &aLoc, n0, n1);
+ }
+ else if (TypeOps::is_subtype(tm, *type1, *rtm.DT_DURATION_TYPE_ONE))
+ {
+ return Operation::template
+ compute<store::XS_DATE,store::XS_DT_DURATION>
(result, dctx, tm, &aLoc, n0, n1);
}
}
@@ -293,7 +305,7 @@
else if (TypeOps::is_subtype(tm, *type1, *rtm.DT_DURATION_TYPE_ONE))
{
return Operation::template
- compute<store::XS_TIME,store::XS_DURATION>
+ compute<store::XS_TIME,store::XS_DT_DURATION>
(result, dctx, tm, &aLoc, n0, n1);
}
}
@@ -732,7 +744,10 @@
const store::Item* i0,
const store::Item* i1 )
{
- xs_decimal d = i0->getYearMonthDurationValue() / i1->getYearMonthDurationValue();
+ xs_yearMonthDuration otherYMDuration = i1->getYearMonthDurationValue();
+ if (otherYMDuration.isZero())
+ throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) );
+ xs_decimal d = i0->getYearMonthDurationValue() / otherYMDuration;
return GENV_ITEMFACTORY->createDecimal(result, d);
}
@@ -746,8 +761,10 @@
const store::Item* i0,
const store::Item* i1 )
{
- xs_decimal d = i0->getDayTimeDurationValue() / i1->getDayTimeDurationValue();
-
+ xs_dayTimeDuration otherDTDuration = i1->getDayTimeDurationValue();
+ if (otherDTDuration.isZero())
+ throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC(loc));
+ xs_decimal d = i0->getDayTimeDurationValue() / otherDTDuration;
return GENV_ITEMFACTORY->createDecimal(result, d);
}
=== modified file 'src/zorbatypes/datetime/duration.cpp'
--- src/zorbatypes/datetime/duration.cpp 2013-04-02 20:15:53 +0000
+++ src/zorbatypes/datetime/duration.cpp 2013-04-08 21:02:33 +0000
@@ -817,7 +817,9 @@
Decimal Duration::operator/(const Duration& d) const
-{
+{
+ if (d.isZero())
+ XQUERY_EXCEPTION(err::FOAR0001);
return Decimal( getTotalSeconds() ) / Decimal( d.getTotalSeconds() );
}
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-04-08 19:49:28 +0000
+++ test/fots/CMakeLists.txt 2013-04-08 21:02:33 +0000
@@ -258,7 +258,6 @@
EXPECTED_FOTS_FAILURE (fn-unparsed-text-lines fn-unparsed-text-lines-053 0)
EXPECTED_FOTS_FAILURE (fn-unparsed-text-lines fn-unparsed-text-lines-054 0)
EXPECTED_FOTS_FAILURE (math-acos math-acos-003 0)
-EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FOAR0001_9 0)
EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_13 0)
EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_14 0)
EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0085 0)
@@ -275,15 +274,6 @@
EXPECTED_FOTS_FAILURE (misc-Serialization K2-Serialization-11 0)
EXPECTED_FOTS_FAILURE (misc-XMLEdition XML10-4ed-Excluded-char-1 0)
EXPECTED_FOTS_FAILURE (misc-XMLEdition XML11-1ed-Included-char-1 0)
-EXPECTED_FOTS_FAILURE (op-add-dayTimeDurations cbcl-plus-002 0)
-EXPECTED_FOTS_FAILURE (op-add-dayTimeDurations cbcl-plus-004 0)
-EXPECTED_FOTS_FAILURE (op-add-dayTimeDurations cbcl-plus-006 0)
-EXPECTED_FOTS_FAILURE (op-add-dayTimeDurations cbcl-plus-008 0)
-EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration-by-yearMonthDuration cbcl-divide-yearMonthDuration-by-yearMonthDuration-001 0)
-EXPECTED_FOTS_FAILURE (op-subtract-dayTimeDurations cbcl-minus-002 0)
-EXPECTED_FOTS_FAILURE (op-subtract-dayTimeDurations cbcl-minus-004 0)
-EXPECTED_FOTS_FAILURE (op-subtract-dayTimeDurations cbcl-minus-006 0)
-EXPECTED_FOTS_FAILURE (op-subtract-dayTimeDurations cbcl-minus-008 0)
EXPECTED_FOTS_FAILURE (prod-AllowingEmpty outer-013 0)
EXPECTED_FOTS_FAILURE (prod-Annotation annotation-3 0)
EXPECTED_FOTS_FAILURE (prod-Annotation annotation-26 0)
Follow ups
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: noreply, 2013-04-10
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-10
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-10
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-10
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-10
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-10
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-10
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Sorin Marian Nasoi, 2013-04-10
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Sorin Marian Nasoi, 2013-04-10
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Chris Hillery, 2013-04-09
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2013-04-08
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-08
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2013-04-08