From d93c87b8dc48077213606750788a77f0954b28b7 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Mon, 5 Feb 2018 10:37:49 +0800 Subject: [PATCH] fix #2489 --- jscomp/bin/all_ounit_tests.ml | 10 +++++++++- jscomp/ext/ext_namespace.ml | 1 + jscomp/ounit_tests/ounit_string_tests.ml | 9 ++++++++- lib/bsb.ml | 1 + lib/bsb_helper.ml | 1 + lib/whole_compiler.ml | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/jscomp/bin/all_ounit_tests.ml b/jscomp/bin/all_ounit_tests.ml index a7874b30ab..a52d7f28ae 100644 --- a/jscomp/bin/all_ounit_tests.ml +++ b/jscomp/bin/all_ounit_tests.ml @@ -13914,6 +13914,7 @@ let namespace_of_package_name (s : string) : string = -> add capital ch ; aux false (off + 1) len + | '/' | '-' -> aux true (off + 1) len | _ -> aux capital (off+1) len @@ -14239,12 +14240,19 @@ let suites = =~ "BsJson" end; __LOC__ >:: begin fun _ -> + let (=~) = OUnit.assert_equal ~printer:(fun x -> x) in Ext_namespace.namespace_of_package_name "reason-react" =~ "ReasonReact"; Ext_namespace.namespace_of_package_name "reason" - =~ "Reason" + =~ "Reason"; + Ext_namespace.namespace_of_package_name + "@aa/bb" + =~"AaBb"; + Ext_namespace.namespace_of_package_name + "@A/bb" + =~"ABb" end; __LOC__ >:: begin fun _ -> Ext_namespace.js_name_of_basename false "a-b" diff --git a/jscomp/ext/ext_namespace.ml b/jscomp/ext/ext_namespace.ml index b8cf73ddf0..abbcad3817 100644 --- a/jscomp/ext/ext_namespace.ml +++ b/jscomp/ext/ext_namespace.ml @@ -122,6 +122,7 @@ let namespace_of_package_name (s : string) : string = -> add capital ch ; aux false (off + 1) len + | '/' | '-' -> aux true (off + 1) len | _ -> aux capital (off+1) len diff --git a/jscomp/ounit_tests/ounit_string_tests.ml b/jscomp/ounit_tests/ounit_string_tests.ml index 40e73c509e..c7a41a9706 100644 --- a/jscomp/ounit_tests/ounit_string_tests.ml +++ b/jscomp/ounit_tests/ounit_string_tests.ml @@ -299,12 +299,19 @@ let suites = =~ "BsJson" end; __LOC__ >:: begin fun _ -> + let (=~) = OUnit.assert_equal ~printer:(fun x -> x) in Ext_namespace.namespace_of_package_name "reason-react" =~ "ReasonReact"; Ext_namespace.namespace_of_package_name "reason" - =~ "Reason" + =~ "Reason"; + Ext_namespace.namespace_of_package_name + "@aa/bb" + =~"AaBb"; + Ext_namespace.namespace_of_package_name + "@A/bb" + =~"ABb" end; __LOC__ >:: begin fun _ -> Ext_namespace.js_name_of_basename false "a-b" diff --git a/lib/bsb.ml b/lib/bsb.ml index 32898f00fc..6910c63a7c 100644 --- a/lib/bsb.ml +++ b/lib/bsb.ml @@ -6577,6 +6577,7 @@ let namespace_of_package_name (s : string) : string = -> add capital ch ; aux false (off + 1) len + | '/' | '-' -> aux true (off + 1) len | _ -> aux capital (off+1) len diff --git a/lib/bsb_helper.ml b/lib/bsb_helper.ml index b716e37a2b..cbea7f2eb2 100644 --- a/lib/bsb_helper.ml +++ b/lib/bsb_helper.ml @@ -4615,6 +4615,7 @@ let namespace_of_package_name (s : string) : string = -> add capital ch ; aux false (off + 1) len + | '/' | '-' -> aux true (off + 1) len | _ -> aux capital (off+1) len diff --git a/lib/whole_compiler.ml b/lib/whole_compiler.ml index 4cb529e89e..7bc7124ce6 100644 --- a/lib/whole_compiler.ml +++ b/lib/whole_compiler.ml @@ -57889,6 +57889,7 @@ let namespace_of_package_name (s : string) : string = -> add capital ch ; aux false (off + 1) len + | '/' | '-' -> aux true (off + 1) len | _ -> aux capital (off+1) len