Skip to content

Commit

Permalink
Updated use of CCOpt and dune files
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Jan 15, 2022
1 parent 9ae1d61 commit 497c0de
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 61 deletions.
4 changes: 2 additions & 2 deletions debug-parse/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
)

(executable
(flags (-g -w "+a-4-9-29-37-40-42-44-48-50-32"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70-26@8" -g))
(name main)
(libraries
unix
Expand All @@ -19,4 +19,4 @@
timere
timere-parse
)
)
)
2 changes: 1 addition & 1 deletion debug/dune
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
)

(executable
(flags (-g -w "+a-4-9-29-37-40-42-44-48-50-32-26"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70-26@8" -g))
(name main)
(libraries
unix
Expand Down
4 changes: 2 additions & 2 deletions debug/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ let debug_fuzz_pattern () =
~b:
(Timedesc.Span.get_s
(snd
(CCOpt.get_exn_or
(CCOption.get_exn_or
"Expected successful retrieval of last element of list"
@@ Misc_utils.last_element_of_list search_space)))
|> OSeq.filter (fun timestamp ->
Expand All @@ -365,7 +365,7 @@ let debug_fuzz_pattern () =
search_space)
|> OSeq.filter (fun timestamp ->
let dt =
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected successful construction of date time"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz
(Timedesc.Span.make ~s:timestamp ())
Expand Down
8 changes: 4 additions & 4 deletions desc-tests/date_time_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ module Alco = struct
(Timedesc.of_iso8601 "2020-01-01T00:00:60Z"
|> CCResult.get_exn
|> Timedesc.to_rfc3339
|> CCOpt.get_exn_or "Expected successful RFC3339 construction")
|> CCOption.get_exn_or "Expected successful RFC3339 construction")

let of_iso8601_leap_second_to_rfc3339_case1 () =
Alcotest.(check string)
"same timestamp" "2020-01-01T00:00:60.12305Z"
(Timedesc.of_iso8601 "2020-01-01T00:00:60.12305Z"
|> CCResult.get_exn
|> Timedesc.to_rfc3339
|> CCOpt.get_exn_or "Expected successful RFC3339 construction")
|> CCOption.get_exn_or "Expected successful RFC3339 construction")

let of_iso8601_case0 () =
Alcotest.(check span_testable)
Expand Down Expand Up @@ -314,7 +314,7 @@ module Qc = struct
(fun (tz, timestamp) ->
let r =
Timedesc.to_timestamp_single
@@ CCOpt.get_exn_or "Expected successful construction of date time"
@@ CCOption.get_exn_or "Expected successful construction of date time"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz timestamp
in
Timedesc.Span.equal r timestamp)
Expand Down Expand Up @@ -353,7 +353,7 @@ module Qc = struct
QCheck.(pair ymd_date time)
(fun ((year, month, day), (hour, minute, second, _ns)) ->
let ptime =
CCOpt.get_exn_or "Expected successful ptime construction"
CCOption.get_exn_or "Expected successful ptime construction"
@@ Ptime.of_date_time ((year, month, day), ((hour, minute, second), 0))
in
let dt =
Expand Down
2 changes: 1 addition & 1 deletion desc-tests/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(test
(flags (-w "+a-4-9-29-40-42-44-48-32" -g))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8" -g))
(name main)
(libraries qcheck
qcheck-alcotest
Expand Down
4 changes: 2 additions & 2 deletions desc-tests/ptime_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Qc = struct
let s' =
s
|> Timedesc.Utils.ptime_span_of_span
|> CCOpt.get_exn_or
|> CCOption.get_exn_or
"Expected successful construction of Ptime.span from span"
|> Timedesc.Utils.span_of_ptime_span
in
Expand All @@ -19,7 +19,7 @@ module Qc = struct
let s' =
s
|> Timedesc.Utils.ptime_of_timestamp
|> CCOpt.get_exn_or
|> CCOption.get_exn_or
"Expected successful construction of ptime from timestamp"
|> Timedesc.Utils.timestamp_of_ptime
in
Expand Down
4 changes: 2 additions & 2 deletions desc-tests/test_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ let date_time =
~print:(fun dt ->
dt
|> Timedesc.to_string
|> CCOpt.get_exn_or
|> CCOption.get_exn_or
"Expected successful construction of string from timedesc object")
date_time_gen

Expand All @@ -492,7 +492,7 @@ let ptime_gen : Ptime.t QCheck.Gen.t =
let open QCheck.Gen in
map2
(fun (year, month, day) (hour, minute, second, _ns) ->
CCOpt.get_exn_or "Expected successful construction of ptime"
CCOption.get_exn_or "Expected successful construction of ptime"
@@ Ptime.of_date_time ((year, month, day), ((hour, minute, second), 0)))
ymd_date_gen time_gen

Expand Down
4 changes: 2 additions & 2 deletions desc-tests/time_zone_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Qc = struct
tz
|> Timedesc.Time_zone.Sexp.to_sexp
|> Timedesc.Time_zone.Sexp.of_sexp
|> CCOpt.get_exn_or
|> CCOption.get_exn_or
"Expected successful construction of time zone from sexp"
in
Timedesc.Time_zone.equal tz tz')
Expand All @@ -18,7 +18,7 @@ module Qc = struct
tz
|> Timedesc.Time_zone.JSON.to_json
|> Timedesc.Time_zone.JSON.of_json
|> CCOpt.get_exn_or
|> CCOption.get_exn_or
"Expected successful construction of time zone from JSOn"
in
Timedesc.Time_zone.equal tz tz')
Expand Down
4 changes: 2 additions & 2 deletions desc-tests/tzdb_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Alco = struct
Alcotest.(check bool)
"all tables can go through make"
(List.for_all
(fun s -> CCOpt.is_some @@ Timedesc.Time_zone.make s)
(fun s -> CCOption.is_some @@ Timedesc.Time_zone.make s)
Timedesc.Time_zone.available_time_zones)
true

Expand All @@ -20,7 +20,7 @@ module Alco = struct
let json_string = CCIO.read_all ic in
let tz_in_memory = Timedesc.Time_zone.make_exn s in
let tz_from_json =
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected to load from JSON string successfully"
@@ Timedesc.Time_zone.JSON.of_string json_string
in
Expand Down
2 changes: 1 addition & 1 deletion desc/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(action (run ../desc-tests/main.exe)))

(library
(flags (-w "+a-4-9-29-40-42-44-48@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(name timedesc)
(public_name timedesc)
(instrumentation (backend bisect_ppx))
Expand Down
2 changes: 1 addition & 1 deletion examples/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(executables
(flags (-g -w "+a-4-9-29-37-40-42-44-48-50-32"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(names dst
simple
date_time
Expand Down
2 changes: 1 addition & 1 deletion export-js-tzdb-full/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(executables
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32-30@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8" -g))
(names export export_all)
(libraries js_of_ocaml js_of_ocaml-lwt timere timedesc.tzdb.full timere-parse yojson)
(preprocess (pps js_of_ocaml-ppx lwt_ppx))
Expand Down
2 changes: 1 addition & 1 deletion export-js-tzdb-none/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)

(executables
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32-30@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8" -g))
(names export export_all)
(libraries js_of_ocaml js_of_ocaml-lwt timere timedesc.tzdb.none timere-parse)
(preprocess (pps js_of_ocaml-ppx lwt_ppx))
Expand Down
2 changes: 1 addition & 1 deletion fuzz/dune
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
)

(executables
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(names resolver_is_same_as_simple_resolver
to_of_sexp
of_sexp_string_does_not_crash
Expand Down
2 changes: 1 addition & 1 deletion fuzz/pattern_intervals_is_sound.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let () =
s1
in
let xr =
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected successful retrieval of last element of seq"
@@ Seq_utils.last_element_of_seq r
in
Expand Down
2 changes: 1 addition & 1 deletion fuzz/pattern_resolution_is_complete.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let () =
let search_start = fst (List.hd search_space) in
let search_end_exc =
snd
(CCOpt.get_exn_or
(CCOption.get_exn_or
"Expected successful retrieval of last element of list"
@@ Misc_utils.last_element_of_list search_space)
in
Expand Down
2 changes: 1 addition & 1 deletion fuzz/pattern_resolution_is_sound.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Span_set_utils
let timestamp_is_okay (tz : Timedesc.Time_zone.t) (pattern : Pattern.t)
timestamp =
let dt =
CCOpt.get_exn_or "Expected successful construction of date time"
CCOption.get_exn_or "Expected successful construction of date time"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz timestamp
in
let weekday = Timedesc.weekday dt in
Expand Down
12 changes: 6 additions & 6 deletions fuzz/simple_resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ let do_chunk_at_year_boundary tz (s : Time.Interval'.t Seq.t) :
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOpt.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "Expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOpt.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "Expected successful date time construction"
in
if Timedesc.year dt1 = Timedesc.year dt2 then fun () ->
Seq.Cons ((t1, t2), aux rest)
Expand All @@ -76,14 +76,14 @@ let do_chunk_at_month_boundary tz (s : Time.Interval'.t Seq.t) :
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOpt.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "Expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOpt.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "Expected successful date time construction"
in
if
Timedesc.year dt1 = Timedesc.year dt2
Expand Down Expand Up @@ -111,7 +111,7 @@ let do_chunk_at_month_boundary tz (s : Time.Interval'.t Seq.t) :
let aux_pattern_mem search_using_tz (pattern : Pattern.t) (timestamp : int64) :
bool =
let dt =
CCOpt.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "Expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:search_using_tz
(Timedesc.Span.make ~s:timestamp ())
in
Expand Down Expand Up @@ -254,7 +254,7 @@ let resolve ?(search_using_tz = Timedesc.Time_zone.utc)
s1
|> Seq.filter_map (fun start ->
find_after bound start s2
|> CCOpt.map (fun x ->
|> CCOption.map (fun x ->
match mode with
| `Whole_inc -> (start, Timedesc.Span.succ x)
| `Whole_exc -> (start, x)
Expand Down
2 changes: 1 addition & 1 deletion gen-build/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(executables
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32-30@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(names gen_tzdb_full
)
(libraries containers
Expand Down
2 changes: 1 addition & 1 deletion gen-build/gen_tzdb_full.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let file_output = Sys.argv.(2)
let () =
Format.printf "Generating file %s from file %s@." file_output file_input;
let db =
CCOpt.get_exn_or "Expected db to successfully load from sexp string"
CCOption.get_exn_or "Expected db to successfully load from sexp string"
@@ Timedesc.Time_zone.Db.Sexp.of_string
@@ CCIO.(with_in file_input read_all)
in
Expand Down
2 changes: 1 addition & 1 deletion gen/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

(executables
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32-30@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(names gen_time_zone_data
)
(libraries oseq
Expand Down
6 changes: 3 additions & 3 deletions gen/gen_time_zone_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ let timestamp_of_date_time_utc (x : date_time) : int64 =
let offset = 0 in
Ptime.of_date_time
((x.year, x.month, x.day), ((x.hour, x.minute, x.second), offset))
|> CCOpt.get_exn_or "Expected successful construction of ptime"
|> CCOption.get_exn_or "Expected successful construction of ptime"
|> Timedesc.Utils.timestamp_of_ptime
|> Timedesc.Span.get_s

let timestamp_of_date_time_local (x : date_time) : int64 =
let offset = 0 in
Ptime.of_date_time
((x.year, x.month, x.day), ((x.hour, x.minute, x.second), offset))
|> CCOpt.get_exn_or "Expected successful construction of ptime"
|> CCOption.get_exn_or "Expected successful construction of ptime"
|> Timedesc.Utils.timestamp_of_ptime
|> Timedesc.Span.get_s

Expand Down Expand Up @@ -406,7 +406,7 @@ let () =
{ Timedesc.Time_zone.is_dst = r.is_dst; offset = r.offset } ))
l
in
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected successful construction of time zone from transitions"
@@ Timedesc.Time_zone.Raw.of_transitions ~name transitions)
tables_utc
Expand Down
2 changes: 1 addition & 1 deletion parse/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

(library
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32-30@8"))
(flags (-w "+a-4-9-29-37-40-42-44-48-50-70@8"))
(name timere_parse)
(public_name timere-parse)
(libraries mparser
Expand Down
Loading

0 comments on commit 497c0de

Please sign in to comment.