Blame lenses/tests/test_quote.aug

Packit Service a2ae7a
(*
Packit Service a2ae7a
Module: Test_Quote
Packit Service a2ae7a
  Provides unit tests and examples for the <Quote> lens.
Packit Service a2ae7a
*)
Packit Service a2ae7a
Packit Service a2ae7a
module Test_Quote =
Packit Service a2ae7a
Packit Service a2ae7a
(* View: double *)
Packit Service a2ae7a
let double = [ label "double" . Quote.double ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: double *)
Packit Service a2ae7a
test double get "\" this is a test\"" =
Packit Service a2ae7a
  { "double" = " this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* View: double_opt *)
Packit Service a2ae7a
let double_opt = [ label "double_opt" . Quote.double_opt ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: double_opt *)
Packit Service a2ae7a
test double_opt get "\"this is a test\"" =
Packit Service a2ae7a
  { "double_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: double_opt *)
Packit Service a2ae7a
test double_opt get "this is a test" =
Packit Service a2ae7a
  { "double_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: double_opt
Packit Service a2ae7a
   Value cannot start with a space *)
Packit Service a2ae7a
test double_opt get " this is a test" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* View: single *)
Packit Service a2ae7a
let single = [ label "single" . Quote.single ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: single *)
Packit Service a2ae7a
test single get "' this is a test'" =
Packit Service a2ae7a
  { "single" = " this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* View: single_opt *)
Packit Service a2ae7a
let single_opt = [ label "single_opt" . Quote.single_opt ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: single_opt *)
Packit Service a2ae7a
test single_opt get "'this is a test'" =
Packit Service a2ae7a
  { "single_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: single_opt *)
Packit Service a2ae7a
test single_opt get "this is a test" =
Packit Service a2ae7a
  { "single_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: single_opt
Packit Service a2ae7a
   Value cannot start with a space *)
Packit Service a2ae7a
test single_opt get " this is a test" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* View: any *)
Packit Service a2ae7a
let any = [ label "any" . Quote.any ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any *)
Packit Service a2ae7a
test any get "\" this is a test\"" =
Packit Service a2ae7a
  { "any" = " this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any *)
Packit Service a2ae7a
test any get "' this is a test'" =
Packit Service a2ae7a
  { "any" = " this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* View: any_opt *)
Packit Service a2ae7a
let any_opt = [ label "any_opt" . Quote.any_opt ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any_opt *)
Packit Service a2ae7a
test any_opt get "\"this is a test\"" =
Packit Service a2ae7a
  { "any_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any_opt *)
Packit Service a2ae7a
test any_opt get "'this is a test'" =
Packit Service a2ae7a
  { "any_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any_opt *)
Packit Service a2ae7a
test any_opt get "this is a test" =
Packit Service a2ae7a
  { "any_opt" = "this is a test" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: any_opt
Packit Service a2ae7a
   Value cannot start with a space *)
Packit Service a2ae7a
test any_opt get " this is a test" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* View: double_opt_allow_spc *)
Packit Service a2ae7a
let double_opt_allow_spc =
Packit Service a2ae7a
  let body = store /[^\n"]+/ in
Packit Service a2ae7a
  [ label "double" . Quote.do_dquote_opt body ]
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: double_opt_allow_spc *)
Packit Service a2ae7a
test double_opt_allow_spc get " test with spaces " =
Packit Service a2ae7a
  { "double" = " test with spaces " }
Packit Service a2ae7a
Packit Service a2ae7a
(* Group: quote_spaces *)
Packit Service a2ae7a
Packit Service a2ae7a
(* View: quote_spaces *)
Packit Service a2ae7a
let quote_spaces =
Packit Service a2ae7a
  Quote.quote_spaces (label "spc")
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     Unquoted value *)
Packit Service a2ae7a
test quote_spaces get "this" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     double quoted value *)
Packit Service a2ae7a
test quote_spaces get "\"this\"" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     single quoted value *)
Packit Service a2ae7a
test quote_spaces get "'this'" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     unquoted value with spaces *)
Packit Service a2ae7a
test quote_spaces get "this that those" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     double quoted value with spaces *)
Packit Service a2ae7a
test quote_spaces get "\"this that those\"" =
Packit Service a2ae7a
  { "spc" = "this that those" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     single quoted value with spaces *)
