diff --git a/jscomp/ext_ident.ml b/jscomp/ext_ident.ml index 15d58457f64..aab3ac1c9c6 100644 --- a/jscomp/ext_ident.ml +++ b/jscomp/ext_ident.ml @@ -224,6 +224,7 @@ let convert (name : string) = | '/' -> Buffer.add_string buffer "$slash" | '|' -> Buffer.add_string buffer "$pipe" | '.' -> Buffer.add_string buffer "$dot" + | '%' -> Buffer.add_string buffer "$percent" | 'a'..'z' | 'A'..'Z'| '_'|'$' |'0'..'9'-> Buffer.add_char buffer c | _ -> Buffer.add_string buffer "$unknown" done; Buffer.contents buffer) diff --git a/jscomp/lam_dispatch_primitive.ml b/jscomp/lam_dispatch_primitive.ml index a3a132482cd..ecb3f188e19 100644 --- a/jscomp/lam_dispatch_primitive.ml +++ b/jscomp/lam_dispatch_primitive.ml @@ -551,7 +551,9 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_float_of_string" | "caml_int_of_string" (* what is the semantics?*) | "caml_int32_of_string" - | "caml_nativeint_of_string" -> + | "caml_nativeint_of_string" + | "caml_int64_format" + -> E.runtime_call Js_config.format prim.prim_name args | "caml_format_int" -> begin match args with @@ -796,7 +798,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_weak_blit" | "caml_weak_get_copy" | "caml_sys_close" - | "caml_int64_format" + | "caml_sys_open" | "caml_ml_input" diff --git a/jscomp/lib/js.ml b/jscomp/lib/js.ml index 8c4825d1f91..30d2c9cd747 100644 --- a/jscomp/lib/js.ml +++ b/jscomp/lib/js.ml @@ -64,8 +64,15 @@ external false_ : boolean = "false" [@@js.val] external to_bool : boolean -> bool = "js_boolean_to_bool" external to_number : 'a -> int = "js_anything_to_number" (* + conversion*) -external string_of_char : char -> string = "js_string_of_char" +external string_of_char : char -> string = "js_string_of_char" +(** TODO: check with {!String.of_char} + it's quite common that we have + {[ Js.String.of_char x.[0] ]} + It would be nice to generate code as below + {[ x[0] + ]} +*) module String = struct external of_char : char -> string = "String.fromCharCode" [@@js.call] diff --git a/jscomp/runtime/.depend b/jscomp/runtime/.depend index e020be3984b..4086e5aeb73 100644 --- a/jscomp/runtime/.depend +++ b/jscomp/runtime/.depend @@ -3,7 +3,7 @@ caml_bigarray.cmi : caml_builtin_exceptions.cmi : caml_exceptions.cmi : caml_float.cmi : caml_int64.cmi -caml_format.cmi : +caml_format.cmi : caml_int64.cmi caml_int64.cmi : caml_lexer.cmi : caml_obj.cmi : @@ -25,8 +25,8 @@ caml_exceptions.cmo : caml_exceptions.cmi caml_exceptions.cmx : caml_exceptions.cmi caml_float.cmo : typed_array.cmo js.cmo caml_int64.cmi caml_float.cmi caml_float.cmx : typed_array.cmx js.cmx caml_int64.cmx caml_float.cmi -caml_format.cmo : js.cmo caml_utils.cmi caml_format.cmi -caml_format.cmx : js.cmx caml_utils.cmx caml_format.cmi +caml_format.cmo : js.cmo caml_utils.cmi caml_int64.cmi caml_format.cmi +caml_format.cmx : js.cmx caml_utils.cmx caml_int64.cmx caml_format.cmi caml_int64.cmo : js.cmo caml_int64.cmi caml_int64.cmx : js.cmx caml_int64.cmi caml_io.cmo : js.cmo @@ -63,8 +63,8 @@ caml_exceptions.cmo : caml_exceptions.cmi caml_exceptions.cmj : caml_exceptions.cmi caml_float.cmo : typed_array.cmo js.cmo caml_int64.cmi caml_float.cmi caml_float.cmj : typed_array.cmj js.cmj caml_int64.cmj caml_float.cmi -caml_format.cmo : js.cmo caml_utils.cmi caml_format.cmi -caml_format.cmj : js.cmj caml_utils.cmj caml_format.cmi +caml_format.cmo : js.cmo caml_utils.cmi caml_int64.cmi caml_format.cmi +caml_format.cmj : js.cmj caml_utils.cmj caml_int64.cmj caml_format.cmi caml_int64.cmo : js.cmo caml_int64.cmi caml_int64.cmj : js.cmj caml_int64.cmi caml_io.cmo : js.cmo diff --git a/jscomp/runtime/caml_format.js b/jscomp/runtime/caml_format.js index 6556e1fafd9..09d18598be2 100644 --- a/jscomp/runtime/caml_format.js +++ b/jscomp/runtime/caml_format.js @@ -3,7 +3,9 @@ var Caml_builtin_exceptions = require("./caml_builtin_exceptions"); var Caml_utils = require("./caml_utils"); +var Caml_int64 = require("./caml_int64"); var Caml_curry = require("./caml_curry"); +var Caml_string = require("./caml_string"); var repeat = Caml_utils.repeat; @@ -167,6 +169,18 @@ function caml_int_of_string(s) { return or_res; } +function int_of_base(param) { + switch (param) { + case 0 : + return 8; + case 1 : + return 16; + case 2 : + return 10; + + } +} + function lowercase(c) { if (c >= /* "A" */65 && c <= /* "Z" */90 || c >= /* "\192" */192 && c <= /* "\214" */214 || c >= /* "\216" */216 && c <= /* "\222" */222) { return c + 32; @@ -176,7 +190,7 @@ function lowercase(c) { } } -function _parse_format(fmt) { +function parse_format(fmt) { var len = fmt.length; if (len > 31) { throw [ @@ -189,7 +203,7 @@ function _parse_format(fmt) { "-", " ", /* false */0, - 0, + /* Ten */2, /* false */0, 0, /* false */0, @@ -214,7 +228,7 @@ function _parse_format(fmt) { else { switch (c - 88) { case 0 : - f[/* base */4] = 16; + f[/* base */4] = /* Hex */1; f[/* uppercase */7] = /* true */1; _i = i + 1; continue ; @@ -228,11 +242,11 @@ function _parse_format(fmt) { exit = 4; break; case 23 : - f[/* base */4] = 8; + f[/* base */4] = /* Oct */0; _i = i + 1; continue ; case 29 : - f[/* base */4] = 10; + f[/* base */4] = /* Ten */2; _i = i + 1; continue ; case 1 : @@ -262,7 +276,7 @@ function _parse_format(fmt) { exit = 1; break; case 32 : - f[/* base */4] = 16; + f[/* base */4] = /* Hex */1; _i = i + 1; continue ; @@ -370,7 +384,7 @@ function _parse_format(fmt) { continue ; case 4 : f[/* signedconv */5] = /* true */1; - f[/* base */4] = 10; + f[/* base */4] = /* Ten */2; _i = i + 1; continue ; case 5 : @@ -384,7 +398,7 @@ function _parse_format(fmt) { }; } -function _finish_formatting(param, rawbuffer) { +function finish_formatting(param, rawbuffer) { var justify = param[/* justify */0]; var signstyle = param[/* signstyle */1]; var filter = param[/* filter */2]; @@ -399,13 +413,15 @@ function _finish_formatting(param, rawbuffer) { ++ len; } if (alternate) { - if (base === 8) { - ++ len; + if (base) { + if (base === /* Hex */1) { + len += 2; + } + } - else if (base === 16) { - len += 2; + else { + ++ len; } - } var buffer = ""; if (justify === "+" && filter === " ") { @@ -422,10 +438,10 @@ function _finish_formatting(param, rawbuffer) { } } - if (alternate && base === 8) { + if (alternate && base === /* Oct */0) { buffer = buffer + "0"; } - if (alternate && base === 16) { + if (alternate && base === /* Hex */1) { buffer = buffer + "0x"; } if (justify === "+" && filter === "0") { @@ -447,25 +463,152 @@ function caml_format_int(fmt, i) { return "" + i; } else { - var f = _parse_format(fmt); - var i$1 = i < 0 ? ( - f[/* signedconv */5] ? (f[/* sign */8] = -1, -i) : (i >>> 0) - ) : i; - var s = i$1.toString(f[/* base */4]); - if (f[/* prec */9] >= 0) { - f[/* filter */2] = " "; - var n = f[/* prec */9] - s.length; + var f = parse_format(fmt); + var f$1 = f; + var i$1 = i; + var i$2 = i$1 < 0 ? ( + f$1[/* signedconv */5] ? (f$1[/* sign */8] = -1, -i$1) : (i$1 >>> 0) + ) : i$1; + var s = i$2.toString(int_of_base(f$1[/* base */4])); + if (f$1[/* prec */9] >= 0) { + f$1[/* filter */2] = " "; + var n = f$1[/* prec */9] - s.length; if (n > 0) { s = Caml_curry.app2(repeat, n, "0") + s; } } - return _finish_formatting(f, s); + return finish_formatting(f$1, s); + } +} + +function caml_int64_format(fmt, x) { + var f = parse_format(fmt); + var x$1 = f[/* signedconv */5] && x[/* hi */1] < 0 ? (f[/* sign */8] = -1, Caml_int64.neg(x)) : x; + var s = ""; + var match = f[/* base */4]; + switch (match) { + case 0 : + var wbase = /* record */[ + 8, + 0 + ]; + var cvtbl = "01234567"; + if (Caml_int64.lt(x$1, Caml_int64.zero)) { + debugger; + var y_000 = x$1[/* lo */0]; + var y_001 = 2147483647 & x$1[/* hi */1]; + var y = /* record */[ + y_000, + y_001 + ]; + var match$1 = Caml_int64.div_mod(y, wbase); + var quotient = Caml_int64.add(/* record */[ + 0, + 268435456 + ], match$1[0]); + var modulus = match$1[1]; + s = Caml_string.string_of_char(cvtbl.charCodeAt(modulus[/* lo */0])) + s; + while(!Caml_int64.is_zero(quotient)) { + var match$2 = Caml_int64.div_mod(quotient, wbase); + quotient = match$2[0]; + modulus = match$2[1]; + s = Caml_string.string_of_char(cvtbl.charCodeAt(modulus[/* lo */0])) + s; + }; + } + else { + var match$3 = Caml_int64.div_mod(x$1, wbase); + var quotient$1 = match$3[0]; + var modulus$1 = match$3[1]; + s = Caml_string.string_of_char(cvtbl.charCodeAt(modulus$1[/* lo */0])) + s; + while(!Caml_int64.is_zero(quotient$1)) { + var match$4 = Caml_int64.div_mod(quotient$1, wbase); + quotient$1 = match$4[0]; + modulus$1 = match$4[1]; + s = Caml_string.string_of_char(cvtbl.charCodeAt(modulus$1[/* lo */0])) + s; + }; + } + break; + case 1 : + var aux = function (v) { + return (v >>> 0).toString(16); + }; + var match$5 = x$1[/* hi */1]; + var match$6 = x$1[/* lo */0]; + var $js; + var exit = 0; + if (match$5 !== 0 || match$6 !== 0) { + exit = 1; + } + else { + $js = "0"; + } + if (exit === 1) { + $js = match$6 !== 0 ? ( + match$5 !== 0 ? aux(x$1[/* hi */1]) + aux(x$1[/* lo */0]) : aux(x$1[/* lo */0]) + ) : aux(x$1[/* hi */1]) + "00000000"; + } + s = $js + s; + break; + case 2 : + var wbase$1 = /* record */[ + 10, + 0 + ]; + var cvtbl$1 = "0123456789"; + if (Caml_int64.lt(x$1, Caml_int64.zero)) { + var y_000$1 = x$1[/* lo */0]; + var y_001$1 = 2147483647 & x$1[/* hi */1]; + var y$1 = /* record */[ + y_000$1, + y_001$1 + ]; + var match$7 = Caml_int64.div_mod(y$1, wbase$1); + var match$8 = Caml_int64.div_mod(Caml_int64.add(/* record */[ + 8, + 0 + ], match$7[1]), wbase$1); + var quotient$2 = Caml_int64.add(Caml_int64.add(/* record */[ + -858993460, + 214748364 + ], match$7[0]), match$8[0]); + var modulus$2 = match$8[1]; + s = Caml_string.string_of_char(cvtbl$1.charCodeAt(modulus$2[/* lo */0])) + s; + while(!Caml_int64.is_zero(quotient$2)) { + var match$9 = Caml_int64.div_mod(quotient$2, wbase$1); + quotient$2 = match$9[0]; + modulus$2 = match$9[1]; + s = Caml_string.string_of_char(cvtbl$1.charCodeAt(modulus$2[/* lo */0])) + s; + }; + } + else { + var match$10 = Caml_int64.div_mod(x$1, wbase$1); + var quotient$3 = match$10[0]; + var modulus$3 = match$10[1]; + s = Caml_string.string_of_char(cvtbl$1.charCodeAt(modulus$3[/* lo */0])) + s; + while(!Caml_int64.is_zero(quotient$3)) { + var match$11 = Caml_int64.div_mod(quotient$3, wbase$1); + quotient$3 = match$11[0]; + modulus$3 = match$11[1]; + s = Caml_string.string_of_char(cvtbl$1.charCodeAt(modulus$3[/* lo */0])) + s; + }; + } + break; + + } + if (f[/* prec */9] >= 0) { + f[/* filter */2] = " "; + var n = f[/* prec */9] - s.length; + if (n > 0) { + s = Caml_curry.app2(repeat, n, "0") + s; + } + } + return finish_formatting(f, s); } function caml_format_float(fmt, x) { - var f = _parse_format(fmt); + var f = parse_format(fmt); var prec = f[/* prec */9] < 0 ? 6 : f[/* prec */9]; var x$1 = x < 0 ? (f[/* sign */8] = -1, -x) : x; var s = ""; @@ -541,7 +684,7 @@ function caml_format_float(fmt, x) { s = "inf"; f[/* filter */2] = " "; } - return _finish_formatting(f, s); + return finish_formatting(f, s); } @@ -601,13 +744,12 @@ exports.caml_invalid_argument = caml_invalid_argument; exports.repeat = repeat; exports.parse_sign_and_base = parse_sign_and_base; exports.caml_failwith = caml_failwith; -exports._parse_format = _parse_format; -exports._finish_formatting = _finish_formatting; exports.caml_format_float = caml_format_float; exports.caml_format_int = caml_format_int; exports.caml_nativeint_format = caml_nativeint_format; exports.caml_int32_format = caml_int32_format; exports.caml_float_of_string = caml_float_of_string; +exports.caml_int64_format = caml_int64_format; exports.caml_int_of_string = caml_int_of_string; exports.caml_int32_of_string = caml_int32_of_string; exports.caml_nativeint_of_string = caml_nativeint_of_string; diff --git a/jscomp/runtime/caml_format.ml b/jscomp/runtime/caml_format.ml index 037f6b3601e..835ab96e967 100644 --- a/jscomp/runtime/caml_format.ml +++ b/jscomp/runtime/caml_format.ml @@ -92,12 +92,19 @@ let caml_int_of_string s = caml_failwith "int_of_string"); or_res +type base = + | Oct | Hex | Ten +let int_of_base = function + | Oct -> 8 + | Hex -> 16 + | Ten -> 10 + type fmt = { mutable justify : string; mutable signstyle : string; mutable filter : string ; mutable alternate : bool; - mutable base : int; + mutable base : base; mutable signedconv : bool; mutable width :int; mutable uppercase : bool; @@ -113,7 +120,7 @@ let lowercase c = then Char.unsafe_chr(Char.code c + 32) else c -let _parse_format fmt = +let parse_format fmt = let len = String.length fmt in if len > 31 then raise @@ Invalid_argument "format_int: format too long" ; @@ -159,20 +166,20 @@ let _parse_format fmt = | 'd' | 'i' -> f.signedconv <- true; - f.base <- 10; + f.base <- Ten; aux f (i + 1) | 'u' -> - f.base <-10; + f.base <- Ten; aux f (i + 1) | 'x' -> - f.base <- 16; + f.base <- Hex; aux f (i + 1) | 'X' -> - f.base <- 16; + f.base <- Hex; f.uppercase <- true; aux f (i + 1) | 'o' -> - f.base <- 8; + f.base <- Oct; aux f (i + 1) (* | 'O' -> base := 8; uppercase := true no uppercase for oct *) | 'e' | 'f' | 'g' @@ -193,7 +200,7 @@ let _parse_format fmt = signstyle = "-"; filter = " " ; alternate = false ; - base= 0 ; + base= Ten ; signedconv= false ; width = 0 ; uppercase= false ; @@ -203,7 +210,7 @@ let _parse_format fmt = -let _finish_formatting ({ +let finish_formatting ({ justify; signstyle; filter ; @@ -221,10 +228,10 @@ let _finish_formatting ({ incr len; if alternate then begin - if base = 8 then + if base = Oct then incr len else - if base = 16 then + if base = Hex then len := !len + 2 else () end ; @@ -243,9 +250,9 @@ let _finish_formatting ({ else if signstyle <> "-" then buffer := !buffer ^ signstyle else () ; - if alternate && base = 8 then + if alternate && base = Oct then buffer := !buffer ^ "0"; - if alternate && base == 16 then + if alternate && base == Hex then buffer := !buffer ^ "0x"; if justify = "+" && filter = "0" then @@ -268,35 +275,166 @@ let _finish_formatting ({ (** TODO: depends on ES6 polyfill [String.prototype.repeat]*) (* external duplicate : string -> int -> string = "repeat" [@@js.send] *) +let aux f i = + let i = + if i < 0 then + if f.signedconv then + begin + f.sign <- -1; + -i + end + else + i lsr 0 + else i in + let s = ref @@ Js.String.of_int i ~base:(int_of_base f.base) in + if f.prec >= 0 then + begin + f.filter <- " "; + let n = f.prec - String.length !s in + if n > 0 then + s := repeat n "0" ^ !s + end + ; + finish_formatting f !s let caml_format_int fmt i = if fmt = "%d" then string_of_int i else - let f = _parse_format fmt in - let i = - if i < 0 then - if f.signedconv then - begin - f.sign <- -1; - -i - end - else - i lsr 0 - else i in - let s = ref @@ Js.String.of_int i ~base:f.base in - if f.prec >= 0 then - begin + let f = parse_format fmt in + aux f i + +let caml_int64_format fmt (x : Caml_int64.t) = + let f = parse_format fmt in + let x = + if f.signedconv && x.hi < 0n then + begin + f.sign <- -1; + Caml_int64.neg x + end + else x in + let s = ref "" in + + begin match f.base with + | Hex -> + (* width does matter, will it be relevant to endian order? + *) + let aux v = + Js.String.of_int (Nativeint.to_int @@ Nativeint.shift_right_logical v 0) ~base:16 + in + s := (match x.hi, x.lo with + | 0n, 0n -> "0" + | _, 0n -> aux x.hi ^ "00000000" + | 0n, _ -> aux x.lo + | _, _ -> + aux x.hi ^ aux x.lo) ^ !s + | Oct -> + let wbase : Caml_int64.t = {lo = 8n; hi = 0n } in + let cvtbl = "01234567" in + + if Caml_int64.lt x Caml_int64.zero then + begin + [%js.debug]; + let y : Caml_int64.t = {x with hi = Nativeint.logand 0x7fff_ffffn x.hi } in + (* 2 ^ 63 + y `div_mod` 8 *) + let quotient_l : Caml_int64.t = + {lo = 0n; hi = 268435456n } (* 2 ^ 31 / 8 *) + (* TODO: int64 constant folding so that we can do idiomatic code + 2 ^ 63 / 10 *)in + + (* let c, d = Caml_int64.div_mod (Caml_int64.add y modulus_l) wbase in + we can not do the code above, it can overflow when y is really large + *) + let c, d = Caml_int64.div_mod y wbase in + + let quotient = + ref (Caml_int64.add quotient_l c ) in + let modulus = ref d in + s := + Js.string_of_char + cvtbl.[ Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + + while not (Caml_int64.is_zero !quotient ) do + let a, b = Caml_int64.div_mod (!quotient) wbase in + quotient := a; + modulus := b; + s := Js.string_of_char cvtbl.[Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + done; + end + else + let a, b = Caml_int64.div_mod x wbase in + let quotient = ref a in + let modulus = ref b in + s := + Js.string_of_char + cvtbl.[ Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + + while not (Caml_int64.is_zero !quotient ) do + let a, b = Caml_int64.div_mod (!quotient) wbase in + quotient := a; + modulus := b; + s := Js.string_of_char cvtbl.[Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + done + + | Ten -> + let wbase : Caml_int64.t = {lo = 10n; hi = 0n } in + let cvtbl = "0123456789" in + + if Caml_int64.lt x Caml_int64.zero then + let y : Caml_int64.t = {x with hi = Nativeint.logand 0x7fff_ffffn x.hi } in + (* 2 ^ 63 + y `div_mod` 10 *) + + let quotient_l : Caml_int64.t = + {lo = -858993460n; hi = 214748364n} + (* TODO: int64 constant folding so that we can do idiomatic code + 2 ^ 63 / 10 *)in + let modulus_l : Caml_int64.t = {lo = 8n; hi = 0n} in + (* let c, d = Caml_int64.div_mod (Caml_int64.add y modulus_l) wbase in + we can not do the code above, it can overflow when y is really large + *) + let c, d = Caml_int64.div_mod y wbase in + let e ,f = Caml_int64.div_mod (Caml_int64.add modulus_l d) wbase in + let quotient = + ref (Caml_int64.add (Caml_int64.add quotient_l c ) + e) in + let modulus = ref f in + s := + Js.string_of_char + cvtbl.[ Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + + while not (Caml_int64.is_zero !quotient ) do + let a, b = Caml_int64.div_mod (!quotient) wbase in + quotient := a; + modulus := b; + s := Js.string_of_char cvtbl.[Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + done; + + else + let a, b = Caml_int64.div_mod x wbase in + let quotient = ref a in + let modulus = ref b in + s := + Js.string_of_char + cvtbl.[ Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + + while not (Caml_int64.is_zero !quotient ) do + let a, b = Caml_int64.div_mod (!quotient) wbase in + quotient := a; + modulus := b; + s := Js.string_of_char cvtbl.[Nativeint.to_int @@ Caml_int64.to_int32 !modulus] ^ !s ; + done; + end; + if f.prec >= 0 then + begin f.filter <- " "; - let n = f.prec - String.length !s in + let n = f.prec - String.length !s in if n > 0 then - s := repeat n "0" ^ !s - end - ; - _finish_formatting f !s + s := repeat n "0" ^ !s + end; + finish_formatting f !s let caml_format_float fmt x = - let f = _parse_format fmt in + let f = parse_format fmt in let prec = if f.prec < 0 then 6 else f.prec in let x = if x < 0. then (f.sign <- (-1); -. x) else x in let s = ref "" in @@ -372,7 +510,7 @@ let caml_format_float fmt x = | _ -> () end; - _finish_formatting f !s + finish_formatting f !s [%%js.raw{| @@ -425,3 +563,4 @@ external caml_float_of_string : string -> float = "$$caml_float_of_string" let caml_int32_of_string = caml_int_of_string let caml_nativeint_of_string = caml_int32_of_string + diff --git a/jscomp/runtime/caml_format.mli b/jscomp/runtime/caml_format.mli index 16388109477..539274e95bd 100644 --- a/jscomp/runtime/caml_format.mli +++ b/jscomp/runtime/caml_format.mli @@ -26,8 +26,6 @@ val caml_failwith : string -> 'a type fmt -val _parse_format : string -> fmt -val _finish_formatting : fmt -> string -> string val caml_format_float : string -> float -> string (* val _caml_format_int : string -> int -> string *) (* *) @@ -36,7 +34,7 @@ val caml_format_int : string -> int -> string val caml_nativeint_format : string -> int -> string val caml_int32_format : string -> int -> string val caml_float_of_string : string -> float - +val caml_int64_format : string -> Caml_int64.t -> string val caml_int_of_string : string -> nativeint val caml_int32_of_string : string -> nativeint val caml_nativeint_of_string : string -> nativeint diff --git a/jscomp/runtime/caml_int64.js b/jscomp/runtime/caml_int64.js index 3329529f391..c4dd01c3064 100644 --- a/jscomp/runtime/caml_int64.js +++ b/jscomp/runtime/caml_int64.js @@ -503,6 +503,15 @@ function mod_(self, other) { return add(self, neg(y)); } +function div_mod(self, other) { + var quotient = div(self, other); + var y = mul(quotient, other); + return /* tuple */[ + quotient, + add(self, neg(y)) + ]; +} + function compare(self, other) { var v = Caml_obj.caml_nativeint_compare(self[/* hi */1], other[/* hi */1]); if (v) { @@ -513,12 +522,17 @@ function compare(self, other) { } } +function to_int32(x) { + return x[/* lo */0]; +} + exports.min_int = min_int; exports.max_int = max_int; exports.one = one; exports.zero = zero; exports.not = not; exports.of_int32 = of_int32; +exports.to_int32 = to_int32; exports.add = add; exports.neg = neg; exports.sub = sub; @@ -538,5 +552,6 @@ exports.to_float = to_float; exports.of_float = of_float; exports.div = div; exports.mod_ = mod_; +exports.div_mod = div_mod; exports.compare = compare; /* two_ptr_32_dbl Not a pure module */ diff --git a/jscomp/runtime/caml_int64.ml b/jscomp/runtime/caml_int64.ml index 6edaeb541a8..f14c6c84555 100644 --- a/jscomp/runtime/caml_int64.ml +++ b/jscomp/runtime/caml_int64.ml @@ -241,6 +241,11 @@ let to_float ({lo; hi } : t) : float = else lo + 0x1_0000_0000n in Nativeint.to_float ( hi * 0x1_0000_0000n + low_bits_unsigned) +(** {[ + u_to_float 0xffffffff_xffffffff = 2 ** 64 - 1 + ]}*) +let u_to_float x : float = + Nativeint.to_float (to_unsigned x.hi * 0x1_0000_0000n + to_unsigned x.lo ) @@ -350,6 +355,11 @@ let rec div self other = let mod_ self other = sub self (mul (div self other) other) + +let div_mod self other = + let quotient = div self other in + quotient, sub self (mul quotient other) + let compare self other = let v = Pervasives.compare self.hi other.hi in if v = 0 then @@ -357,16 +367,6 @@ let compare self other = (to_unsigned self.lo) (to_unsigned other.lo) else v -(* let rec to_string self : string = *) -(* match self with *) -(* | {lo=0n; hi = 0n} *) -(* -> *) -(* "0" *) -(* | {lo = 0n ; hi = - 0x8000_0000n} *) -(* -> *) -(* "-9223372036854775808" (\* Int64.min_int *\) *) -(* | {lo; hi} -> *) -(* if hi < 0n then "-" ^ to_string (neg self) *) -(* else *) - -(* let radixToPower = 1000000L *) + +let to_int32 x = x.lo + diff --git a/jscomp/runtime/caml_int64.mli b/jscomp/runtime/caml_int64.mli index 4fa1b2db7b0..e7c53e2bbdc 100644 --- a/jscomp/runtime/caml_int64.mli +++ b/jscomp/runtime/caml_int64.mli @@ -26,6 +26,7 @@ val one : t val zero : t val not : t -> t val of_int32 : nativeint -> t +val to_int32 : t -> nativeint val add : t -> t -> t val neg : t -> t @@ -50,4 +51,6 @@ val to_float : t -> float val of_float : float -> t val div : t -> t -> t val mod_ : t -> t -> t + +val div_mod : t -> t -> t * t val compare : t -> t -> int diff --git a/jscomp/stdlib/camlinternalFormat.js b/jscomp/stdlib/camlinternalFormat.js index 354748d7b19..475bf497ff0 100644 --- a/jscomp/stdlib/camlinternalFormat.js +++ b/jscomp/stdlib/camlinternalFormat.js @@ -10,7 +10,6 @@ var Pervasives = require("./pervasives"); var Caml_format = require("../runtime/caml_format"); var Char = require("./char"); var Sys = require("./sys"); -var Caml_primitive = require("../runtime/caml_primitive"); var CamlinternalFormatBasics = require("./camlinternalFormatBasics"); var Buffer = require("./buffer"); var $$String = require("./string"); @@ -3736,7 +3735,7 @@ function convert_nativeint(iconv, n) { } function convert_int64(iconv, n) { - return Caml_primitive.caml_int64_format(format_of_aconv(iconv, /* "L" */76), n); + return Caml_format.caml_int64_format(format_of_aconv(iconv, /* "L" */76), n); } function convert_float(fconv, prec, x) { diff --git a/jscomp/stdlib/int64.js b/jscomp/stdlib/int64.js index f7e6c6c2031..3b88508a0b8 100644 --- a/jscomp/stdlib/int64.js +++ b/jscomp/stdlib/int64.js @@ -1,8 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_int64 = require("../runtime/caml_int64"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_int64 = require("../runtime/caml_int64"); +var Caml_format = require("../runtime/caml_format"); function succ(n) { return Caml_int64.add(n, /* int64 */[ @@ -38,7 +38,7 @@ function lognot(n) { } function to_string(n) { - return Caml_primitive.caml_int64_format("%d", n); + return Caml_format.caml_int64_format("%d", n); } function compare(x, y) { diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 5666bf54980..e0049210711 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -58,10 +58,10 @@ buffer_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/bytes.cmx \ ../stdlib/buffer.cmx caml_compare_test.cmo : mt.cmi caml_compare_test.cmx : mt.cmx -caml_format_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi \ - ../stdlib/array.cmi -caml_format_test.cmx : ../stdlib/printf.cmx mt.cmx ../stdlib/format.cmx \ - ../stdlib/array.cmx +caml_format_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/int64.cmi \ + ../stdlib/format.cmi ../stdlib/array.cmi +caml_format_test.cmx : ../stdlib/printf.cmx mt.cmx ../stdlib/int64.cmx \ + ../stdlib/format.cmx ../stdlib/array.cmx class_type_ffi_test.cmo : ../lib/js.cmo class_type_ffi_test.cmx : ../lib/js.cmx complex_if_test.cmo : mt.cmi ../stdlib/bytes.cmi @@ -142,6 +142,10 @@ google_closure_test.cmo : test_google_closure.cmo mt.cmi google_closure_test.cmx : test_google_closure.cmx mt.cmx guide_for_ext.cmo : guide_for_ext.cmx : +hamming_test.cmo : ../stdlib/printf.cmi ../stdlib/lazy.cmi \ + ../stdlib/int64.cmi +hamming_test.cmx : ../stdlib/printf.cmx ../stdlib/lazy.cmx \ + ../stdlib/int64.cmx hashtbl_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ ../stdlib/array.cmi hashtbl_test.cmx : mt.cmx ../stdlib/list.cmx ../stdlib/hashtbl.cmx \ @@ -276,6 +280,8 @@ string_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/list.cmi \ ext_string.cmo ../stdlib/bytes.cmi string_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/list.cmx \ ext_string.cmx ../stdlib/bytes.cmx +stringmatch_test.cmo : ../stdlib/string.cmi +stringmatch_test.cmx : ../stdlib/string.cmx swap_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/int64.cmi ../stdlib/int32.cmi ../stdlib/format.cmi \ ../stdlib/array.cmi @@ -532,10 +538,10 @@ buffer_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/bytes.cmj \ ../stdlib/buffer.cmj caml_compare_test.cmo : mt.cmi caml_compare_test.cmj : mt.cmj -caml_format_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi \ - ../stdlib/array.cmi -caml_format_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/format.cmj \ - ../stdlib/array.cmj +caml_format_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/int64.cmi \ + ../stdlib/format.cmi ../stdlib/array.cmi +caml_format_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/int64.cmj \ + ../stdlib/format.cmj ../stdlib/array.cmj class_type_ffi_test.cmo : ../lib/js.cmo class_type_ffi_test.cmj : ../lib/js.cmj complex_if_test.cmo : mt.cmi ../stdlib/bytes.cmi @@ -616,6 +622,10 @@ google_closure_test.cmo : test_google_closure.cmo mt.cmi google_closure_test.cmj : test_google_closure.cmj mt.cmj guide_for_ext.cmo : guide_for_ext.cmj : +hamming_test.cmo : ../stdlib/printf.cmi ../stdlib/lazy.cmi \ + ../stdlib/int64.cmi +hamming_test.cmj : ../stdlib/printf.cmj ../stdlib/lazy.cmj \ + ../stdlib/int64.cmj hashtbl_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ ../stdlib/array.cmi hashtbl_test.cmj : mt.cmj ../stdlib/list.cmj ../stdlib/hashtbl.cmj \ @@ -750,6 +760,8 @@ string_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/list.cmi \ ext_string.cmo ../stdlib/bytes.cmi string_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/list.cmj \ ext_string.cmj ../stdlib/bytes.cmj +stringmatch_test.cmo : ../stdlib/string.cmi +stringmatch_test.cmj : ../stdlib/string.cmj swap_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/int64.cmi ../stdlib/int32.cmi ../stdlib/format.cmi \ ../stdlib/array.cmi diff --git a/jscomp/test/caml_format_test.js b/jscomp/test/caml_format_test.js index 31c309b4881..d4504067194 100644 --- a/jscomp/test/caml_format_test.js +++ b/jscomp/test/caml_format_test.js @@ -1,12 +1,14 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_int64 = require("../runtime/caml_int64"); var Caml_obj = require("../runtime/caml_obj"); var Caml_float = require("../runtime/caml_float"); var Pervasives = require("../stdlib/pervasives"); var Caml_format = require("../runtime/caml_format"); var Mt = require("./mt"); var Printf = require("../stdlib/printf"); +var Int64 = require("../stdlib/int64"); var $$Array = require("../stdlib/array"); var Caml_curry = require("../runtime/caml_curry"); var Format = require("../stdlib/format"); @@ -2385,45 +2387,716 @@ var ksprintf_suites = /* :: */[ ksprintf_suites_001 ]; -Mt.from_pair_suites("caml_format_test.ml", Pervasives.$at(suites, Pervasives.$at(formatter_suites, Pervasives.$at(from_lambda_pairs(lambda_suites), Pervasives.$at(ksprintf_suites, $$Array.to_list($$Array.mapi(function (i, param) { - var str_result = param[2]; - var f = param[1]; - var fmt = param[0]; - return /* tuple */[ - Caml_curry.app1(Printf.sprintf(/* Format */{ - 0: /* String_literal */{ - 0: "float_format ", - 1: /* Int */{ - 0: /* Int_d */0, +var a$1 = Format.asprintf; + +var int64_suites_000 = /* tuple */[ + "i32_simple", + function () { + return /* Eq */{ + 0: Caml_curry.app1(Format.asprintf(/* Format */{ + 0: /* Nativeint */{ + 0: /* Int_x */6, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 6 + }, + 1: "%nx", + length: 2, + tag: 0 + }), 4294967295), + 1: "ffffffff", + length: 2, + tag: 0 + }; + } +]; + +var int64_suites_001 = /* :: */[ + /* tuple */[ + "i32_simple1", + function () { + return /* Eq */{ + 0: Caml_curry.app1(Format.asprintf(/* Format */{ + 0: /* Nativeint */{ + 0: /* Int_o */10, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 6 + }, + 1: "%no", + length: 2, + tag: 0 + }), 4294967295), + 1: "37777777777", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple", + function () { + return /* Eq */{ + 0: Caml_curry.app1(Format.asprintf(/* Format */{ + 0: /* Int64 */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Ld", + length: 2, + tag: 0 + }), /* int64 */[ + 3, + 0 + ]), + 1: "3", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple2", + function () { + return /* Eq */{ + 0: Caml_curry.app1(Format.asprintf(/* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lx", + length: 2, + tag: 0 + }), /* int64 */[ + 33, + 0 + ]), + 1: "21", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple3", + function () { + return /* Eq */{ + 0: Caml_curry.app1(Format.asprintf(/* Format */{ + 0: /* Int64 */{ + 0: /* Int_i */3, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Li", + length: 2, + tag: 0 + }), /* int64 */[ + 33, + 0 + ]), + 1: "33", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple4", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_X */8, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%LX", + length: 2, + tag: 0 + }, /* int64 */[ + 44, + 0 + ]), + 1: "2C", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple5", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lx", + length: 2, + tag: 0 + }, /* int64 */[ + 44, + 0 + ]), + 1: "2c", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple6", + function () { + return /* Eq */{ + 0: Caml_curry.app3(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* Arg_padding */{ + 0: /* Right */1, + length: 1, + tag: 1 + }, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%*Lx", + length: 2, + tag: 0 + }, 5, /* int64 */[ + 44, + 0 + ]), + 1: " 2c", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple7", + function () { + return /* Eq */{ + 0: Caml_format.caml_int64_format("%d", /* int64 */[ + 3333, + 0 + ]), + 1: "3333", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple8", + function () { + return /* Eq */{ + 0: Caml_curry.app3(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Int64 */{ + 0: /* Int_d */0, + 1: /* Lit_padding */{ + 0: /* Zeros */2, + 1: 18, + length: 2, + tag: 0 + }, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + length: 4, + tag: 7 + }, + 1: "%Ld%018Ld", + length: 2, + tag: 0 + }, /* int64 */[ + 3, + 0 + ], /* int64 */[ + 3, + 0 + ]), + 1: "3000000000000000003", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple9", + function () { + return /* Eq */{ + 0: Caml_curry.app3(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Int64 */{ + 0: /* Int_d */0, + 1: /* Lit_padding */{ + 0: /* Zeros */2, + 1: 18, + length: 2, + tag: 0 + }, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + length: 4, + tag: 7 + }, + 1: "%Ld%018Ld", + length: 2, + tag: 0 + }, /* int64 */[ + 1548746752, + 107288 + ], /* int64 */[ + 0, + 0 + ]), + 1: "460800000000000000000000000000000", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple10", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lx", + length: 2, + tag: 0 + }, Int64.max_int), + 1: "7fffffffffffffff", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple15", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Ld", + length: 2, + tag: 0 + }, /* int64 */[ + -1, + -1 + ]), + 1: "-1", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple16", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Ld", + length: 2, + tag: 0 + }, /* int64 */[ + -11111, + -1 + ]), + 1: "-11111", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple14", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_X */8, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%LX", + length: 2, + tag: 0 + }, /* int64 */[ + -1, + -1 + ]), + 1: "FFFFFFFFFFFFFFFF", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple17", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lx", + length: 2, + tag: 0 + }, /* int64 */[ + -1, + -1 + ]), + 1: "ffffffffffffffff", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple11", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_X */8, 1: /* No_padding */0, 2: /* No_precision */0, 3: /* End_of_format */0, length: 4, - tag: 4 + tag: 7 }, + 1: "%LX", length: 2, - tag: 11 - }, - 1: "float_format %d", - length: 2, - tag: 0 - }), i), + tag: 0 + }, Int64.max_int), + 1: "7FFFFFFFFFFFFFFF", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple12", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_X */8, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%LX", + length: 2, + tag: 0 + }, Int64.min_int), + 1: "8000000000000000", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple17", function () { return /* Eq */{ - 0: Caml_format.caml_format_float(fmt, f), - 1: str_result, + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_u */12, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lu", + length: 2, + tag: 0 + }, /* int64 */[ + -1, + -1 + ]), + 1: "18446744073709551615", length: 2, tag: 0 }; } - ]; - }, float_data))))))); + ], + /* :: */[ + /* tuple */[ + "i64_simple21", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_u */12, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lu", + length: 2, + tag: 0 + }, /* int64 */[ + -10000, + -1 + ]), + 1: "18446744073709541616", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple19", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_o */10, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%Lo", + length: 2, + tag: 0 + }, Int64.min_int), + 1: "1000000000000000000000", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple13", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_X */8, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%LX", + length: 2, + tag: 0 + }, Caml_int64.add(Int64.min_int, /* int64 */[ + 1, + 0 + ])), + 1: "8000000000000001", + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "i64_simple20", + function () { + return /* Eq */{ + 0: Caml_curry.app2(a$1, /* Format */{ + 0: /* Int64 */{ + 0: /* Int_x */6, + 1: /* Lit_padding */{ + 0: /* Right */1, + 1: 12, + length: 2, + tag: 0 + }, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 7 + }, + 1: "%12Lx", + length: 2, + tag: 0 + }, /* int64 */[ + 3, + 0 + ]), + 1: " 3", + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] +]; + +var int64_suites = /* :: */[ + int64_suites_000, + int64_suites_001 +]; + +Mt.from_pair_suites("caml_format_test.ml", Pervasives.$at(suites, Pervasives.$at(formatter_suites, Pervasives.$at(from_lambda_pairs(lambda_suites), Pervasives.$at(ksprintf_suites, Pervasives.$at($$Array.to_list($$Array.mapi(function (i, param) { + var str_result = param[2]; + var f = param[1]; + var fmt = param[0]; + return /* tuple */[ + Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "float_format ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "float_format %d", + length: 2, + tag: 0 + }), i), + function () { + return /* Eq */{ + 0: Caml_format.caml_format_float(fmt, f), + 1: str_result, + length: 2, + tag: 0 + }; + } + ]; + }, float_data)), int64_suites)))))); var float_suites = /* :: */[ "float_nan", /* [] */0 ]; +var hh = /* int64 */[ + -858993460, + 214748364 +]; + +var hhh = /* int64 */[ + 0, + 268435456 +]; + exports.of_string = of_string; exports.from_float_of_string = from_float_of_string; exports.from_of_string = from_of_string; @@ -2440,4 +3113,7 @@ exports.Lambda_suites = Lambda_suites; exports.lambda_suites = lambda_suites; exports.from_lambda_pairs = from_lambda_pairs; exports.ksprintf_suites = ksprintf_suites; +exports.int64_suites = int64_suites; +exports.hh = hh; +exports.hhh = hhh; /* v Not a pure module */ diff --git a/jscomp/test/caml_format_test.ml b/jscomp/test/caml_format_test.ml index 363e03b3805..cab21d1e41b 100644 --- a/jscomp/test/caml_format_test.ml +++ b/jscomp/test/caml_format_test.ml @@ -175,13 +175,67 @@ let ksprintf_suites = Mt.[ (* module Mt = Mock_mt *) -let () = +let int64_suites = + let a = Format.asprintf in + Mt.[ + + + "i32_simple", (fun _ -> Eq(Format.asprintf "%nx" 0xffff_ffffn, "ffffffff")) ; + "i32_simple1", (fun _ -> Eq(Format.asprintf "%no" 0xffff_ffffn, "37777777777")); + "i64_simple", (fun _ -> Eq( Format.asprintf "%Ld" 3L, "3")); + "i64_simple2", (fun _ -> Eq( Format.asprintf "%Lx" 33L, "21")); + "i64_simple3", (fun _ -> Eq( Format.asprintf "%Li" 33L, "33")); + "i64_simple4", (fun _ -> Eq(a "%LX" 44L, "2C")); + "i64_simple5", (fun _ -> Eq(a "%Lx" 44L, "2c")); + "i64_simple6", (fun _ -> Eq(a "%*Lx" 5 44L, " 2c")); + "i64_simple7", (fun _ -> Eq(Int64.to_string 3333L, "3333")); + "i64_simple8", (fun _ -> Eq( a "%Ld%018Ld" 3L 3L, "3000000000000000003")); + "i64_simple9", (fun _ -> Eq( a "%Ld%018Ld" 460800000000000L 0L, + "460800000000000000000000000000000")); + "i64_simple10", (fun _ -> Eq( a "%Lx" Int64.max_int,"7fffffffffffffff" + )); + "i64_simple15", (fun _ -> + Eq( a "%Ld" (-1L), "-1")); + "i64_simple16", (fun _ -> + Eq( a "%Ld" (-11111L), "-11111")); + "i64_simple14", (fun _ -> + Eq( a "%LX" (-1L), + + "FFFFFFFFFFFFFFFF" + )); + "i64_simple17", (fun _ -> + Eq( a "%Lx" (-1L), + + "ffffffffffffffff" + )); + + "i64_simple11", (fun _ -> Eq( a "%LX" Int64.max_int,"7FFFFFFFFFFFFFFF" + )); + "i64_simple12", (fun _ -> Eq( a "%LX" Int64.min_int, "8000000000000000")); + "i64_simple17", (fun _ -> + + Eq(a "%Lu" (-1L), "18446744073709551615") + ); + "i64_simple21", (fun _ -> Eq(a "%Lu" (-10000L), "18446744073709541616")); + "i64_simple19", (fun _ -> Eq(a "%Lo" Int64.min_int , "1000000000000000000000") ); + "i64_simple13", (fun _ -> Eq( a "%LX" Int64.(add min_int 1L), + "8000000000000001")); + + "i64_simple20", (fun _ -> Eq(a "%12Lx" 3L, " 3")) + ] + +let hh = 922337203685477580L (* 2 ^ 63 / 10 *) +let hhh = 1152921504606846976L +(* module Mt = Mock_mt *) +let () = Mt.from_pair_suites __FILE__ @@ suites @ formatter_suites @ from_lambda_pairs lambda_suites @ ksprintf_suites @ - (Array.mapi (fun i (fmt, f,str_result) -> (Printf.sprintf "float_format %d" i ) , (fun _ -> Mt.Eq(format_float fmt f, str_result))) float_data |> Array.to_list) + (Array.mapi (fun i (fmt, f,str_result) -> (Printf.sprintf "float_format %d" i ) , (fun _ -> Mt.Eq(format_float fmt f, str_result))) float_data |> Array.to_list) @ + + int64_suites diff --git a/jscomp/test/hamming_test.ml b/jscomp/test/hamming_test.ml new file mode 100644 index 00000000000..df24fe3b310 --- /dev/null +++ b/jscomp/test/hamming_test.ml @@ -0,0 +1,111 @@ +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* We cannot use bignums because we don't do custom runtimes, but + int64 is a bit short, so we roll our own 37-digit numbers... +*) + +let n0 = Int64.of_int 0;; +let n1 = Int64.of_int 1;; +let n2 = Int64.of_int 2;; +let n3 = Int64.of_int 3;; +let n5 = Int64.of_int 5;; + +let ( % ) = Int64.rem;; +let ( * ) = Int64.mul;; +let ( / ) = Int64.div;; +let ( + ) = Int64.add;; +let digit = 1000000000000000000L(* Int64.of_string "1000000000000000000" *);; + +let mul n (pl, ph) = ((n * pl) % digit, n * ph + (n * pl) / digit);; +let cmp (nl, nh) (pl, ph) = + if nh < ph then -1 + else if nh > ph then 1 + else if nl < pl then -1 + else if nl > pl then 1 + else 0 +;; + +let x2 = fun p -> mul n2 p;; +let x3 = fun p -> mul n3 p;; +let x5 = fun p -> mul n5 p;; + +let nn1 = (n1, n0);; + +let pr (nl, nh) = + (* if compare nh n0 = 0 *) + (* then Printf.printf "%Ld\n" nl *) + (* else *) + Printf.printf "%Ld%018Ld\n" nh nl + +(* let pr = Js.log *) +(* let pr (nl, nh) = *) +(* [%js.debug]; *) +(* if compare nh n0 = 0 *) +(* then Js.log @@ Format.asprintf "%Ld" nl *) +(* else Js.log @@ Format.asprintf "%Ld%018Ld" nh nl *) +(* ;; *) + +(* + (* bignum version *) +open Num;; +let nn1 = num_of_int 1;; +let x2 = fun p -> (num_of_int 2) */ p;; +let x3 = fun p -> (num_of_int 3) */ p;; +let x5 = fun p -> (num_of_int 5) */ p;; +let cmp n p = sign_num (n -/ p);; +let pr n = Printf.printf "%s\n" (string_of_num n);; +*) + + +(* This is where the interesting stuff begins. *) + +open Lazy;; + +type 'a lcons = Cons of 'a * 'a lcons Lazy.t;; +type 'a llist = 'a lcons Lazy.t;; + +let rec map f l = + lazy ( + match force l with + | Cons (x, ll) -> Cons (f x, map f ll) + ) +;; + +let rec merge cmp l1 l2 = + lazy ( + match force l1, force l2 with + | Cons (x1, ll1), Cons (x2, ll2) + -> let c = cmp x1 x2 in + if c = 0 + then Cons (x1, merge cmp ll1 ll2) + else if c < 0 + then Cons (x1, merge cmp ll1 l2) + else Cons (x2, merge cmp l1 ll2) + ) +;; + +let rec iter_interval f l (start, stop) = + if stop = 0 then () + else match force l with + | Cons (x, ll) + -> if start <= 0 then f x; + iter_interval f ll (start-1, stop-1) +;; + +let rec hamming = lazy (Cons (nn1, merge cmp ham2 (merge cmp ham3 ham5))) + and ham2 = lazy (force (map x2 hamming)) + and ham3 = lazy (force (map x3 hamming)) + and ham5 = lazy (force (map x5 hamming)) +;; + +iter_interval pr hamming (88000, 88100);; diff --git a/jscomp/test/int64_mul_div_test.js b/jscomp/test/int64_mul_div_test.js index 03df3d7edaa..fcb0371f916 100644 --- a/jscomp/test/int64_mul_div_test.js +++ b/jscomp/test/int64_mul_div_test.js @@ -1,15 +1,15 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_int64 = require("../runtime/caml_int64"); -var Caml_obj = require("../runtime/caml_obj"); -var Pervasives = require("../stdlib/pervasives"); -var Mt = require("./mt"); -var Printf = require("../stdlib/printf"); -var Caml_primitive = require("../runtime/caml_primitive"); -var $$Array = require("../stdlib/array"); -var Caml_curry = require("../runtime/caml_curry"); -var List = require("../stdlib/list"); +var Caml_int64 = require("../runtime/caml_int64"); +var Caml_obj = require("../runtime/caml_obj"); +var Pervasives = require("../stdlib/pervasives"); +var Caml_format = require("../runtime/caml_format"); +var Mt = require("./mt"); +var Printf = require("../stdlib/printf"); +var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); +var List = require("../stdlib/list"); function commutative_mul(result, a, b) { return /* Eq */{ @@ -1785,7 +1785,7 @@ function from_to_string(xs) { function () { return /* Eq */{ 0: str_a, - 1: Caml_primitive.caml_int64_format("%d", a), + 1: Caml_format.caml_int64_format("%d", a), length: 2, tag: 0 }; @@ -1871,7 +1871,51 @@ Mt.from_pair_suites("int64_mul_div_test.ml", Pervasives.$at(from_pairs("random", } ], /* [] */0 - ], Pervasives.$at(from(simple_divs), from_compare(int64_compare_tests)))))))); + ], Pervasives.$at(from(simple_divs), Pervasives.$at(from_compare(int64_compare_tests), /* :: */[ + /* tuple */[ + "div_rem_0", + function () { + return /* Eq */{ + 0: Caml_int64.div(/* int64 */[ + -1, + -1 + ], /* int64 */[ + 16, + 0 + ]), + 1: /* int64 */[ + 0, + 0 + ], + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "div_rem_1", + function () { + return /* Eq */{ + 0: Caml_int64.mod_(/* int64 */[ + -1, + -1 + ], /* int64 */[ + 16, + 0 + ]), + 1: /* int64 */[ + -1, + -1 + ], + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] + ])))))))); exports.commutative_mul = commutative_mul; exports.pairs = pairs; diff --git a/jscomp/test/int64_mul_div_test.ml b/jscomp/test/int64_mul_div_test.ml index b40bd75d2ee..5e7cc20e97a 100644 --- a/jscomp/test/int64_mul_div_test.ml +++ b/jscomp/test/int64_mul_div_test.ml @@ -207,4 +207,7 @@ let from_to_string xs = ] @ from simple_divs @ from_compare int64_compare_tests - + @ [ + "div_rem_0", (fun _ -> Eq(Int64.div (-1L) 16L,0L)); + "div_rem_1", (fun _ -> Eq(Int64.rem (-1L) 16L,-1L)); + ] diff --git a/jscomp/test/int64_test.js b/jscomp/test/int64_test.js index e717b1f5544..c446b0688f7 100644 --- a/jscomp/test/int64_test.js +++ b/jscomp/test/int64_test.js @@ -1228,7 +1228,43 @@ var suites_001 = /* :: */[ }; } ], - /* [] */0 + /* :: */[ + /* tuple */[ + "of_int32", + function () { + return /* Eq */{ + 0: $$Array.map(function (prim) { + return Caml_int64.of_int32(prim); + }, /* array */[0]), + 1: /* array */[/* int64 */[ + 0, + 0 + ]], + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "to_int32", + function () { + return /* Eq */{ + 0: $$Array.map(function (prim) { + return prim[0]; + }, /* array */[/* int64 */[ + 0, + 0 + ]]), + 1: /* array */[0], + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] + ] ] ] ] diff --git a/jscomp/test/int64_test.ml b/jscomp/test/int64_test.ml index 56aa755604f..7837303b568 100644 --- a/jscomp/test/int64_test.ml +++ b/jscomp/test/int64_test.ml @@ -71,7 +71,9 @@ let suites = Mt.[ -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L; -1L|] )); - "mul simple", (fun _ -> Eq (6L, mul 3L 2L )) + "mul simple", (fun _ -> Eq (6L, mul 3L 2L )); + "of_int32", (fun _ -> Eq(Array.map Int64.of_int32 [|0l|], [|0L|])); + "to_int32", (fun _ -> Eq(Array.map Int64.to_int32 [|0L|], [|0l|])); ] diff --git a/jscomp/test/lazy_test.js b/jscomp/test/lazy_test.js index b1fc480ca9d..a0b79993c32 100644 --- a/jscomp/test/lazy_test.js +++ b/jscomp/test/lazy_test.js @@ -1,8 +1,9 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var CamlinternalLazy = require("../stdlib/camlinternalLazy"); -var Mt = require("./mt"); +var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var CamlinternalLazy = require("../stdlib/camlinternalLazy"); +var Mt = require("./mt"); var u = [3]; @@ -33,6 +34,100 @@ function lazy_test() { ]; } +function f(param) { + var match = param[0]; + var tag = match.tag | 0; + if (tag !== 250) { + if (tag === 246) { + CamlinternalLazy.force_lazy_block(match); + } + else { + ; + } + } + var match$1 = param[2][/* contents */0]; + if (match$1) { + var match$2 = param[1]; + var tag$1 = match$2.tag | 0; + if (tag$1 !== 250) { + if (tag$1 === 246) { + CamlinternalLazy.force_lazy_block(match$2); + } + else { + ; + } + } + var match$3 = param[2][/* contents */0]; + if (match$3) { + return 1; + } + else { + throw [ + Caml_builtin_exceptions.match_failure, + [ + "lazy_test.ml", + 11, + 8 + ] + ]; + } + } + else { + return 0; + } +} + +var s = [/* None */0]; + +var set_true = { + 0: function () { + s[0] = /* Some */[1]; + return /* () */0; + }, + length: 1, + tag: 246 +}; + +var set_false = { + 0: function () { + s[0] = /* None */0; + return /* () */0; + }, + length: 1, + tag: 246 +}; + +var h; + +try { + h = f(/* tuple */[ + set_true, + set_false, + s + ]); +} +catch (exn){ + if (exn[0] === Caml_builtin_exceptions.match_failure) { + h = 2; + } + else { + throw exn; + } +} + +function exotic(param) { + var tag = param.tag | 0; + if (tag === 250) { + return param[0]; + } + else if (tag === 246) { + return CamlinternalLazy.force_lazy_block(param); + } + else { + return param; + } +} + Mt.from_pair_suites("lazy_test.ml", /* :: */[ /* tuple */[ "simple", @@ -48,10 +143,29 @@ Mt.from_pair_suites("lazy_test.ml", /* :: */[ }; } ], - /* [] */0 + /* :: */[ + /* tuple */[ + "lazy_match", + function () { + return /* Eq */{ + 0: h, + 1: 2, + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] ]); exports.u = u; exports.v = v; exports.lazy_test = lazy_test; -/* Not a pure module */ +exports.f = f; +exports.s = s; +exports.set_true = set_true; +exports.set_false = set_false; +exports.h = h; +exports.exotic = exotic; +/* h Not a pure module */ diff --git a/jscomp/test/lazy_test.ml b/jscomp/test/lazy_test.ml index 0594d915ce4..971e0f18fae 100644 --- a/jscomp/test/lazy_test.ml +++ b/jscomp/test/lazy_test.ml @@ -8,15 +8,34 @@ let lazy_test () = let g = (Lazy.force v ; !u) in h,g +let f = function + | lazy (), _, {contents=None} -> 0 + | _, lazy (), {contents=Some x} -> 1 + +(* PR #5992 *) +(* Was segfaulting *) +let s = ref None +let set_true = lazy (s := Some 1) +let set_false = lazy (s := None) + +let h = + try f (set_true, set_false, s) with Match_failure _ -> 2 + (** this is broken due to [%obj_field] and [%obj_set_field] is translated into [%array_unsafe_get] which does not fit our purpose http://caml.inria.fr/mantis/view.php?id=7020 *) +(* module Mt = Mock_mt *) + +let exotic = (* Lazy in a pattern. (used in advi) *) +function lazy y -> y + ;; Mt.from_pair_suites __FILE__ Mt.[ "simple", (fun _ -> Eq ((lazy_test ()) ,(3, 32)) - ) + ); +"lazy_match", (fun _ -> Eq(h, 2)) ] diff --git a/jscomp/test/stringmatch_test.js b/jscomp/test/stringmatch_test.js new file mode 100644 index 00000000000..b051dbc63f0 --- /dev/null +++ b/jscomp/test/stringmatch_test.js @@ -0,0 +1,4022 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); + +function tst01(s) { + if (s === "") { + return 0; + } + else { + return 1; + } +} + +if (tst01("") !== 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 20, + 2 + ] + ]; +} + +if (tst01("\0\0\0\x03") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 21, + 2 + ] + ]; +} + +if (tst01("\0\0\0\0\0\0\0\x07") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 22, + 2 + ] + ]; +} + +function tst02(s) { + var len = s.length; + if (s === "") { + if (len < 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 30, + 23 + ] + ]; + } + else { + return 1; + } + } + else if (len) { + if (s === "A") { + return 2; + } + else { + return 3; + } + } + else { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 32, + 22 + ] + ]; + } +} + +if (tst02("") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 37, + 2 + ] + ]; +} + +if (tst02("A") !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 38, + 2 + ] + ]; +} + +if (tst02("B") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 39, + 2 + ] + ]; +} + +if (tst02("\0\0\0\0\0\0\0\x07") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 40, + 2 + ] + ]; +} + +if (tst02("\0\0\0\x03") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 41, + 2 + ] + ]; +} + +function tst03(s) { + switch (s) { + case "app_const" : + return 5; + case "app_const_const" : + return 9; + case "app_const_env" : + return 11; + case "app_const_meth" : + return 12; + case "app_const_var" : + return 10; + case "app_env" : + return 7; + case "app_env_const" : + return 14; + case "app_meth" : + return 8; + case "app_meth_const" : + return 15; + case "app_var" : + return 6; + case "app_var_const" : + return 13; + case "get_const" : + return 0; + case "get_env" : + return 2; + case "get_meth" : + return 3; + case "get_var" : + return 1; + case "meth_app_const" : + return 16; + case "meth_app_env" : + return 18; + case "meth_app_meth" : + return 19; + case "meth_app_var" : + return 17; + case "send_const" : + return 20; + case "send_env" : + return 22; + case "send_meth" : + return 23; + case "send_var" : + return 21; + case "set_var" : + return 4; + default: + return -1; + } +} + +if (tst03("get_const") !== 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 123, + 2 + ] + ]; +} + +if (tst03("set_congt") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 124, + 2 + ] + ]; +} + +if (tst03("get_var") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 125, + 2 + ] + ]; +} + +if (tst03("gat_ver") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 126, + 2 + ] + ]; +} + +if (tst03("get_env") !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 127, + 2 + ] + ]; +} + +if (tst03("get_env") !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 128, + 2 + ] + ]; +} + +if (tst03("get_meth") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 129, + 2 + ] + ]; +} + +if (tst03("met_geth") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 130, + 2 + ] + ]; +} + +if (tst03("set_var") !== 4) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 131, + 2 + ] + ]; +} + +if (tst03("sev_tar") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 132, + 2 + ] + ]; +} + +if (tst03("app_const") !== 5) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 133, + 2 + ] + ]; +} + +if (tst03("ppa_const") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 134, + 2 + ] + ]; +} + +if (tst03("app_var") !== 6) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 135, + 2 + ] + ]; +} + +if (tst03("app_var") !== 6) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 136, + 2 + ] + ]; +} + +if (tst03("app_env") !== 7) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 137, + 2 + ] + ]; +} + +if (tst03("epp_anv") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 138, + 2 + ] + ]; +} + +if (tst03("app_meth") !== 8) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 139, + 2 + ] + ]; +} + +if (tst03("atp_meph") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 140, + 2 + ] + ]; +} + +if (tst03("app_const_const") !== 9) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 141, + 2 + ] + ]; +} + +if (tst03("app_const_const") !== 9) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 142, + 2 + ] + ]; +} + +if (tst03("app_const_var") !== 10) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 143, + 2 + ] + ]; +} + +if (tst03("atp_consp_var") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 144, + 2 + ] + ]; +} + +if (tst03("app_const_env") !== 11) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 145, + 2 + ] + ]; +} + +if (tst03("app_constne_v") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 146, + 2 + ] + ]; +} + +if (tst03("app_const_meth") !== 12) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 147, + 2 + ] + ]; +} + +if (tst03("spp_conat_meth") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 148, + 2 + ] + ]; +} + +if (tst03("app_var_const") !== 13) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 149, + 2 + ] + ]; +} + +if (tst03("app_va_rconst") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 150, + 2 + ] + ]; +} + +if (tst03("app_env_const") !== 14) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 151, + 2 + ] + ]; +} + +if (tst03("app_env_const") !== 14) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 152, + 2 + ] + ]; +} + +if (tst03("app_meth_const") !== 15) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 153, + 2 + ] + ]; +} + +if (tst03("app_teth_consm") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 154, + 2 + ] + ]; +} + +if (tst03("meth_app_const") !== 16) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 155, + 2 + ] + ]; +} + +if (tst03("math_epp_const") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 156, + 2 + ] + ]; +} + +if (tst03("meth_app_var") !== 17) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 157, + 2 + ] + ]; +} + +if (tst03("meth_app_var") !== 17) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 158, + 2 + ] + ]; +} + +if (tst03("meth_app_env") !== 18) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 159, + 2 + ] + ]; +} + +if (tst03("eeth_app_mnv") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 160, + 2 + ] + ]; +} + +if (tst03("meth_app_meth") !== 19) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 161, + 2 + ] + ]; +} + +if (tst03("meth_apt_meph") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 162, + 2 + ] + ]; +} + +if (tst03("send_const") !== 20) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 163, + 2 + ] + ]; +} + +if (tst03("tend_conss") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 164, + 2 + ] + ]; +} + +if (tst03("send_var") !== 21) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 165, + 2 + ] + ]; +} + +if (tst03("serd_van") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 166, + 2 + ] + ]; +} + +if (tst03("send_env") !== 22) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 167, + 2 + ] + ]; +} + +if (tst03("sen_denv") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 168, + 2 + ] + ]; +} + +if (tst03("send_meth") !== 23) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 169, + 2 + ] + ]; +} + +if (tst03("tend_mesh") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 170, + 2 + ] + ]; +} + +function tst04(s) { + switch (s) { + case "AAAAAAAA" : + return 0; + case "AAAAAAAAAAAAAAAA" : + return 1; + case "AAAAAAAAAAAAAAAAAAAAAAAA" : + return 2; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 3; + case "BBBBBBBB" : + return 4; + case "BBBBBBBBBBBBBBBB" : + return 5; + case "BBBBBBBBBBBBBBBBBBBBBBBB" : + return 6; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 7; + case "CCCCCCCC" : + return 8; + case "CCCCCCCCCCCCCCCC" : + return 9; + case "CCCCCCCCCCCCCCCCCCCCCCCC" : + return 10; + case "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" : + return 11; + default: + return -1; + } +} + +if (tst04("AAAAAAAA") !== 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 204, + 2 + ] + ]; +} + +if (tst04("AAAAAAAAAAAAAAAA") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 205, + 2 + ] + ]; +} + +if (tst04("AAAAAAAAAAAAAAAAAAAAAAAA") !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 206, + 2 + ] + ]; +} + +if (tst04("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 207, + 2 + ] + ]; +} + +if (tst04("BBBBBBBB") !== 4) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 208, + 2 + ] + ]; +} + +if (tst04("BBBBBBBBBBBBBBBB") !== 5) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 209, + 2 + ] + ]; +} + +if (tst04("BBBBBBBBBBBBBBBBBBBBBBBB") !== 6) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 210, + 2 + ] + ]; +} + +if (tst04("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB") !== 7) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 211, + 2 + ] + ]; +} + +if (tst04("CCCCCCCC") !== 8) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 212, + 2 + ] + ]; +} + +if (tst04("CCCCCCCCCCCCCCCC") !== 9) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 213, + 2 + ] + ]; +} + +if (tst04("CCCCCCCCCCCCCCCCCCCCCCCC") !== 10) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 214, + 2 + ] + ]; +} + +if (tst04("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC") !== 11) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 215, + 2 + ] + ]; +} + +if (tst04("") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 216, + 2 + ] + ]; +} + +if (tst04("DDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 217, + 2 + ] + ]; +} + +if (tst04("DDDDDDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 218, + 2 + ] + ]; +} + +if (tst04("AAADDDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 219, + 2 + ] + ]; +} + +if (tst04("AAAAAAADDDDDDDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 220, + 2 + ] + ]; +} + +if (tst04("AAAAAAADDDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 221, + 2 + ] + ]; +} + +if (tst04("AAAAAAAAAAAAAAADDDD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 222, + 2 + ] + ]; +} + +function tst05(s) { + switch (s) { + case "AAA" : + return 0; + case "AAAA" : + return 1; + case "AAAAA" : + return 2; + case "AAAAAA" : + return 3; + case "AAAAAAA" : + return 4; + case "AAAAAAAAAAAA" : + return 5; + case "AAAAAAAAAAAAAAAA" : + return 6; + case "AAAAAAAAAAAAAAAAAAAA" : + return 7; + case "BBB" : + return 8; + case "BBBB" : + return 9; + case "BBBBB" : + return 10; + case "BBBBBB" : + return 11; + case "BBBBBBB" : + return 12; + default: + return -1; + } +} + +if (tst05("AAA") !== 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 258, + 2 + ] + ]; +} + +if (tst05("AAAA") !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 259, + 2 + ] + ]; +} + +if (tst05("AAAAA") !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 260, + 2 + ] + ]; +} + +if (tst05("AAAAAA") !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 261, + 2 + ] + ]; +} + +if (tst05("AAAAAAA") !== 4) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 262, + 2 + ] + ]; +} + +if (tst05("AAAAAAAAAAAA") !== 5) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 263, + 2 + ] + ]; +} + +if (tst05("AAAAAAAAAAAAAAAA") !== 6) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 264, + 2 + ] + ]; +} + +if (tst05("AAAAAAAAAAAAAAAAAAAA") !== 7) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 265, + 2 + ] + ]; +} + +if (tst05("BBB") !== 8) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 266, + 2 + ] + ]; +} + +if (tst05("BBBB") !== 9) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 267, + 2 + ] + ]; +} + +if (tst05("BBBBB") !== 10) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 268, + 2 + ] + ]; +} + +if (tst05("BBBBBB") !== 11) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 269, + 2 + ] + ]; +} + +if (tst05("BBBBBBB") !== 12) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 270, + 2 + ] + ]; +} + +if (tst05("") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 271, + 2 + ] + ]; +} + +if (tst05("AAD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 272, + 2 + ] + ]; +} + +if (tst05("AAAD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 273, + 2 + ] + ]; +} + +if (tst05("AAAAAAD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 274, + 2 + ] + ]; +} + +if (tst05("AAAAAAAD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 275, + 2 + ] + ]; +} + +if (tst05("BBD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 276, + 2 + ] + ]; +} + +if (tst05("BBBD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 277, + 2 + ] + ]; +} + +if (tst05("BBBBBBD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 278, + 2 + ] + ]; +} + +if (tst05("BBBBBBBD") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 279, + 2 + ] + ]; +} + +var s00 = "and"; + +var t00 = "nad"; + +var s01 = "as"; + +var t01 = "sa"; + +var s02 = "assert"; + +var t02 = "asesrt"; + +var s03 = "begin"; + +var t03 = "negib"; + +var s04 = "class"; + +var t04 = "lcass"; + +var s05 = "constraint"; + +var t05 = "constiarnt"; + +var s06 = "do"; + +var t06 = "od"; + +var s07 = "done"; + +var t07 = "eond"; + +var s08 = "downto"; + +var t08 = "dowtno"; + +var s09 = "else"; + +var t09 = "lese"; + +var s10 = "end"; + +var t10 = "edn"; + +var s11 = "exception"; + +var t11 = "exception"; + +var s12 = "external"; + +var t12 = "external"; + +var s13 = "false"; + +var t13 = "fslae"; + +var s14 = "for"; + +var t14 = "ofr"; + +var s15 = "fun"; + +var t15 = "fnu"; + +var s16 = "function"; + +var t16 = "function"; + +var s17 = "functor"; + +var t17 = "ounctfr"; + +var s18 = "if"; + +var t18 = "fi"; + +var s19 = "in"; + +var t19 = "in"; + +var s20 = "include"; + +var t20 = "inculde"; + +var s21 = "inherit"; + +var t21 = "iehnrit"; + +var s22 = "initializer"; + +var t22 = "enitializir"; + +var s23 = "lazy"; + +var t23 = "zaly"; + +var s24 = "let"; + +var t24 = "elt"; + +var s25 = "match"; + +var t25 = "match"; + +var s26 = "method"; + +var t26 = "methdo"; + +var s27 = "module"; + +var t27 = "modelu"; + +var s28 = "mutable"; + +var t28 = "butamle"; + +var s29 = "new"; + +var t29 = "wen"; + +var s30 = "object"; + +var t30 = "objcet"; + +var s31 = "of"; + +var t31 = "of"; + +var s32 = "open"; + +var t32 = "epon"; + +var s33 = "or"; + +var t33 = "ro"; + +var s34 = "private"; + +var t34 = "privaet"; + +var s35 = "rec"; + +var t35 = "rec"; + +var s36 = "sig"; + +var t36 = "gis"; + +var s37 = "struct"; + +var t37 = "scrutt"; + +var s38 = "then"; + +var t38 = "hten"; + +var s39 = "to"; + +var t39 = "to"; + +var s40 = "true"; + +var t40 = "teur"; + +var s41 = "try"; + +var t41 = "try"; + +var s42 = "type"; + +var t42 = "pyte"; + +var s43 = "val"; + +var t43 = "val"; + +var s44 = "virtual"; + +var t44 = "vritual"; + +var s45 = "when"; + +var t45 = "whne"; + +var s46 = "while"; + +var t46 = "wlihe"; + +var s47 = "with"; + +var t47 = "iwth"; + +var s48 = "mod"; + +var t48 = "mod"; + +var s49 = "land"; + +var t49 = "alnd"; + +var s50 = "lor"; + +var t50 = "rol"; + +var s51 = "lxor"; + +var t51 = "lxor"; + +var s52 = "lsl"; + +var t52 = "lsl"; + +var s53 = "lsr"; + +var t53 = "lsr"; + +var s54 = "asr"; + +var t54 = "sar"; + +var s55 = "A"; + +var t55 = "A"; + +var s56 = "AA"; + +var t56 = "AA"; + +var s57 = "AAA"; + +var t57 = "AAA"; + +var s58 = "AAAA"; + +var t58 = "AAAA"; + +var s59 = "AAAAA"; + +var t59 = "AAAAA"; + +var s60 = "AAAAAA"; + +var t60 = "AAAAAA"; + +var s61 = "AAAAAAA"; + +var t61 = "AAAAAAA"; + +var s62 = "AAAAAAAA"; + +var t62 = "AAAAAAAA"; + +var s63 = "AAAAAAAAA"; + +var t63 = "AAAAAAAAA"; + +var s64 = "AAAAAAAAAA"; + +var t64 = "AAAAAAAAAA"; + +var s65 = "AAAAAAAAAAA"; + +var t65 = "AAAAAAAAAAA"; + +var s66 = "AAAAAAAAAAAA"; + +var t66 = "AAAAAAAAAAAA"; + +var s67 = "AAAAAAAAAAAAA"; + +var t67 = "AAAAAAAAAAAAA"; + +var s68 = "AAAAAAAAAAAAAA"; + +var t68 = "AAAAAAAAAAAAAA"; + +var s69 = "AAAAAAAAAAAAAAA"; + +var t69 = "AAAAAAAAAAAAAAA"; + +var s70 = "AAAAAAAAAAAAAAAA"; + +var t70 = "AAAAAAAAAAAAAAAA"; + +var s71 = "AAAAAAAAAAAAAAAAA"; + +var t71 = "AAAAAAAAAAAAAAAAA"; + +var s72 = "AAAAAAAAAAAAAAAAAA"; + +var t72 = "AAAAAAAAAAAAAAAAAA"; + +var s73 = "AAAAAAAAAAAAAAAAAAA"; + +var t73 = "AAAAAAAAAAAAAAAAAAA"; + +var s74 = "AAAAAAAAAAAAAAAAAAAA"; + +var t74 = "AAAAAAAAAAAAAAAAAAAA"; + +var s75 = "AAAAAAAAAAAAAAAAAAAAA"; + +var t75 = "AAAAAAAAAAAAAAAAAAAAA"; + +var s76 = "AAAAAAAAAAAAAAAAAAAAAA"; + +var t76 = "AAAAAAAAAAAAAAAAAAAAAA"; + +var s77 = "AAAAAAAAAAAAAAAAAAAAAAA"; + +var t77 = "AAAAAAAAAAAAAAAAAAAAAAA"; + +var s78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; + +var t78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; + +var s79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var t88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +var s89 = "BBBBBBBBBBBBBBB"; + +var t89 = "BBBBBBBBBBBBBBB"; + +var s90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +var t90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +var s91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +var t91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +function tst06(s) { + switch (s) { + case "A" : + return 55; + case "AA" : + return 56; + case "AAA" : + return 57; + case "AAAA" : + return 58; + case "AAAAA" : + return 59; + case "AAAAAA" : + return 60; + case "AAAAAAA" : + return 61; + case "AAAAAAAA" : + return 62; + case "AAAAAAAAA" : + return 63; + case "AAAAAAAAAA" : + return 64; + case "AAAAAAAAAAA" : + return 65; + case "AAAAAAAAAAAA" : + return 66; + case "AAAAAAAAAAAAA" : + return 67; + case "AAAAAAAAAAAAAA" : + return 68; + case "AAAAAAAAAAAAAAA" : + return 69; + case "AAAAAAAAAAAAAAAA" : + return 70; + case "AAAAAAAAAAAAAAAAA" : + return 71; + case "AAAAAAAAAAAAAAAAAA" : + return 72; + case "AAAAAAAAAAAAAAAAAAA" : + return 73; + case "AAAAAAAAAAAAAAAAAAAA" : + return 74; + case "AAAAAAAAAAAAAAAAAAAAA" : + return 75; + case "AAAAAAAAAAAAAAAAAAAAAA" : + return 76; + case "AAAAAAAAAAAAAAAAAAAAAAA" : + return 77; + case "AAAAAAAAAAAAAAAAAAAAAAAA" : + return 78; + case "AAAAAAAAAAAAAAAAAAAAAAAAA" : + return 79; + case "AAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 80; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 81; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 82; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 83; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 84; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 85; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 86; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 87; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 88; + case "BBBBBBBBBBBBBBB" : + return 89; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 90; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 91; + case "and" : + return 0; + case "as" : + return 1; + case "asr" : + return 54; + case "assert" : + return 2; + case "begin" : + return 3; + case "class" : + return 4; + case "constraint" : + return 5; + case "do" : + return 6; + case "done" : + return 7; + case "downto" : + return 8; + case "else" : + return 9; + case "end" : + return 10; + case "exception" : + return 11; + case "external" : + return 12; + case "false" : + return 13; + case "for" : + return 14; + case "fun" : + return 15; + case "function" : + return 16; + case "functor" : + return 17; + case "if" : + return 18; + case "in" : + return 19; + case "include" : + return 20; + case "inherit" : + return 21; + case "initializer" : + return 22; + case "land" : + return 49; + case "lazy" : + return 23; + case "let" : + return 24; + case "lor" : + return 50; + case "lsl" : + return 52; + case "lsr" : + return 53; + case "lxor" : + return 51; + case "match" : + return 25; + case "method" : + return 26; + case "mod" : + return 48; + case "module" : + return 27; + case "mutable" : + return 28; + case "new" : + return 29; + case "object" : + return 30; + case "of" : + return 31; + case "open" : + return 32; + case "or" : + return 33; + case "private" : + return 34; + case "rec" : + return 35; + case "sig" : + return 36; + case "struct" : + return 37; + case "then" : + return 38; + case "to" : + return 39; + case "true" : + return 40; + case "try" : + return 41; + case "type" : + return 42; + case "val" : + return 43; + case "virtual" : + return 44; + case "when" : + return 45; + case "while" : + return 46; + case "with" : + return 47; + default: + return -1; + } +} + +if (tst06(s00) !== 0) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 565, + 2 + ] + ]; +} + +if (tst06(t00) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 566, + 2 + ] + ]; +} + +if (tst06(s01) !== 1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 567, + 2 + ] + ]; +} + +if (tst06(t01) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 568, + 2 + ] + ]; +} + +if (tst06(s02) !== 2) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 569, + 2 + ] + ]; +} + +if (tst06(t02) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 570, + 2 + ] + ]; +} + +if (tst06(s03) !== 3) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 571, + 2 + ] + ]; +} + +if (tst06(t03) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 572, + 2 + ] + ]; +} + +if (tst06(s04) !== 4) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 573, + 2 + ] + ]; +} + +if (tst06(t04) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 574, + 2 + ] + ]; +} + +if (tst06(s05) !== 5) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 575, + 2 + ] + ]; +} + +if (tst06(t05) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 576, + 2 + ] + ]; +} + +if (tst06(s06) !== 6) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 577, + 2 + ] + ]; +} + +if (tst06(t06) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 578, + 2 + ] + ]; +} + +if (tst06(s07) !== 7) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 579, + 2 + ] + ]; +} + +if (tst06(t07) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 580, + 2 + ] + ]; +} + +if (tst06(s08) !== 8) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 581, + 2 + ] + ]; +} + +if (tst06(t08) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 582, + 2 + ] + ]; +} + +if (tst06(s09) !== 9) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 583, + 2 + ] + ]; +} + +if (tst06(t09) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 584, + 2 + ] + ]; +} + +if (tst06(s10) !== 10) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 585, + 2 + ] + ]; +} + +if (tst06(t10) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 586, + 2 + ] + ]; +} + +if (tst06(s11) !== 11) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 587, + 2 + ] + ]; +} + +if (tst06(t11) !== 11) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 588, + 2 + ] + ]; +} + +if (tst06(s12) !== 12) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 589, + 2 + ] + ]; +} + +if (tst06(t12) !== 12) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 590, + 2 + ] + ]; +} + +if (tst06(s13) !== 13) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 591, + 2 + ] + ]; +} + +if (tst06(t13) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 592, + 2 + ] + ]; +} + +if (tst06(s14) !== 14) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 593, + 2 + ] + ]; +} + +if (tst06(t14) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 594, + 2 + ] + ]; +} + +if (tst06(s15) !== 15) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 595, + 2 + ] + ]; +} + +if (tst06(t15) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 596, + 2 + ] + ]; +} + +if (tst06(s16) !== 16) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 597, + 2 + ] + ]; +} + +if (tst06(t16) !== 16) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 598, + 2 + ] + ]; +} + +if (tst06(s17) !== 17) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 599, + 2 + ] + ]; +} + +if (tst06(t17) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 600, + 2 + ] + ]; +} + +if (tst06(s18) !== 18) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 601, + 2 + ] + ]; +} + +if (tst06(t18) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 602, + 2 + ] + ]; +} + +if (tst06(s19) !== 19) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 603, + 2 + ] + ]; +} + +if (tst06(t19) !== 19) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 604, + 2 + ] + ]; +} + +if (tst06(s20) !== 20) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 605, + 2 + ] + ]; +} + +if (tst06(t20) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 606, + 2 + ] + ]; +} + +if (tst06(s21) !== 21) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 607, + 2 + ] + ]; +} + +if (tst06(t21) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 608, + 2 + ] + ]; +} + +if (tst06(s22) !== 22) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 609, + 2 + ] + ]; +} + +if (tst06(t22) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 610, + 2 + ] + ]; +} + +if (tst06(s23) !== 23) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 611, + 2 + ] + ]; +} + +if (tst06(t23) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 612, + 2 + ] + ]; +} + +if (tst06(s24) !== 24) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 613, + 2 + ] + ]; +} + +if (tst06(t24) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 614, + 2 + ] + ]; +} + +if (tst06(s25) !== 25) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 615, + 2 + ] + ]; +} + +if (tst06(t25) !== 25) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 616, + 2 + ] + ]; +} + +if (tst06(s26) !== 26) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 617, + 2 + ] + ]; +} + +if (tst06(t26) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 618, + 2 + ] + ]; +} + +if (tst06(s27) !== 27) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 619, + 2 + ] + ]; +} + +if (tst06(t27) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 620, + 2 + ] + ]; +} + +if (tst06(s28) !== 28) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 621, + 2 + ] + ]; +} + +if (tst06(t28) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 622, + 2 + ] + ]; +} + +if (tst06(s29) !== 29) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 623, + 2 + ] + ]; +} + +if (tst06(t29) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 624, + 2 + ] + ]; +} + +if (tst06(s30) !== 30) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 625, + 2 + ] + ]; +} + +if (tst06(t30) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 626, + 2 + ] + ]; +} + +if (tst06(s31) !== 31) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 627, + 2 + ] + ]; +} + +if (tst06(t31) !== 31) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 628, + 2 + ] + ]; +} + +if (tst06(s32) !== 32) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 629, + 2 + ] + ]; +} + +if (tst06(t32) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 630, + 2 + ] + ]; +} + +if (tst06(s33) !== 33) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 631, + 2 + ] + ]; +} + +if (tst06(t33) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 632, + 2 + ] + ]; +} + +if (tst06(s34) !== 34) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 633, + 2 + ] + ]; +} + +if (tst06(t34) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 634, + 2 + ] + ]; +} + +if (tst06(s35) !== 35) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 635, + 2 + ] + ]; +} + +if (tst06(t35) !== 35) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 636, + 2 + ] + ]; +} + +if (tst06(s36) !== 36) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 637, + 2 + ] + ]; +} + +if (tst06(t36) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 638, + 2 + ] + ]; +} + +if (tst06(s37) !== 37) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 639, + 2 + ] + ]; +} + +if (tst06(t37) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 640, + 2 + ] + ]; +} + +if (tst06(s38) !== 38) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 641, + 2 + ] + ]; +} + +if (tst06(t38) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 642, + 2 + ] + ]; +} + +if (tst06(s39) !== 39) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 643, + 2 + ] + ]; +} + +if (tst06(t39) !== 39) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 644, + 2 + ] + ]; +} + +if (tst06(s40) !== 40) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 645, + 2 + ] + ]; +} + +if (tst06(t40) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 646, + 2 + ] + ]; +} + +if (tst06(s41) !== 41) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 647, + 2 + ] + ]; +} + +if (tst06(t41) !== 41) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 648, + 2 + ] + ]; +} + +if (tst06(s42) !== 42) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 649, + 2 + ] + ]; +} + +if (tst06(t42) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 650, + 2 + ] + ]; +} + +if (tst06(s43) !== 43) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 651, + 2 + ] + ]; +} + +if (tst06(t43) !== 43) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 652, + 2 + ] + ]; +} + +if (tst06(s44) !== 44) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 653, + 2 + ] + ]; +} + +if (tst06(t44) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 654, + 2 + ] + ]; +} + +if (tst06(s45) !== 45) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 655, + 2 + ] + ]; +} + +if (tst06(t45) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 656, + 2 + ] + ]; +} + +if (tst06(s46) !== 46) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 657, + 2 + ] + ]; +} + +if (tst06(t46) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 658, + 2 + ] + ]; +} + +if (tst06(s47) !== 47) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 659, + 2 + ] + ]; +} + +if (tst06(t47) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 660, + 2 + ] + ]; +} + +if (tst06(s48) !== 48) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 661, + 2 + ] + ]; +} + +if (tst06(t48) !== 48) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 662, + 2 + ] + ]; +} + +if (tst06(s49) !== 49) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 663, + 2 + ] + ]; +} + +if (tst06(t49) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 664, + 2 + ] + ]; +} + +if (tst06(s50) !== 50) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 665, + 2 + ] + ]; +} + +if (tst06(t50) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 666, + 2 + ] + ]; +} + +if (tst06(s51) !== 51) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 667, + 2 + ] + ]; +} + +if (tst06(t51) !== 51) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 668, + 2 + ] + ]; +} + +if (tst06(s52) !== 52) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 669, + 2 + ] + ]; +} + +if (tst06(t52) !== 52) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 670, + 2 + ] + ]; +} + +if (tst06(s53) !== 53) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 671, + 2 + ] + ]; +} + +if (tst06(t53) !== 53) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 672, + 2 + ] + ]; +} + +if (tst06(s54) !== 54) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 673, + 2 + ] + ]; +} + +if (tst06(t54) !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 674, + 2 + ] + ]; +} + +if (tst06(s55) !== 55) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 675, + 2 + ] + ]; +} + +if (tst06(t55) !== 55) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 676, + 2 + ] + ]; +} + +if (tst06(s56) !== 56) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 677, + 2 + ] + ]; +} + +if (tst06(t56) !== 56) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 678, + 2 + ] + ]; +} + +if (tst06(s57) !== 57) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 679, + 2 + ] + ]; +} + +if (tst06(t57) !== 57) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 680, + 2 + ] + ]; +} + +if (tst06(s58) !== 58) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 681, + 2 + ] + ]; +} + +if (tst06(t58) !== 58) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 682, + 2 + ] + ]; +} + +if (tst06(s59) !== 59) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 683, + 2 + ] + ]; +} + +if (tst06(t59) !== 59) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 684, + 2 + ] + ]; +} + +if (tst06(s60) !== 60) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 685, + 2 + ] + ]; +} + +if (tst06(t60) !== 60) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 686, + 2 + ] + ]; +} + +if (tst06(s61) !== 61) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 687, + 2 + ] + ]; +} + +if (tst06(t61) !== 61) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 688, + 2 + ] + ]; +} + +if (tst06(s62) !== 62) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 689, + 2 + ] + ]; +} + +if (tst06(t62) !== 62) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 690, + 2 + ] + ]; +} + +if (tst06(s63) !== 63) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 691, + 2 + ] + ]; +} + +if (tst06(t63) !== 63) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 692, + 2 + ] + ]; +} + +if (tst06(s64) !== 64) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 693, + 2 + ] + ]; +} + +if (tst06(t64) !== 64) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 694, + 2 + ] + ]; +} + +if (tst06(s65) !== 65) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 695, + 2 + ] + ]; +} + +if (tst06(t65) !== 65) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 696, + 2 + ] + ]; +} + +if (tst06(s66) !== 66) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 697, + 2 + ] + ]; +} + +if (tst06(t66) !== 66) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 698, + 2 + ] + ]; +} + +if (tst06(s67) !== 67) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 699, + 2 + ] + ]; +} + +if (tst06(t67) !== 67) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 700, + 2 + ] + ]; +} + +if (tst06(s68) !== 68) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 701, + 2 + ] + ]; +} + +if (tst06(t68) !== 68) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 702, + 2 + ] + ]; +} + +if (tst06(s69) !== 69) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 703, + 2 + ] + ]; +} + +if (tst06(t69) !== 69) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 704, + 2 + ] + ]; +} + +if (tst06(s70) !== 70) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 705, + 2 + ] + ]; +} + +if (tst06(t70) !== 70) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 706, + 2 + ] + ]; +} + +if (tst06(s71) !== 71) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 707, + 2 + ] + ]; +} + +if (tst06(t71) !== 71) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 708, + 2 + ] + ]; +} + +if (tst06(s72) !== 72) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 709, + 2 + ] + ]; +} + +if (tst06(t72) !== 72) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 710, + 2 + ] + ]; +} + +if (tst06(s73) !== 73) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 711, + 2 + ] + ]; +} + +if (tst06(t73) !== 73) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 712, + 2 + ] + ]; +} + +if (tst06(s74) !== 74) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 713, + 2 + ] + ]; +} + +if (tst06(t74) !== 74) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 714, + 2 + ] + ]; +} + +if (tst06(s75) !== 75) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 715, + 2 + ] + ]; +} + +if (tst06(t75) !== 75) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 716, + 2 + ] + ]; +} + +if (tst06(s76) !== 76) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 717, + 2 + ] + ]; +} + +if (tst06(t76) !== 76) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 718, + 2 + ] + ]; +} + +if (tst06(s77) !== 77) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 719, + 2 + ] + ]; +} + +if (tst06(t77) !== 77) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 720, + 2 + ] + ]; +} + +if (tst06(s78) !== 78) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 721, + 2 + ] + ]; +} + +if (tst06(t78) !== 78) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 722, + 2 + ] + ]; +} + +if (tst06(s79) !== 79) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 723, + 2 + ] + ]; +} + +if (tst06(t79) !== 79) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 724, + 2 + ] + ]; +} + +if (tst06(s80) !== 80) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 725, + 2 + ] + ]; +} + +if (tst06(t80) !== 80) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 726, + 2 + ] + ]; +} + +if (tst06(s81) !== 81) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 727, + 2 + ] + ]; +} + +if (tst06(t81) !== 81) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 728, + 2 + ] + ]; +} + +if (tst06(s82) !== 82) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 729, + 2 + ] + ]; +} + +if (tst06(t82) !== 82) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 730, + 2 + ] + ]; +} + +if (tst06(s83) !== 83) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 731, + 2 + ] + ]; +} + +if (tst06(t83) !== 83) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 732, + 2 + ] + ]; +} + +if (tst06(s84) !== 84) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 733, + 2 + ] + ]; +} + +if (tst06(t84) !== 84) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 734, + 2 + ] + ]; +} + +if (tst06(s85) !== 85) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 735, + 2 + ] + ]; +} + +if (tst06(t85) !== 85) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 736, + 2 + ] + ]; +} + +if (tst06(s86) !== 86) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 737, + 2 + ] + ]; +} + +if (tst06(t86) !== 86) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 738, + 2 + ] + ]; +} + +if (tst06(s87) !== 87) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 739, + 2 + ] + ]; +} + +if (tst06(t87) !== 87) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 740, + 2 + ] + ]; +} + +if (tst06(s88) !== 88) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 741, + 2 + ] + ]; +} + +if (tst06(t88) !== 88) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 742, + 2 + ] + ]; +} + +if (tst06(s89) !== 89) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 743, + 2 + ] + ]; +} + +if (tst06(t89) !== 89) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 744, + 2 + ] + ]; +} + +if (tst06(s90) !== 90) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 745, + 2 + ] + ]; +} + +if (tst06(t90) !== 90) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 746, + 2 + ] + ]; +} + +if (tst06(s91) !== 91) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 747, + 2 + ] + ]; +} + +if (tst06(t91) !== 91) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 748, + 2 + ] + ]; +} + +if (tst06("") !== -1) { + throw [ + Caml_builtin_exceptions.assert_failure, + [ + "stringmatch_test.ml", + 749, + 2 + ] + ]; +} + +exports.tst01 = tst01; +exports.tst02 = tst02; +exports.tst03 = tst03; +exports.tst04 = tst04; +exports.tst05 = tst05; +exports.s00 = s00; +exports.t00 = t00; +exports.s01 = s01; +exports.t01 = t01; +exports.s02 = s02; +exports.t02 = t02; +exports.s03 = s03; +exports.t03 = t03; +exports.s04 = s04; +exports.t04 = t04; +exports.s05 = s05; +exports.t05 = t05; +exports.s06 = s06; +exports.t06 = t06; +exports.s07 = s07; +exports.t07 = t07; +exports.s08 = s08; +exports.t08 = t08; +exports.s09 = s09; +exports.t09 = t09; +exports.s10 = s10; +exports.t10 = t10; +exports.s11 = s11; +exports.t11 = t11; +exports.s12 = s12; +exports.t12 = t12; +exports.s13 = s13; +exports.t13 = t13; +exports.s14 = s14; +exports.t14 = t14; +exports.s15 = s15; +exports.t15 = t15; +exports.s16 = s16; +exports.t16 = t16; +exports.s17 = s17; +exports.t17 = t17; +exports.s18 = s18; +exports.t18 = t18; +exports.s19 = s19; +exports.t19 = t19; +exports.s20 = s20; +exports.t20 = t20; +exports.s21 = s21; +exports.t21 = t21; +exports.s22 = s22; +exports.t22 = t22; +exports.s23 = s23; +exports.t23 = t23; +exports.s24 = s24; +exports.t24 = t24; +exports.s25 = s25; +exports.t25 = t25; +exports.s26 = s26; +exports.t26 = t26; +exports.s27 = s27; +exports.t27 = t27; +exports.s28 = s28; +exports.t28 = t28; +exports.s29 = s29; +exports.t29 = t29; +exports.s30 = s30; +exports.t30 = t30; +exports.s31 = s31; +exports.t31 = t31; +exports.s32 = s32; +exports.t32 = t32; +exports.s33 = s33; +exports.t33 = t33; +exports.s34 = s34; +exports.t34 = t34; +exports.s35 = s35; +exports.t35 = t35; +exports.s36 = s36; +exports.t36 = t36; +exports.s37 = s37; +exports.t37 = t37; +exports.s38 = s38; +exports.t38 = t38; +exports.s39 = s39; +exports.t39 = t39; +exports.s40 = s40; +exports.t40 = t40; +exports.s41 = s41; +exports.t41 = t41; +exports.s42 = s42; +exports.t42 = t42; +exports.s43 = s43; +exports.t43 = t43; +exports.s44 = s44; +exports.t44 = t44; +exports.s45 = s45; +exports.t45 = t45; +exports.s46 = s46; +exports.t46 = t46; +exports.s47 = s47; +exports.t47 = t47; +exports.s48 = s48; +exports.t48 = t48; +exports.s49 = s49; +exports.t49 = t49; +exports.s50 = s50; +exports.t50 = t50; +exports.s51 = s51; +exports.t51 = t51; +exports.s52 = s52; +exports.t52 = t52; +exports.s53 = s53; +exports.t53 = t53; +exports.s54 = s54; +exports.t54 = t54; +exports.s55 = s55; +exports.t55 = t55; +exports.s56 = s56; +exports.t56 = t56; +exports.s57 = s57; +exports.t57 = t57; +exports.s58 = s58; +exports.t58 = t58; +exports.s59 = s59; +exports.t59 = t59; +exports.s60 = s60; +exports.t60 = t60; +exports.s61 = s61; +exports.t61 = t61; +exports.s62 = s62; +exports.t62 = t62; +exports.s63 = s63; +exports.t63 = t63; +exports.s64 = s64; +exports.t64 = t64; +exports.s65 = s65; +exports.t65 = t65; +exports.s66 = s66; +exports.t66 = t66; +exports.s67 = s67; +exports.t67 = t67; +exports.s68 = s68; +exports.t68 = t68; +exports.s69 = s69; +exports.t69 = t69; +exports.s70 = s70; +exports.t70 = t70; +exports.s71 = s71; +exports.t71 = t71; +exports.s72 = s72; +exports.t72 = t72; +exports.s73 = s73; +exports.t73 = t73; +exports.s74 = s74; +exports.t74 = t74; +exports.s75 = s75; +exports.t75 = t75; +exports.s76 = s76; +exports.t76 = t76; +exports.s77 = s77; +exports.t77 = t77; +exports.s78 = s78; +exports.t78 = t78; +exports.s79 = s79; +exports.t79 = t79; +exports.s80 = s80; +exports.t80 = t80; +exports.s81 = s81; +exports.t81 = t81; +exports.s82 = s82; +exports.t82 = t82; +exports.s83 = s83; +exports.t83 = t83; +exports.s84 = s84; +exports.t84 = t84; +exports.s85 = s85; +exports.t85 = t85; +exports.s86 = s86; +exports.t86 = t86; +exports.s87 = s87; +exports.t87 = t87; +exports.s88 = s88; +exports.t88 = t88; +exports.s89 = s89; +exports.t89 = t89; +exports.s90 = s90; +exports.t90 = t90; +exports.s91 = s91; +exports.t91 = t91; +exports.tst06 = tst06; +/* Not a pure module */ diff --git a/jscomp/test/stringmatch_test.ml b/jscomp/test/stringmatch_test.ml new file mode 100644 index 00000000000..c0bbbaae57e --- /dev/null +++ b/jscomp/test/stringmatch_test.ml @@ -0,0 +1,750 @@ +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Luc Maranget, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 2014 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* Empty string oddities *) + +let rec tst01 s = match s with +| "" -> 0 +| _ -> 1 + +let () = + assert (tst01 "" = 0) ; + assert (tst01 "\000\000\000\003" = 1) ; + assert (tst01 "\000\000\000\000\000\000\000\007" = 1) ; + () + +(* A few when clauses *) + +let tst02 s = + let len = String.length s in + match s with + | "" when len < 0 -> assert false + | "" -> 1 + | _ when len = 0 -> assert false + | "A" -> 2 + | _ -> 3 + +let () = + assert (tst02 "" = 1) ; + assert (tst02 "A" = 2) ; + assert (tst02 "B" = 3) ; + assert (tst02 "\000\000\000\000\000\000\000\007" = 3) ; + assert (tst02 "\000\000\000\003" = 3) ; + () + +(* Keword reckognition *) + +let s00 = "get_const" +let t00 = "set_congt" +let s01 = "get_var" +let t01 = "gat_ver" +let s02 = "get_env" +let t02 = "get_env" +let s03 = "get_meth" +let t03 = "met_geth" +let s04 = "set_var" +let t04 = "sev_tar" +let s05 = "app_const" +let t05 = "ppa_const" +let s06 = "app_var" +let t06 = "app_var" +let s07 = "app_env" +let t07 = "epp_anv" +let s08 = "app_meth" +let t08 = "atp_meph" +let s09 = "app_const_const" +let t09 = "app_const_const" +let s10 = "app_const_var" +let t10 = "atp_consp_var" +let s11 = "app_const_env" +let t11 = "app_constne_v" +let s12 = "app_const_meth" +let t12 = "spp_conat_meth" +let s13 = "app_var_const" +let t13 = "app_va_rconst" +let s14 = "app_env_const" +let t14 = "app_env_const" +let s15 = "app_meth_const" +let t15 = "app_teth_consm" +let s16 = "meth_app_const" +let t16 = "math_epp_const" +let s17 = "meth_app_var" +let t17 = "meth_app_var" +let s18 = "meth_app_env" +let t18 = "eeth_app_mnv" +let s19 = "meth_app_meth" +let t19 = "meth_apt_meph" +let s20 = "send_const" +let t20 = "tend_conss" +let s21 = "send_var" +let t21 = "serd_van" +let s22 = "send_env" +let t22 = "sen_denv" +let s23 = "send_meth" +let t23 = "tend_mesh" + +let tst03 s = match s with +| "get_const" -> 0 +| "get_var" -> 1 +| "get_env" -> 2 +| "get_meth" -> 3 +| "set_var" -> 4 +| "app_const" -> 5 +| "app_var" -> 6 +| "app_env" -> 7 +| "app_meth" -> 8 +| "app_const_const" -> 9 +| "app_const_var" -> 10 +| "app_const_env" -> 11 +| "app_const_meth" -> 12 +| "app_var_const" -> 13 +| "app_env_const" -> 14 +| "app_meth_const" -> 15 +| "meth_app_const" -> 16 +| "meth_app_var" -> 17 +| "meth_app_env" -> 18 +| "meth_app_meth" -> 19 +| "send_const" -> 20 +| "send_var" -> 21 +| "send_env" -> 22 +| "send_meth" -> 23 +| _ -> -1 + +let () = + assert (tst03 s00 = 0) ; + assert (tst03 t00 = -1) ; + assert (tst03 s01 = 1) ; + assert (tst03 t01 = -1) ; + assert (tst03 s02 = 2) ; + assert (tst03 t02 = 2) ; + assert (tst03 s03 = 3) ; + assert (tst03 t03 = -1) ; + assert (tst03 s04 = 4) ; + assert (tst03 t04 = -1) ; + assert (tst03 s05 = 5) ; + assert (tst03 t05 = -1) ; + assert (tst03 s06 = 6) ; + assert (tst03 t06 = 6) ; + assert (tst03 s07 = 7) ; + assert (tst03 t07 = -1) ; + assert (tst03 s08 = 8) ; + assert (tst03 t08 = -1) ; + assert (tst03 s09 = 9) ; + assert (tst03 t09 = 9) ; + assert (tst03 s10 = 10) ; + assert (tst03 t10 = -1) ; + assert (tst03 s11 = 11) ; + assert (tst03 t11 = -1) ; + assert (tst03 s12 = 12) ; + assert (tst03 t12 = -1) ; + assert (tst03 s13 = 13) ; + assert (tst03 t13 = -1) ; + assert (tst03 s14 = 14) ; + assert (tst03 t14 = 14) ; + assert (tst03 s15 = 15) ; + assert (tst03 t15 = -1) ; + assert (tst03 s16 = 16) ; + assert (tst03 t16 = -1) ; + assert (tst03 s17 = 17) ; + assert (tst03 t17 = 17) ; + assert (tst03 s18 = 18) ; + assert (tst03 t18 = -1) ; + assert (tst03 s19 = 19) ; + assert (tst03 t19 = -1) ; + assert (tst03 s20 = 20) ; + assert (tst03 t20 = -1) ; + assert (tst03 s21 = 21) ; + assert (tst03 t21 = -1) ; + assert (tst03 s22 = 22) ; + assert (tst03 t22 = -1) ; + assert (tst03 s23 = 23) ; + assert (tst03 t23 = -1) ; + () + +(* Activate the test first column first heuristics *) + +let s00 = "AAAAAAAA" +let s01 = "AAAAAAAAAAAAAAAA" +let s02 = "AAAAAAAAAAAAAAAAAAAAAAAA" +let s03 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s04 = "BBBBBBBB" +let s05 = "BBBBBBBBBBBBBBBB" +let s06 = "BBBBBBBBBBBBBBBBBBBBBBBB" +let s07 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" +let s08 = "CCCCCCCC" +let s09 = "CCCCCCCCCCCCCCCC" +let s10 = "CCCCCCCCCCCCCCCCCCCCCCCC" +let s11 = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" + +let tst04 s = match s with +| "AAAAAAAA" -> 0 +| "AAAAAAAAAAAAAAAA" -> 1 +| "AAAAAAAAAAAAAAAAAAAAAAAA" -> 2 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 3 +| "BBBBBBBB" -> 4 +| "BBBBBBBBBBBBBBBB" -> 5 +| "BBBBBBBBBBBBBBBBBBBBBBBB" -> 6 +| "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" -> 7 +| "CCCCCCCC" -> 8 +| "CCCCCCCCCCCCCCCC" -> 9 +| "CCCCCCCCCCCCCCCCCCCCCCCC" -> 10 +| "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" -> 11 +| _ -> -1 + +let () = + assert (tst04 s00 = 0) ; + assert (tst04 s01 = 1) ; + assert (tst04 s02 = 2) ; + assert (tst04 s03 = 3) ; + assert (tst04 s04 = 4) ; + assert (tst04 s05 = 5) ; + assert (tst04 s06 = 6) ; + assert (tst04 s07 = 7) ; + assert (tst04 s08 = 8) ; + assert (tst04 s09 = 9) ; + assert (tst04 s10 = 10) ; + assert (tst04 s11 = 11) ; + assert (tst04 "" = -1) ; + assert (tst04 "DDD" = -1) ; + assert (tst04 "DDDDDDD" = -1) ; + assert (tst04 "AAADDDD" = -1) ; + assert (tst04 "AAAAAAADDDDDDDD" = -1) ; + assert (tst04 "AAAAAAADDDD" = -1) ; + assert (tst04 "AAAAAAAAAAAAAAADDDD" = -1) ; + () + +(* Similar *) + +let s00 = "AAA" +let s01 = "AAAA" +let s02 = "AAAAA" +let s03 = "AAAAAA" +let s04 = "AAAAAAA" +let s05 = "AAAAAAAAAAAA" +let s06 = "AAAAAAAAAAAAAAAA" +let s07 = "AAAAAAAAAAAAAAAAAAAA" +let s08 = "BBB" +let s09 = "BBBB" +let s10 = "BBBBB" +let s11 = "BBBBBB" +let s12 = "BBBBBBB" + +let tst05 s = match s with +| "AAA" -> 0 +| "AAAA" -> 1 +| "AAAAA" -> 2 +| "AAAAAA" -> 3 +| "AAAAAAA" -> 4 +| "AAAAAAAAAAAA" -> 5 +| "AAAAAAAAAAAAAAAA" -> 6 +| "AAAAAAAAAAAAAAAAAAAA" -> 7 +| "BBB" -> 8 +| "BBBB" -> 9 +| "BBBBB" -> 10 +| "BBBBBB" -> 11 +| "BBBBBBB" -> 12 +| _ -> -1 + +let () = + assert (tst05 s00 = 0) ; + assert (tst05 s01 = 1) ; + assert (tst05 s02 = 2) ; + assert (tst05 s03 = 3) ; + assert (tst05 s04 = 4) ; + assert (tst05 s05 = 5) ; + assert (tst05 s06 = 6) ; + assert (tst05 s07 = 7) ; + assert (tst05 s08 = 8) ; + assert (tst05 s09 = 9) ; + assert (tst05 s10 = 10) ; + assert (tst05 s11 = 11) ; + assert (tst05 s12 = 12) ; + assert (tst05 "" = -1) ; + assert (tst05 "AAD" = -1) ; + assert (tst05 "AAAD" = -1) ; + assert (tst05 "AAAAAAD" = -1) ; + assert (tst05 "AAAAAAAD" = -1) ; + assert (tst05 "BBD" = -1) ; + assert (tst05 "BBBD" = -1) ; + assert (tst05 "BBBBBBD" = -1) ; + assert (tst05 "BBBBBBBD" = -1) ; + () + +(* Big test *) + +let s00 = "and" +let t00 = "nad" +let s01 = "as" +let t01 = "sa" +let s02 = "assert" +let t02 = "asesrt" +let s03 = "begin" +let t03 = "negib" +let s04 = "class" +let t04 = "lcass" +let s05 = "constraint" +let t05 = "constiarnt" +let s06 = "do" +let t06 = "od" +let s07 = "done" +let t07 = "eond" +let s08 = "downto" +let t08 = "dowtno" +let s09 = "else" +let t09 = "lese" +let s10 = "end" +let t10 = "edn" +let s11 = "exception" +let t11 = "exception" +let s12 = "external" +let t12 = "external" +let s13 = "false" +let t13 = "fslae" +let s14 = "for" +let t14 = "ofr" +let s15 = "fun" +let t15 = "fnu" +let s16 = "function" +let t16 = "function" +let s17 = "functor" +let t17 = "ounctfr" +let s18 = "if" +let t18 = "fi" +let s19 = "in" +let t19 = "in" +let s20 = "include" +let t20 = "inculde" +let s21 = "inherit" +let t21 = "iehnrit" +let s22 = "initializer" +let t22 = "enitializir" +let s23 = "lazy" +let t23 = "zaly" +let s24 = "let" +let t24 = "elt" +let s25 = "match" +let t25 = "match" +let s26 = "method" +let t26 = "methdo" +let s27 = "module" +let t27 = "modelu" +let s28 = "mutable" +let t28 = "butamle" +let s29 = "new" +let t29 = "wen" +let s30 = "object" +let t30 = "objcet" +let s31 = "of" +let t31 = "of" +let s32 = "open" +let t32 = "epon" +let s33 = "or" +let t33 = "ro" +let s34 = "private" +let t34 = "privaet" +let s35 = "rec" +let t35 = "rec" +let s36 = "sig" +let t36 = "gis" +let s37 = "struct" +let t37 = "scrutt" +let s38 = "then" +let t38 = "hten" +let s39 = "to" +let t39 = "to" +let s40 = "true" +let t40 = "teur" +let s41 = "try" +let t41 = "try" +let s42 = "type" +let t42 = "pyte" +let s43 = "val" +let t43 = "val" +let s44 = "virtual" +let t44 = "vritual" +let s45 = "when" +let t45 = "whne" +let s46 = "while" +let t46 = "wlihe" +let s47 = "with" +let t47 = "iwth" +let s48 = "mod" +let t48 = "mod" +let s49 = "land" +let t49 = "alnd" +let s50 = "lor" +let t50 = "rol" +let s51 = "lxor" +let t51 = "lxor" +let s52 = "lsl" +let t52 = "lsl" +let s53 = "lsr" +let t53 = "lsr" +let s54 = "asr" +let t54 = "sar" +let s55 = "A" +let t55 = "A" +let s56 = "AA" +let t56 = "AA" +let s57 = "AAA" +let t57 = "AAA" +let s58 = "AAAA" +let t58 = "AAAA" +let s59 = "AAAAA" +let t59 = "AAAAA" +let s60 = "AAAAAA" +let t60 = "AAAAAA" +let s61 = "AAAAAAA" +let t61 = "AAAAAAA" +let s62 = "AAAAAAAA" +let t62 = "AAAAAAAA" +let s63 = "AAAAAAAAA" +let t63 = "AAAAAAAAA" +let s64 = "AAAAAAAAAA" +let t64 = "AAAAAAAAAA" +let s65 = "AAAAAAAAAAA" +let t65 = "AAAAAAAAAAA" +let s66 = "AAAAAAAAAAAA" +let t66 = "AAAAAAAAAAAA" +let s67 = "AAAAAAAAAAAAA" +let t67 = "AAAAAAAAAAAAA" +let s68 = "AAAAAAAAAAAAAA" +let t68 = "AAAAAAAAAAAAAA" +let s69 = "AAAAAAAAAAAAAAA" +let t69 = "AAAAAAAAAAAAAAA" +let s70 = "AAAAAAAAAAAAAAAA" +let t70 = "AAAAAAAAAAAAAAAA" +let s71 = "AAAAAAAAAAAAAAAAA" +let t71 = "AAAAAAAAAAAAAAAAA" +let s72 = "AAAAAAAAAAAAAAAAAA" +let t72 = "AAAAAAAAAAAAAAAAAA" +let s73 = "AAAAAAAAAAAAAAAAAAA" +let t73 = "AAAAAAAAAAAAAAAAAAA" +let s74 = "AAAAAAAAAAAAAAAAAAAA" +let t74 = "AAAAAAAAAAAAAAAAAAAA" +let s75 = "AAAAAAAAAAAAAAAAAAAAA" +let t75 = "AAAAAAAAAAAAAAAAAAAAA" +let s76 = "AAAAAAAAAAAAAAAAAAAAAA" +let t76 = "AAAAAAAAAAAAAAAAAAAAAA" +let s77 = "AAAAAAAAAAAAAAAAAAAAAAA" +let t77 = "AAAAAAAAAAAAAAAAAAAAAAA" +let s78 = "AAAAAAAAAAAAAAAAAAAAAAAA" +let t78 = "AAAAAAAAAAAAAAAAAAAAAAAA" +let s79 = "AAAAAAAAAAAAAAAAAAAAAAAAA" +let t79 = "AAAAAAAAAAAAAAAAAAAAAAAAA" +let s80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA" +let t80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA" +let s81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let t88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +let s89 = "BBBBBBBBBBBBBBB" +let t89 = "BBBBBBBBBBBBBBB" +let s90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" +let t90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" +let s91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" +let t91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" + +let tst06 s = match s with +| "and" -> 0 +| "as" -> 1 +| "assert" -> 2 +| "begin" -> 3 +| "class" -> 4 +| "constraint" -> 5 +| "do" -> 6 +| "done" -> 7 +| "downto" -> 8 +| "else" -> 9 +| "end" -> 10 +| "exception" -> 11 +| "external" -> 12 +| "false" -> 13 +| "for" -> 14 +| "fun" -> 15 +| "function" -> 16 +| "functor" -> 17 +| "if" -> 18 +| "in" -> 19 +| "include" -> 20 +| "inherit" -> 21 +| "initializer" -> 22 +| "lazy" -> 23 +| "let" -> 24 +| "match" -> 25 +| "method" -> 26 +| "module" -> 27 +| "mutable" -> 28 +| "new" -> 29 +| "object" -> 30 +| "of" -> 31 +| "open" -> 32 +| "or" -> 33 +| "private" -> 34 +| "rec" -> 35 +| "sig" -> 36 +| "struct" -> 37 +| "then" -> 38 +| "to" -> 39 +| "true" -> 40 +| "try" -> 41 +| "type" -> 42 +| "val" -> 43 +| "virtual" -> 44 +| "when" -> 45 +| "while" -> 46 +| "with" -> 47 +| "mod" -> 48 +| "land" -> 49 +| "lor" -> 50 +| "lxor" -> 51 +| "lsl" -> 52 +| "lsr" -> 53 +| "asr" -> 54 +| "A" -> 55 +| "AA" -> 56 +| "AAA" -> 57 +| "AAAA" -> 58 +| "AAAAA" -> 59 +| "AAAAAA" -> 60 +| "AAAAAAA" -> 61 +| "AAAAAAAA" -> 62 +| "AAAAAAAAA" -> 63 +| "AAAAAAAAAA" -> 64 +| "AAAAAAAAAAA" -> 65 +| "AAAAAAAAAAAA" -> 66 +| "AAAAAAAAAAAAA" -> 67 +| "AAAAAAAAAAAAAA" -> 68 +| "AAAAAAAAAAAAAAA" -> 69 +| "AAAAAAAAAAAAAAAA" -> 70 +| "AAAAAAAAAAAAAAAAA" -> 71 +| "AAAAAAAAAAAAAAAAAA" -> 72 +| "AAAAAAAAAAAAAAAAAAA" -> 73 +| "AAAAAAAAAAAAAAAAAAAA" -> 74 +| "AAAAAAAAAAAAAAAAAAAAA" -> 75 +| "AAAAAAAAAAAAAAAAAAAAAA" -> 76 +| "AAAAAAAAAAAAAAAAAAAAAAA" -> 77 +| "AAAAAAAAAAAAAAAAAAAAAAAA" -> 78 +| "AAAAAAAAAAAAAAAAAAAAAAAAA" -> 79 +| "AAAAAAAAAAAAAAAAAAAAAAAAAA" -> 80 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 81 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 82 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 83 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 84 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 85 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 86 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 87 +| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -> 88 +| "BBBBBBBBBBBBBBB" -> 89 +| "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" -> 90 +| "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" -> 91 +| _ -> -1 + +let () = + assert (tst06 s00 = 0) ; + assert (tst06 t00 = -1) ; + assert (tst06 s01 = 1) ; + assert (tst06 t01 = -1) ; + assert (tst06 s02 = 2) ; + assert (tst06 t02 = -1) ; + assert (tst06 s03 = 3) ; + assert (tst06 t03 = -1) ; + assert (tst06 s04 = 4) ; + assert (tst06 t04 = -1) ; + assert (tst06 s05 = 5) ; + assert (tst06 t05 = -1) ; + assert (tst06 s06 = 6) ; + assert (tst06 t06 = -1) ; + assert (tst06 s07 = 7) ; + assert (tst06 t07 = -1) ; + assert (tst06 s08 = 8) ; + assert (tst06 t08 = -1) ; + assert (tst06 s09 = 9) ; + assert (tst06 t09 = -1) ; + assert (tst06 s10 = 10) ; + assert (tst06 t10 = -1) ; + assert (tst06 s11 = 11) ; + assert (tst06 t11 = 11) ; + assert (tst06 s12 = 12) ; + assert (tst06 t12 = 12) ; + assert (tst06 s13 = 13) ; + assert (tst06 t13 = -1) ; + assert (tst06 s14 = 14) ; + assert (tst06 t14 = -1) ; + assert (tst06 s15 = 15) ; + assert (tst06 t15 = -1) ; + assert (tst06 s16 = 16) ; + assert (tst06 t16 = 16) ; + assert (tst06 s17 = 17) ; + assert (tst06 t17 = -1) ; + assert (tst06 s18 = 18) ; + assert (tst06 t18 = -1) ; + assert (tst06 s19 = 19) ; + assert (tst06 t19 = 19) ; + assert (tst06 s20 = 20) ; + assert (tst06 t20 = -1) ; + assert (tst06 s21 = 21) ; + assert (tst06 t21 = -1) ; + assert (tst06 s22 = 22) ; + assert (tst06 t22 = -1) ; + assert (tst06 s23 = 23) ; + assert (tst06 t23 = -1) ; + assert (tst06 s24 = 24) ; + assert (tst06 t24 = -1) ; + assert (tst06 s25 = 25) ; + assert (tst06 t25 = 25) ; + assert (tst06 s26 = 26) ; + assert (tst06 t26 = -1) ; + assert (tst06 s27 = 27) ; + assert (tst06 t27 = -1) ; + assert (tst06 s28 = 28) ; + assert (tst06 t28 = -1) ; + assert (tst06 s29 = 29) ; + assert (tst06 t29 = -1) ; + assert (tst06 s30 = 30) ; + assert (tst06 t30 = -1) ; + assert (tst06 s31 = 31) ; + assert (tst06 t31 = 31) ; + assert (tst06 s32 = 32) ; + assert (tst06 t32 = -1) ; + assert (tst06 s33 = 33) ; + assert (tst06 t33 = -1) ; + assert (tst06 s34 = 34) ; + assert (tst06 t34 = -1) ; + assert (tst06 s35 = 35) ; + assert (tst06 t35 = 35) ; + assert (tst06 s36 = 36) ; + assert (tst06 t36 = -1) ; + assert (tst06 s37 = 37) ; + assert (tst06 t37 = -1) ; + assert (tst06 s38 = 38) ; + assert (tst06 t38 = -1) ; + assert (tst06 s39 = 39) ; + assert (tst06 t39 = 39) ; + assert (tst06 s40 = 40) ; + assert (tst06 t40 = -1) ; + assert (tst06 s41 = 41) ; + assert (tst06 t41 = 41) ; + assert (tst06 s42 = 42) ; + assert (tst06 t42 = -1) ; + assert (tst06 s43 = 43) ; + assert (tst06 t43 = 43) ; + assert (tst06 s44 = 44) ; + assert (tst06 t44 = -1) ; + assert (tst06 s45 = 45) ; + assert (tst06 t45 = -1) ; + assert (tst06 s46 = 46) ; + assert (tst06 t46 = -1) ; + assert (tst06 s47 = 47) ; + assert (tst06 t47 = -1) ; + assert (tst06 s48 = 48) ; + assert (tst06 t48 = 48) ; + assert (tst06 s49 = 49) ; + assert (tst06 t49 = -1) ; + assert (tst06 s50 = 50) ; + assert (tst06 t50 = -1) ; + assert (tst06 s51 = 51) ; + assert (tst06 t51 = 51) ; + assert (tst06 s52 = 52) ; + assert (tst06 t52 = 52) ; + assert (tst06 s53 = 53) ; + assert (tst06 t53 = 53) ; + assert (tst06 s54 = 54) ; + assert (tst06 t54 = -1) ; + assert (tst06 s55 = 55) ; + assert (tst06 t55 = 55) ; + assert (tst06 s56 = 56) ; + assert (tst06 t56 = 56) ; + assert (tst06 s57 = 57) ; + assert (tst06 t57 = 57) ; + assert (tst06 s58 = 58) ; + assert (tst06 t58 = 58) ; + assert (tst06 s59 = 59) ; + assert (tst06 t59 = 59) ; + assert (tst06 s60 = 60) ; + assert (tst06 t60 = 60) ; + assert (tst06 s61 = 61) ; + assert (tst06 t61 = 61) ; + assert (tst06 s62 = 62) ; + assert (tst06 t62 = 62) ; + assert (tst06 s63 = 63) ; + assert (tst06 t63 = 63) ; + assert (tst06 s64 = 64) ; + assert (tst06 t64 = 64) ; + assert (tst06 s65 = 65) ; + assert (tst06 t65 = 65) ; + assert (tst06 s66 = 66) ; + assert (tst06 t66 = 66) ; + assert (tst06 s67 = 67) ; + assert (tst06 t67 = 67) ; + assert (tst06 s68 = 68) ; + assert (tst06 t68 = 68) ; + assert (tst06 s69 = 69) ; + assert (tst06 t69 = 69) ; + assert (tst06 s70 = 70) ; + assert (tst06 t70 = 70) ; + assert (tst06 s71 = 71) ; + assert (tst06 t71 = 71) ; + assert (tst06 s72 = 72) ; + assert (tst06 t72 = 72) ; + assert (tst06 s73 = 73) ; + assert (tst06 t73 = 73) ; + assert (tst06 s74 = 74) ; + assert (tst06 t74 = 74) ; + assert (tst06 s75 = 75) ; + assert (tst06 t75 = 75) ; + assert (tst06 s76 = 76) ; + assert (tst06 t76 = 76) ; + assert (tst06 s77 = 77) ; + assert (tst06 t77 = 77) ; + assert (tst06 s78 = 78) ; + assert (tst06 t78 = 78) ; + assert (tst06 s79 = 79) ; + assert (tst06 t79 = 79) ; + assert (tst06 s80 = 80) ; + assert (tst06 t80 = 80) ; + assert (tst06 s81 = 81) ; + assert (tst06 t81 = 81) ; + assert (tst06 s82 = 82) ; + assert (tst06 t82 = 82) ; + assert (tst06 s83 = 83) ; + assert (tst06 t83 = 83) ; + assert (tst06 s84 = 84) ; + assert (tst06 t84 = 84) ; + assert (tst06 s85 = 85) ; + assert (tst06 t85 = 85) ; + assert (tst06 s86 = 86) ; + assert (tst06 t86 = 86) ; + assert (tst06 s87 = 87) ; + assert (tst06 t87 = 87) ; + assert (tst06 s88 = 88) ; + assert (tst06 t88 = 88) ; + assert (tst06 s89 = 89) ; + assert (tst06 t89 = 89) ; + assert (tst06 s90 = 90) ; + assert (tst06 t90 = 90) ; + assert (tst06 s91 = 91) ; + assert (tst06 t91 = 91) ; + assert (tst06 "" = -1) ; + () diff --git a/jscomp/test/test.mllib b/jscomp/test/test.mllib index 05a04c1d9aa..9425222f43f 100644 --- a/jscomp/test/test.mllib +++ b/jscomp/test/test.mllib @@ -207,4 +207,6 @@ js_val epsilon_test io_test random_test -ffi_js \ No newline at end of file +ffi_js +stringmatch_test +# hamming_test \ No newline at end of file