Permalink
Browse files

searchの結果の型の変更へ対応させた

  • Loading branch information...
1 parent c47552e commit 0ecac34700df7da924d453f4eaaf70150bf68243 @mzp committed Jan 11, 2010
Showing with 36 additions and 20 deletions.
  1. +11 −6 controller.ml
  2. +25 −14 controllerTest.ml
View
@@ -13,9 +13,14 @@ let find_package module_ configs =
in
config.Config.name
-let format configs x =
+let module_ =
+ function [] -> [""]
+ | [x] -> [x]
+ | xs -> HList.init xs
+
+let format configs {Search.id=id; kind=kind} =
let kind, opt =
- match x.Search.kind with
+ match kind with
Search.Value s ->
"value",[ "type", String s]
| Search.Type "" ->
@@ -24,7 +29,7 @@ let format configs x =
"type",[ "is_abstract", Bool false;
"type", String s ]
| Search.Module ->
- "module",[]
+ "module",["module_name", String (String.concat ~sep:"." id)]
| Search.ModuleType ->
"module_type",[]
| Search.Class ->
@@ -34,9 +39,9 @@ let format configs x =
| _ ->
"", []
in
- ["module" , String (String.concat ~sep:"." x.Search.module_);
- "name" , String x.Search.name;
- "package", String (find_package x.Search.module_ configs)]
+ ["module" , String (String.concat ~sep:"." @@ module_ id);
+ "name" , String (HList.last id);
+ "package", String (find_package id configs)]
@ List.map ["value"; "type"; "module"; "module_type"; "class"; "class_type"]
~f:(fun x -> ("is_" ^ x, Bool (x = kind)))
@ opt
View
@@ -34,8 +34,7 @@ let _ = begin "controller.ml" >::: [
"module", String "String";
"type", String "string -> string list -> string";
] @@ Controller.format config {
- Search.name = "concat";
- module_=["String"];
+ Search.id = ["String";"concat"];
kind = Search.Value "string -> string list -> string"}
end;
"type" >:: begin fun () ->
@@ -52,8 +51,7 @@ let _ = begin "controller.ml" >::: [
"is_abstract", Bool false;
"type", String "string";
] @@ Controller.format config {
- Search.name = "t";
- module_=["String"];
+ Search.id = ["String";"t"];
kind = Search.Type "string" };
end;
"abstract type" >:: begin fun () ->
@@ -69,8 +67,7 @@ let _ = begin "controller.ml" >::: [
"module", String "String";
"is_abstract", Bool true;
] @@ Controller.format config {
- Search.name = "t";
- module_=["String"];
+ Search.id = ["String";"t"];
kind = Search.Type "" };
end;
"module" >:: begin fun () ->
@@ -84,10 +81,27 @@ let _ = begin "controller.ml" >::: [
"name", String "String";
"package", String "other package";
"module", String "String";
+ "module_name", String "String";
]
@@ Controller.format config {
- Search.name = "String";
- module_=["String"];
+ Search.id = ["String"];
+ kind = Search.Module }
+ end;
+ "nest module" >:: begin fun () ->
+ ok [
+ "is_value" , Bool false;
+ "is_type" , Bool false;
+ "is_module" , Bool true;
+ "is_module_type", Bool false;
+ "is_class" , Bool false;
+ "is_class_type" , Bool false;
+ "name", String "Foo";
+ "package", String "other package";
+ "module", String "String";
+ "module_name", String "String.Foo";
+ ]
+ @@ Controller.format config {
+ Search.id = ["String"; "Foo"];
kind = Search.Module }
end;
"module type" >:: begin fun () ->
@@ -103,8 +117,7 @@ let _ = begin "controller.ml" >::: [
"module", String "String";
]
@@ Controller.format config {
- Search.name = "String";
- module_=["String"];
+ Search.id = ["String"];
kind = Search.ModuleType }
end;
"class" >:: begin fun () ->
@@ -120,8 +133,7 @@ let _ = begin "controller.ml" >::: [
"module", String "String";
]
@@ Controller.format config {
- Search.name = "String";
- module_=["String"];
+ Search.id=["String"];
kind = Search.Class }
end;
"class type" >:: begin fun () ->
@@ -137,8 +149,7 @@ let _ = begin "controller.ml" >::: [
"module", String "String";
]
@@ Controller.format config {
- Search.name = "String";
- module_=["String"];
+ Search.id=["String"];
kind = Search.ClassType }
end;
"pagenation(first)" >:: begin fun () ->

0 comments on commit 0ecac34

Please sign in to comment.