xs/rules.xs

filter: Statementstmt 96.4% 27 / 28 Branchbran 88.8% 16 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 93.4% 43 / 46 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/tkz/tkz_engine.h ↑ Summary xs/data.xs »
1 # Doors onto the TZ string evaluator, for the tests only: a rule, or a
2 # whole footer, made up by the test rather than taken from a zone, so the
3 # forms no zone uses today are tested too.
4  
5 MODULE = Time::Keeper::Zone PACKAGE = Time::Keeper::Zone
6  
7 # Local seconds of a rule in a year. kind: M, J or n.
8 SV *
9 _rule_local(kind, month, week, wday, day, time, year)
10 const char *kind
11 int month
12 int week
13 int wday
14 int day
15 int time
16 SV *year
17 PREINIT:
18 tkz_rule r;
19 CODE:
20 20 ▶ r.kind = kind[0] == 'M' ? TKZ_RULE_MONTH : kind[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY;
Branch: 2 branches
BranchTrueFalseTotal
r.kind = kind[0] == 'M' ? TKZ_RULE_MONTH : kind[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY; 12 8 20
r.kind = kind[0] == 'M' ? TKZ_RULE_MONTH : kind[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY; 6 6 12
21 20 r.month = (uint8_t)month;
22 20 r.week = (uint8_t)week;
23 20 r.wday = (uint8_t)wday;
24 20 r.day = (uint16_t)day;
25 20 r.time = time;
26 20 RETVAL = tkz_newSVi64(aTHX_ tkz_rule_local(&r, tkz_sv_i64(aTHX_ year)));
27 OUTPUT:
28 RETVAL
29  
30 # A footer of the test's own, evaluated at t. Returns whether it is DST
31 # and the next change, the latter missing when there is none. start and
32 # end are [kind, month, week, wday, day, time].
33 void
34 _footer_eval(std_utoff, dst_utoff, start, end, t)
35 int std_utoff
36 int dst_utoff
37 AV *start
38 AV *end
39 SV *t
40 PREINIT:
41 tkz_footer f;
42 int64_t next;
43 uint16_t ty;
44 int k;
45 PPCODE:
46 15 Zero(&f, 1, tkz_footer);
47 15 f.std_utoff = std_utoff;
48 15 f.dst_utoff = dst_utoff;
49 15 f.std_type = 1;
50 15 f.dst_type = 2;
51 45 ▶ for (k = 0; k < 2; k++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = 0; k < 2; k++) { 30 15 45
52 30 ▶ AV *a = k ? end : start;
Branch: 1 branch
BranchTrueFalseTotal
AV *a = k ? end : start; 15 15 30
53 30 ▶ tkz_rule *r = k ? &f.end : &f.start;
Branch: 1 branch
BranchTrueFalseTotal
tkz_rule *r = k ? &f.end : &f.start; 15 15 30
54 30 const char *kd = SvPV_nolen(*av_fetch(a, 0, 0));
55 30 ▶ r->kind = kd[0] == 'M' ? TKZ_RULE_MONTH : kd[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY;
Branch: 2 branches
BranchTrueFalseTotal
r->kind = kd[0] == 'M' ? TKZ_RULE_MONTH : kd[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY; 13 17 30
r->kind = kd[0] == 'M' ? TKZ_RULE_MONTH : kd[0] == 'J' ? TKZ_RULE_JULIAN : TKZ_RULE_DAY; 8 5 13
56 30 r->month = (uint8_t)SvIV(*av_fetch(a, 1, 0));
57 30 r->week = (uint8_t)SvIV(*av_fetch(a, 2, 0));
58 30 r->wday = (uint8_t)SvIV(*av_fetch(a, 3, 0));
59 30 r->day = (uint16_t)SvIV(*av_fetch(a, 4, 0));
60 30 r->time = (int32_t)SvIV(*av_fetch(a, 5, 0));
61 }
62 15 ty = tkz_footer_at(&f, tkz_sv_i64(aTHX_ t), &next);
63 15 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 15 15
64 15 mPUSHi(ty == 2);
65 15 ▶ if (next == TKZ_NO_CHANGE)
Branch: 1 branch
BranchTrueFalseTotal
if (next == TKZ_NO_CHANGE) 0 15 15
66 0 PUSHs(&PL_sv_undef);
67 else
68 15 mPUSHs(tkz_newSVi64(aTHX_ next));
« include/tkz/tkz_engine.h ↑ Summary xs/data.xs »