Skip to content

Commit

Permalink
WIP: move tests locally and start bindings to array
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed Jul 13, 2016
1 parent 208f3ec commit 68f337e
Show file tree
Hide file tree
Showing 311 changed files with 844 additions and 1,130 deletions.
1 change: 0 additions & 1 deletion jscomp/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ let stdlib_set = String_set.of_list [
"stdLabels";
"camlinternalLazy";
"map";

(* "std_exit"; *)
(* https://developer.mozilla.org/de/docs/Web/Events/beforeunload *)
"camlinternalMod";
Expand Down
2 changes: 1 addition & 1 deletion jscomp/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ val get_no_any_assert : unit -> bool
(** Internal use *)
val runtime_set : String_set.t
val stdlib_set : String_set.t

(** only used in {!Js_generate_require} *)

val block : string
val int32 : string
Expand Down
5 changes: 5 additions & 0 deletions jscomp/runtime/.runtimedepend
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ caml_string.cmi :
caml_sys.cmi :
caml_utils.cmi :
caml_weak.cmi :
js_array.cmi : js.cmj
js_primitive.cmi : js.cmj
block.cmj : block.cmi
block.cmx : block.cmi
Expand Down Expand Up @@ -80,6 +81,8 @@ curry.cmj : caml_oo.cmi caml_array.cmi
curry.cmx : caml_oo.cmx caml_array.cmx
js.cmj :
js.cmx :
js_array.cmj : js.cmj js_array.cmi
js_array.cmx : js.cmx js_array.cmi
js_float.cmj :
js_float.cmx :
js_int.cmj :
Expand Down Expand Up @@ -156,6 +159,8 @@ curry.cmo : caml_oo.cmi caml_array.cmi
curry.cmj : caml_oo.cmj caml_array.cmj
js.cmo :
js.cmj :
js_array.cmo : js.cmo js_array.cmi
js_array.cmj : js.cmj js_array.cmi
js_float.cmo :
js_float.cmj :
js_int.cmo :
Expand Down
2 changes: 1 addition & 1 deletion jscomp/runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OTHERS= caml_array caml_string \
caml_format caml_md5 caml_queue caml_hash caml_weak\
caml_backtrace caml_int32 caml_gc typed_array \
js_primitive caml_basic caml_oo curry caml_module js_unsafe \
js_string js_float js_obj js_nativeint js_int
js_string js_float js_obj js_nativeint js_int js_array

SOURCE_LIST= $(OTHERS) caml_builtin_exceptions block js

Expand Down
59 changes: 59 additions & 0 deletions jscomp/runtime/js_array.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)


type 'a t = 'a array

class type ['a] _obj = object ('self_type)
method length : int
method toString : unit -> string
method toLocaleString : unit -> string
method concat : 'self_type Js.t -> 'self_type Js.t
method concat_one : 'a -> 'self_type Js.t
method join : string -> string
method slice : int -> int -> 'self_type Js.t
method slice_copy : unit -> 'self_type Js.t
method slice_start : int -> 'self_type Js.t
method indexOf : 'a -> int -> int
method indexOf_start : 'a -> int
method lastIndexOf : 'a -> int -> int
method lastIndexOf_start : 'a -> int
method every : ('a -> int -> Js.boolean [@bs]) -> Js.boolean
method some : ('a -> int -> Js.boolean [@bs]) -> Js.boolean
method forEach : ('a -> 'int -> unit [@bs]) -> unit
method map : ('a -> 'b [@bs]) -> 'b _obj Js.t
method map_i : ('a -> int -> 'b [@bs]) -> 'b _obj Js.t
method filter : ('a -> int -> Js.boolean[@bs]) -> 'self_type Js.t
method reduce : ('a -> 'a -> int -> 'a [@bs]) -> 'a -> 'a
end [@bs]

type 'a obj = 'a _obj Js.t


external as_obj : 'a t -> 'a obj = "%identity"
external as_val : 'a obj -> 'a t = "%identity"




59 changes: 59 additions & 0 deletions jscomp/runtime/js_array.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)


type 'a t = 'a array

class type ['a] _obj = object ('self_type)
method length : int
method toString : unit -> string
method toLocaleString : unit -> string
method concat : 'self_type Js.t -> 'self_type Js.t
method concat_one : 'a -> 'self_type Js.t
method join : string -> string
method slice : int -> int -> 'self_type Js.t
method slice_copy : unit -> 'self_type Js.t
method slice_start : int -> 'self_type Js.t
method indexOf : 'a -> int -> int
method indexOf_start : 'a -> int
method lastIndexOf : 'a -> int -> int
method lastIndexOf_start : 'a -> int
method every : ('a -> int -> Js.boolean [@bs]) -> Js.boolean
method some : ('a -> int -> Js.boolean [@bs]) -> Js.boolean
method forEach : ('a -> 'int -> unit [@bs]) -> unit
method map : ('a -> 'b [@bs]) -> 'b _obj Js.t
method map_i : ('a -> int -> 'b [@bs]) -> 'b _obj Js.t
method filter : ('a -> int -> Js.boolean[@bs]) -> 'self_type Js.t
method reduce : ('a -> 'a -> int -> 'a [@bs]) -> 'a -> 'a
end [@bs]

type 'a obj = 'a _obj Js.t


external as_obj : 'a t -> 'a obj = "%identity"
external as_val : 'a obj -> 'a t = "%identity"




2 changes: 1 addition & 1 deletion jscomp/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $(addsuffix .cmi, $(SOURCE_LIST)): ../runtime/js.cmi


COMPFLAGS+= $(MODULE_FLAGS) -w -40
COMPFLAGS+= -bs-no-version-header -bs-diagnose -bs-cross-module-opt -bs-package-name $(npm_package_name) -bs-package-output lib/js/test/
COMPFLAGS+= -bs-no-version-header -bs-diagnose -bs-cross-module-opt -bs-package-name $(npm_package_name)


$(TESTS): $(CAMLC)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");
var Ext_filename = require("./ext_filename");

var suites = [/* [] */0];
Expand Down
2 changes: 1 addition & 1 deletion lib/js/test/a_list_test.js → jscomp/test/a_list_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");
var Ext_list = require("./ext_list");

var suites_000 = /* tuple */[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Curry = require("../curry");
var Curry = require("../../lib/js/curry");

function g(x) {
return Curry._1(x[0], x);
Expand Down
2 changes: 1 addition & 1 deletion lib/js/test/a_scope_bug.js → jscomp/test/a_scope_bug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Caml_int32 = require("../caml_int32");
var Caml_int32 = require("../../lib/js/caml_int32");

function odd(_z) {
while(true) {
Expand Down
4 changes: 2 additions & 2 deletions lib/js/test/a_string_test.js → jscomp/test/a_string_test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");
var Ext_string = require("./ext_string");
var List = require("../list");
var List = require("../../lib/js/list");

var suites_000 = /* tuple */[
"split",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");

function f(b, _, _n) {
while(true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Curry = require("../curry");
var Block = require("../../lib/js/block");
var Curry = require("../../lib/js/curry");

var g = 7;

Expand Down
10 changes: 5 additions & 5 deletions lib/js/test/arith_lexer.js → jscomp/test/arith_lexer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var Pervasives = require("../pervasives");
var Caml_format = require("../caml_format");
var Lexing = require("../lexing");
var Block = require("../block");
var Curry = require("../curry");
var Pervasives = require("../../lib/js/pervasives");
var Caml_format = require("../../lib/js/caml_format");
var Lexing = require("../../lib/js/lexing");
var Block = require("../../lib/js/block");
var Curry = require("../../lib/js/curry");

var __ocaml_lex_tables = /* record */[
/* lex_base */"\0\0\xf6\xff\xf7\xff\xf8\xff\xf9\xff\xfa\xff\xfb\xff\xfc\xff:\0\x85\0\xff\xff",
Expand Down
6 changes: 3 additions & 3 deletions lib/js/test/arith_parser.js → jscomp/test/arith_parser.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var Caml_builtin_exceptions = require("../caml_builtin_exceptions");
var Block = require("../block");
var Parsing = require("../parsing");
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions");
var Block = require("../../lib/js/block");
var Parsing = require("../../lib/js/parsing");

var yytransl_const = /* array */[
259,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Pervasives = require("../pervasives");
var Pervasives = require("../../lib/js/pervasives");

function str(e) {
switch (e.tag | 0) {
Expand Down
10 changes: 5 additions & 5 deletions lib/js/test/array_test.js → jscomp/test/array_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var Caml_obj = require("../caml_obj");
var Caml_obj = require("../../lib/js/caml_obj");
var Mt = require("./mt");
var Block = require("../block");
var Caml_array = require("../caml_array");
var $$Array = require("../array");
var List = require("../list");
var Block = require("../../lib/js/block");
var Caml_array = require("../../lib/js/caml_array");
var $$Array = require("../../lib/js/array");
var List = require("../../lib/js/list");

function is_sorted(x) {
var len = x.length;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var Mt = require("./mt");
var Offset = require("./offset");
var Mt_global = require("./mt_global");
var Curry = require("../curry");
var Curry = require("../../lib/js/curry");

var count = [0];

Expand Down
6 changes: 3 additions & 3 deletions lib/js/test/bdd.js → jscomp/test/bdd.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var Caml_builtin_exceptions = require("../caml_builtin_exceptions");
var Caml_int32 = require("../caml_int32");
var Caml_array = require("../caml_array");
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions");
var Caml_int32 = require("../../lib/js/caml_int32");
var Caml_array = require("../../lib/js/caml_array");

function $$eval(_bdd, vars) {
while(true) {
Expand Down
4 changes: 2 additions & 2 deletions lib/js/test/bigarray_test.js → jscomp/test/bigarray_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Caml_int32 = require("../caml_int32");
var Bigarray = require("../bigarray");
var Caml_int32 = require("../../lib/js/caml_int32");
var Bigarray = require("../../lib/js/bigarray");

function sum() {
var result = 0;
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/js/test/buffer_test.js → jscomp/test/buffer_test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var Bytes = require("../bytes");
var Bytes = require("../../lib/js/bytes");
var Mt = require("./mt");
var Block = require("../block");
var Buffer = require("../buffer");
var Block = require("../../lib/js/block");
var Buffer = require("../../lib/js/buffer");

var v = "gso";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var Caml_obj = require("../caml_obj");
var Caml_obj = require("../../lib/js/caml_obj");
var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");

var suites_000 = /* tuple */[
"option",
Expand Down
24 changes: 12 additions & 12 deletions lib/js/test/caml_format_test.js → jscomp/test/caml_format_test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';

var Caml_int64 = require("../caml_int64");
var Caml_obj = require("../caml_obj");
var Caml_float = require("../caml_float");
var Pervasives = require("../pervasives");
var Caml_format = require("../caml_format");
var Caml_int64 = require("../../lib/js/caml_int64");
var Caml_obj = require("../../lib/js/caml_obj");
var Caml_float = require("../../lib/js/caml_float");
var Pervasives = require("../../lib/js/pervasives");
var Caml_format = require("../../lib/js/caml_format");
var Mt = require("./mt");
var Block = require("../block");
var Curry = require("../curry");
var Printf = require("../printf");
var Int64 = require("../int64");
var $$Array = require("../array");
var Buffer = require("../buffer");
var Format = require("../format");
var Block = require("../../lib/js/block");
var Curry = require("../../lib/js/curry");
var Printf = require("../../lib/js/printf");
var Int64 = require("../../lib/js/int64");
var $$Array = require("../../lib/js/array");
var Buffer = require("../../lib/js/buffer");
var Format = require("../../lib/js/format");

var of_string = Caml_obj.caml_obj_dup(/* array */[
/* tuple */[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Mt = require("./mt");
var Block = require("../block");
var Block = require("../../lib/js/block");

var suites = [/* [] */0];

Expand Down
Loading

0 comments on commit 68f337e

Please sign in to comment.