Packit Service a2ae7a
test quote_spaces get "'this that those'" =
Packit Service a2ae7a
  { "spc" = "this that those" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     remove spaces from double-quoted value *)
Packit Service a2ae7a
test quote_spaces put "\"this that those\""
Packit Service a2ae7a
  after set "spc" "thisthat" =
Packit Service a2ae7a
  "\"thisthat\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     remove spaces from single-quoted value *)
Packit Service a2ae7a
test quote_spaces put "'this that those'"
Packit Service a2ae7a
  after set "spc" "thisthat" =
Packit Service a2ae7a
  "'thisthat'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     add spaces to unquoted value *)
Packit Service a2ae7a
test quote_spaces put "this"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "\"this that those\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     add spaces to double-quoted value *)
Packit Service a2ae7a
test quote_spaces put "\"this\""
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "\"this that those\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_spaces
Packit Service a2ae7a
     add spaces to single-quoted value *)
Packit Service a2ae7a
test quote_spaces put "'this'"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "'this that those'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Group: dquote_spaces *)
Packit Service a2ae7a
Packit Service a2ae7a
(* View: dquote_spaces *)
Packit Service a2ae7a
let dquote_spaces =
Packit Service a2ae7a
  Quote.dquote_spaces (label "spc")
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     Unquoted value *)
Packit Service a2ae7a
test dquote_spaces get "this" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     double quoted value *)
Packit Service a2ae7a
test dquote_spaces get "\"this\"" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     single quoted value *)
Packit Service a2ae7a
test dquote_spaces get "'this'" =
Packit Service a2ae7a
  { "spc" = "'this'" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     unquoted value with spaces *)
Packit Service a2ae7a
test dquote_spaces get "this that those" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     double quoted value with spaces *)
Packit Service a2ae7a
test dquote_spaces get "\"this that those\"" =
Packit Service a2ae7a
  { "spc" = "this that those" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     single quoted value with spaces *)
Packit Service a2ae7a
test dquote_spaces get "'this that those'" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     remove spaces from double-quoted value *)
Packit Service a2ae7a
test dquote_spaces put "\"this that those\""
Packit Service a2ae7a
  after set "spc" "thisthat" =
Packit Service a2ae7a
  "\"thisthat\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     add spaces to unquoted value *)
Packit Service a2ae7a
test dquote_spaces put "this"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "\"this that those\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     add spaces to double-quoted value *)
Packit Service a2ae7a
test dquote_spaces put "\"this\""
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "\"this that those\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_spaces
Packit Service a2ae7a
     add spaces to single-quoted value *)
Packit Service a2ae7a
test dquote_spaces put "'this'"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "\"this that those\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Group: squote_spaces *)
Packit Service a2ae7a
Packit Service a2ae7a
(* View: squote_spaces *)
Packit Service a2ae7a
let squote_spaces =
Packit Service a2ae7a
  Quote.squote_spaces (label "spc")
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     Unquoted value *)
Packit Service a2ae7a
test squote_spaces get "this" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     double quoted value *)
Packit Service a2ae7a
test squote_spaces get "\"this\"" =
Packit Service a2ae7a
  { "spc" = "\"this\"" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     single quoted value *)
Packit Service a2ae7a
test squote_spaces get "'this'" =
Packit Service a2ae7a
  { "spc" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     unquoted value with spaces *)
