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

Proposed by Nicolae Brinza
Status: Superseded
Proposed branch: lp:~nbrinza/zorba/bugs2
Merge into: lp:zorba
Diff against target: 273 lines (+85/-30)
12 files modified
src/zorbatypes/datetime/duration.cpp (+30/-14)
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
Zorba Coders Pending
Paul J. Lucas Pending
Nicolae Brinza Pending
Review via email: mp+155767@code.launchpad.net

This proposal supersedes a proposal from 2013-03-27.

This proposal has been superseded by a proposal from 2013-03-27.

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 :
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 :

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.

lp:~nbrinza/zorba/bugs2 updated
11009. By Nicolae Brinza

Marked FOTS progressions

11010. By Nicolae Brinza

Added location and overflow value where possible for the FODT0002 error.

11011. By Nicolae Brinza

Improved the error reporting for Duration computations overflows

11012. By Nicolae Brinza

Merged with Zorba trunk

11013. By Nicolae Brinza

Updated FOTS progressions

11014. By Nicolae Brinza

date/time/durations castings now throw FODT0001 instead of FORG0001, as required by the 3.0 spec.

11015. By Nicolae Brinza

Merged with Zorba trunk

11016. By Nicolae Brinza

overflows in date/time casts now return FODT0001 and in durations return FODT0002.

11017. By Nicolae Brinza

Marked progressions and updated the Changelog

11018. By Nicolae Brinza

Merged with Zorba trunk

11019. By Nicolae Brinza

Fixed failing tests.

11020. By Nicolae Brinza

Merged with Zorba trunk

11021. By Nicolae Brinza

Marked more progressions

11022. By Nicolae Brinza

Marked more progressions

11023. By Nicolae Brinza

More datetime/duration fixes.

11024. By Nicolae Brinza

Fixed regressions

11025. By Nicolae Brinza

Merged with Zorba trunk

11026. By Nicolae Brinza

Merged with Zorba trunk

11027. By Nicolae Brinza

Added W3C bug reference in disputed bugs

11028. By Nicolae Brinza

Added DISPUTED to the tests that pend on W3C bugs

11029. By Nicolae Brinza

Merged with Zorba trunk

11030. By Nicolae Brinza

Merged with the fix_bug_1167641 branch

Unmerged revisions

11030. By Nicolae Brinza

Merged with the fix_bug_1167641 branch

11029. By Nicolae Brinza

