1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 module test_code_index
is test
24 # CodeIndex used in tests
25 var test_index
= new CodeIndex(test_context
)
27 redef fun build_test_env
do
29 for mmodule
in test_model
.mmodules
do
30 test_index
.index_mentity
(mmodule
)
32 test_builder
.paths
.add test_src
35 fun test_find1
is test
do
36 var query
= "import game\n"
37 var matches
= test_index
.match_code
(query
)
38 assert matches
.first
.document
.mentity
.full_name
== "test_prog::test_prog"
41 fun test_find2
is test
do
42 var query
= "import game\nimport rpg\n"
43 var matches
= test_index
.match_code
(query
)
44 assert matches
.first
.document
.mentity
.full_name
== "test_prog::game"
47 fun test_find3
is test
do
48 var query
= "import game\nclass MyGame\nsuper Game\nredef fun start_game do end\nend\n"
49 var matches
= test_index
.match_code
(query
)
50 assert matches
.first
.document
.mentity
.full_name
== "test_prog::game_examples"
53 fun test_find_error
is test
do
55 var matches
= test_index
.match_code
(query
)
56 assert matches
.is_empty