Packit Service a2ae7a
test squote_spaces get "this that those" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     double quoted value with spaces *)
Packit Service a2ae7a
test squote_spaces get "\"this that those\"" = *
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     single quoted value with spaces *)
Packit Service a2ae7a
test squote_spaces get "'this that those'" =
Packit Service a2ae7a
  { "spc" = "this that those" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     remove spaces from single-quoted value *)
Packit Service a2ae7a
test squote_spaces put "'this that those'"
Packit Service a2ae7a
  after set "spc" "thisthat" =
Packit Service a2ae7a
  "'thisthat'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     add spaces to unquoted value *)
Packit Service a2ae7a
test squote_spaces put "this"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "'this that those'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     add spaces to double-quoted value *)
Packit Service a2ae7a
test squote_spaces put "\"this\""
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "'this that those'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_spaces
Packit Service a2ae7a
     add spaces to single-quoted value *)
Packit Service a2ae7a
test squote_spaces put "'this'"
Packit Service a2ae7a
  after set "spc" "this that those" =
Packit Service a2ae7a
  "'this that those'"
Packit Service a2ae7a
Packit Service a2ae7a
(* Group: nil cases *)
Packit Service a2ae7a
Packit Service a2ae7a
(* View: dquote_opt_nil *)
Packit Service a2ae7a
let dquote_opt_nil =
Packit Service a2ae7a
     let body = store Quote.double_opt_re
Packit Service a2ae7a
  in [ label "dquote_opt_nil" . Quote.do_dquote_opt_nil body ]?
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil get "this" =
Packit Service a2ae7a
  { "dquote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil get "'this'" =
Packit Service a2ae7a
  { "dquote_opt_nil" = "'this'" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil get "\"this\"" =
Packit Service a2ae7a
  { "dquote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil put ""
Packit Service a2ae7a
  after set "dquote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil put "\"this\""
Packit Service a2ae7a
  after set "dquote_opt_nil" "this" =
Packit Service a2ae7a
  "\"this\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: dquote_opt_nil *)
Packit Service a2ae7a
test dquote_opt_nil put "'this'"
Packit Service a2ae7a
  after set "dquote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* View: squote_opt_nil *)
Packit Service a2ae7a
let squote_opt_nil =
Packit Service a2ae7a
     let body = store Quote.single_opt_re
Packit Service a2ae7a
  in [ label "squote_opt_nil" . Quote.do_squote_opt_nil body ]?
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil get "this" =
Packit Service a2ae7a
  { "squote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil get "'this'" =
Packit Service a2ae7a
  { "squote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil get "\"this\"" =
Packit Service a2ae7a
  { "squote_opt_nil" = "\"this\"" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil put ""
Packit Service a2ae7a
  after set "squote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil put "\"this\""
Packit Service a2ae7a
  after set "squote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: squote_opt_nil *)
Packit Service a2ae7a
test squote_opt_nil put "\"this\""
Packit Service a2ae7a
  after set "squote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* View: quote_opt_nil *)
Packit Service a2ae7a
let quote_opt_nil =
Packit Service a2ae7a
     let body = store Quote.any_opt_re
Packit Service a2ae7a
  in [ label "quote_opt_nil" . Quote.do_quote_opt_nil body ]?
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil get "this" =
Packit Service a2ae7a
  { "quote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil get "'this'" =
Packit Service a2ae7a
  { "quote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil get "\"this\"" =
Packit Service a2ae7a
  { "quote_opt_nil" = "this" }
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil put ""
Packit Service a2ae7a
  after set "quote_opt_nil" "this" =
Packit Service a2ae7a
  "this"
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil put "\"this\""
Packit Service a2ae7a
  after set "quote_opt_nil" "this" =
Packit Service a2ae7a
  "\"this\""
Packit Service a2ae7a
Packit Service a2ae7a
(* Test: quote_opt_nil *)
Packit Service a2ae7a
test quote_opt_nil put "'this'"
Packit Service a2ae7a
  after set "quote_opt_nil" "this" =
Packit Service a2ae7a
  "'this'"
Packit Service a2ae7a