Merged with Zorba trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/zorbatypes/datetime/duration.cpp'
2--- src/zorbatypes/datetime/duration.cpp 2013-03-11 15:00:50 +0000
3+++ src/zorbatypes/datetime/duration.cpp 2013-03-27 16:03:23 +0000
4@@ -41,6 +41,7 @@
5 0, 12, 30, 24, 60, 60, Duration::FRAC_SECONDS_UPPER_LIMIT
6 };
7
8+static const long seconds_per_year = 60 * 60 * 24 * 30 * 12;
9
10 /******************************************************************************
11 Parse a 'nS' string, with fractional seconds, returns 0 on success and a
12@@ -728,9 +729,11 @@
13 Duration* Duration::operator*(const xs_double& value) const
14 {
15 xs_double result;
16- xs_double dSeconds;
17+ xs_integer totalSeconds;
18+ int32_t years;
19 int32_t seconds;
20 int32_t frac_seconds;
21+ bool negative = false;
22
23 if (facet == DURATION_FACET)
24 {
25@@ -738,19 +741,25 @@
26 return NULL;
27 }
28
29- Integer significants = Integer(FRAC_SECONDS_UPPER_LIMIT);
30-
31 try {
32 result = getTotalSeconds() * value;
33- result = result.round(significants);
34- seconds = to_xs_int(result.floor());
35+ if (result < 0)
36+ {
37+ negative = true;
38+ result = -result;
39+ }
40+ result = result.round(Integer(FRAC_SECONDS_UPPER_LIMIT));
41+ totalSeconds = result.floor();
42 result = (result - result.floor()) * FRAC_SECONDS_UPPER_LIMIT;
43+
44+ years = to_xs_int(totalSeconds / seconds_per_year);
45+ seconds = to_xs_int(totalSeconds % seconds_per_year);
46 frac_seconds = to_xs_int(result.round());
47 } catch ( std::range_error const& ) {
48 throw XQUERY_EXCEPTION(err::FODT0002);
49 }
50
51- Duration* d = new Duration(facet, seconds<0, 0, 0, 0, 0, 0, seconds, frac_seconds);
52+ Duration* d = new Duration(facet, negative, years, 0, 0, 0, 0, seconds, frac_seconds);
53 return d;
54 }
55
56@@ -758,9 +767,11 @@
57 Duration* Duration::operator/(const xs_double& value) const
58 {
59 xs_double result;
60- xs_double dSeconds;
61+ xs_integer totalSeconds;
62+ int32_t years;
63 int32_t seconds;
64 int32_t frac_seconds;
65+ bool negative = false;
66
67 if (facet == DURATION_FACET)
68 {
69@@ -768,20 +779,25 @@
70 return NULL;
71 }
72
73- Integer significants = Integer(FRAC_SECONDS_UPPER_LIMIT);
74-
75 try {
76 result = getTotalSeconds() / value;
77- result = result.round(significants);
78- dSeconds = result.round();
79- seconds = to_xs_int(dSeconds.floor());
80- result = (result - dSeconds) * FRAC_SECONDS_UPPER_LIMIT;
81+ if (result < 0)
82+ {
83+ negative = true;
84+ result = -result;
85+ }
86+ result = result.round(Integer(FRAC_SECONDS_UPPER_LIMIT));
87+ totalSeconds = result.floor();
88+ result = (result - result.floor()) * FRAC_SECONDS_UPPER_LIMIT;
89+
90+ years = to_xs_int(totalSeconds / seconds_per_year);
91+ seconds = to_xs_int(totalSeconds % seconds_per_year);
92 frac_seconds = to_xs_int(result.round());
93 } catch ( std::range_error const& ) {
94 throw XQUERY_EXCEPTION(err::FODT0002);
95 }
96
97- Duration* d = new Duration(facet, seconds<0, 0, 0, 0, 0, 0, seconds, frac_seconds);
98+ Duration* d = new Duration(facet, negative, years, 0, 0, 0, 0, seconds, frac_seconds);
99 return d;
100 }
101
102
103=== modified file 'test/fots/CMakeLists.txt'
104--- test/fots/CMakeLists.txt 2013-03-27 09:26:16 +0000
105+++ test/fots/CMakeLists.txt 2013-03-27 16:03:23 +0000
106@@ -135,8 +135,6 @@
107 EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-003 0)
108 EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-004 0)
109 EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0)
110-EXPECTED_FOTS_FAILURE (fn-avg cbcl-avg-002 0)
111-EXPECTED_FOTS_FAILURE (fn-avg cbcl-avg-003 0)
112 EXPECTED_FOTS_FAILURE (fn-collection fn-collection-4 0)
113 EXPECTED_FOTS_FAILURE (fn-collection fn-collection-4d 0)
114 EXPECTED_FOTS_FAILURE (fn-collection fn-collection-5 0)
115@@ -165,15 +163,12 @@
116 EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0)
117 EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-006 0)
118 EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-007 0)
119-EXPECTED_FOTS_FAILURE (fn-format-date format-date-005 0)
120-EXPECTED_FOTS_FAILURE (fn-format-date format-date-006 0)
121 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en126 0)
122 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en127 0)
123 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en128 0)
124 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en132 0)
125 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en133 0)
126 EXPECTED_FOTS_FAILURE (fn-format-date format-date-en134 0)
127-EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-005 0)
128 EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-006 0)
129 EXPECTED_FOTS_FAILURE (fn-format-dateTime format-dateTime-011 0)
130 EXPECTED_FOTS_FAILURE (fn-format-integer format-integer-030 0)
131@@ -326,12 +321,8 @@
132 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-8 0)
133 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0001-9 0)
134 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-1 0)
135-EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-2 0)
136-EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-3 0)
137 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-4 0)
138 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-6 0)
139-EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-7 0)
140-EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-8 0)
141 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes FODT0002-9 0)
142 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_13 0)
143 EXPECTED_FOTS_FAILURE (misc-CombinedErrorCodes XQST0046_14 0)
144@@ -361,11 +352,9 @@
145 EXPECTED_FOTS_FAILURE (op-date-greater-than cbcl-date-le-001 0)
146 EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-ge-001 0)
147 EXPECTED_FOTS_FAILURE (op-date-less-than cbcl-date-lt-001 0)
148-EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration cbcl-divide-dayTimeDuration-003 0)
149 EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-001 0)
150 EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-002 0)
151 EXPECTED_FOTS_FAILURE (op-divide-dayTimeDuration-by-dayTimeDuration cbcl-divide-dayTimeDuration-by-dayTimeDuration-003 0)
152-EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration cbcl-divide-yearMonthDuration-003 0)
153 EXPECTED_FOTS_FAILURE (op-divide-yearMonthDuration-by-yearMonthDuration cbcl-divide-yearMonthDuration-by-yearMonthDuration-001 0)
154 EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-001 0)
155 EXPECTED_FOTS_FAILURE (op-subtract-dateTimes cbcl-subtract-dateTimes-002 0)
156
157=== renamed file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.res' => 'test/rbkt/ExpQueryResults/zorba/HigherOrder/combinator-02.xml.res'
158--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.res 2013-02-07 17:24:36 +0000
159+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/combinator-02.xml.res 2013-03-27 16:03:23 +0000
160@@ -1,1 +1,2 @@
161 <?xml version="1.0" encoding="UTF-8"?>
162+1 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
163
164=== added file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res'
165--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res 1970-01-01 00:00:00 +0000
166+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-101.xml.res 2013-03-27 16:03:23 +0000
167@@ -0,0 +1,2 @@
168+<?xml version="1.0" encoding="UTF-8"?>
169+Message: This is a test.
170
171=== added file 'test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res'
172--- test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res 1970-01-01 00:00:00 +0000
173+++ test/rbkt/ExpQueryResults/zorba/HigherOrder/hof-104.xml.res 2013-03-27 16:03:23 +0000
174@@ -0,0 +1,2 @@
175+<?xml version="1.0" encoding="UTF-8"?>
176+wbua
177
178=== added file 'test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec'
179--- test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec 1970-01-01 00:00:00 +0000
180+++ test/rbkt/Queries/zorba/HigherOrder/combinator-01.spec 2013-03-27 16:03:23 +0000
181@@ -0,0 +1,1 @@
182+Error: http://www.zorba-xquery.com/errors:ZXQP0003
183\ No newline at end of file
184
185=== added file 'test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq'
186--- test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq 1970-01-01 00:00:00 +0000
187+++ test/rbkt/Queries/zorba/HigherOrder/combinator-01.xq 2013-03-27 16:03:23 +0000
188@@ -0,0 +1,7 @@
189+(: Infinite Y combinator test -- should cause a stack overflow :)
190+
191+declare function local:Y($f) {
192+ function($a) { $f(local:Y($f), $a) }
193+};
194+
195+local:Y(function($f, $a) { $a, $f($a + 1) })(1)
196
197=== renamed file 'test/rbkt/Queries/zorba/HigherOrder/hof-101.xq' => 'test/rbkt/Queries/zorba/HigherOrder/combinator-02.xq'
198--- test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 2013-02-07 17:24:36 +0000
199+++ test/rbkt/Queries/zorba/HigherOrder/combinator-02.xq 2013-03-27 16:03:23 +0000
200@@ -1,10 +1,7 @@
201-xquery version "3.0";
202-
203-declare namespace o = "http://www.zorba-xquery.com/options/features";
204-declare option o:enable "hof";
205+(: Y combinator test :)
206
207 declare function local:Y($f) {
208 function($a) { $f(local:Y($f), $a) }
209 };
210
211-local:Y(function($f, $a) { $a, $f($a + 1) })(1)
212+local:Y(function($f, $a) { $a, if ($a < 500) then $f($a + 1) else -1 })(1)
213
214=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-101.xq'
215--- test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 1970-01-01 00:00:00 +0000
216+++ test/rbkt/Queries/zorba/HigherOrder/hof-101.xq 2013-03-27 16:03:23 +0000
217@@ -0,0 +1,27 @@
218+declare namespace an = "http://www.zorba-xquery.com/annotations";
219+
220+declare %private variable $handlers := ();
221+
222+declare %an:sequential function local:add($handler)
223+{
224+ $handlers := ($handlers, $handler);
225+};
226+
227+declare function local:emit($message)
228+{
229+ for $h in $handlers
230+ return $h($message)
231+};
232+
233+declare function local:handle($message)
234+{
235+ ("Message:", $message)
236+};
237+
238+declare %an:sequential function local:test($message)
239+{
240+ local:add(local:handle#1);
241+ local:emit($message)
242+};
243+
244+local:test("This is a test.")
245
246=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-104.xq'
247--- test/rbkt/Queries/zorba/HigherOrder/hof-104.xq 1970-01-01 00:00:00 +0000
248+++ test/rbkt/Queries/zorba/HigherOrder/hof-104.xq 2013-03-27 16:03:23 +0000
249@@ -0,0 +1,9 @@
250+(: Higher order function as a prolog variable :)
251+
252+declare variable $func := function($x){translate($x, "abcdefghijklmnopqrstuvwxyz", "nopqrstuvwxyzabcdefghijklm")};
253+
254+declare function local:scramble($x as function(xs:string) as xs:string, $y as xs:string) as xs:string {
255+ $x($y)
256+};
257+
258+local:scramble($func, "john")
259
260=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-105.spec'
261--- test/rbkt/Queries/zorba/HigherOrder/hof-105.spec 1970-01-01 00:00:00 +0000
262+++ test/rbkt/Queries/zorba/HigherOrder/hof-105.spec 2013-03-27 16:03:23 +0000
263@@ -0,0 +1,1 @@
264+Error: http://www.w3.org/2005/xqt-errors:SENR0001
265\ No newline at end of file
266
267=== added file 'test/rbkt/Queries/zorba/HigherOrder/hof-105.xq'
268--- test/rbkt/Queries/zorba/HigherOrder/hof-105.xq 1970-01-01 00:00:00 +0000
269+++ test/rbkt/Queries/zorba/HigherOrder/hof-105.xq 2013-03-27 16:03:23 +0000
270@@ -0,0 +1,3 @@
271+function($a,$b){
272+ function($a1,$b1){ $a1($b1) }
273+}(function($a2){$a2}, "test")

Subscribers

People subscribed via source and target branches