summary refs log tree commit diff stats
path: root/nimsuggest/tests
diff options
context:
space:
mode:
authorSaem Ghani <saemghani+github@gmail.com>2021-01-24 22:36:47 -0800
committerGitHub <noreply@github.com>2021-01-25 07:36:47 +0100
commitd99ea0082944918f23534cb291f6e6d18e5224b7 (patch)
treea2ffc7f4ec29f930dc4effc4ed6fde59c1338e9a /nimsuggest/tests
parent461a95525e110016597ef45f1dd4c1ac4472170c (diff)
downloadNim-d99ea0082944918f23534cb291f6e6d18e5224b7.tar.gz
fixed nim-lang/nimsuggest#48 type aware sug (#16814)
* suggesting identifiers accounts context over scope (distance)
* key takeaway: context fit is prioritized over a heuristics like scope
Diffstat (limited to 'nimsuggest/tests')
-rw-r--r--nimsuggest/tests/tsug_template.nim6
-rw-r--r--nimsuggest/tests/tsug_typedecl.nim26
2 files changed, 29 insertions, 3 deletions
diff --git a/nimsuggest/tests/tsug_template.nim b/nimsuggest/tests/tsug_template.nim
index 0f258fcc6..15615f0af 100644
--- a/nimsuggest/tests/tsug_template.nim
+++ b/nimsuggest/tests/tsug_template.nim
@@ -6,7 +6,7 @@ tmp#[!]#
 discard """
 $nimsuggest --tester $file
 >sug $1
-sug;;skMacro;;tsug_template.tmpb;;macro (){.noSideEffect, gcsafe, locks: 0.};;$file;;2;;6;;"";;0;;Prefix
-sug;;skConverter;;tsug_template.tmpc;;converter ();;$file;;3;;10;;"";;0;;Prefix
-sug;;skTemplate;;tsug_template.tmpa;;template ();;$file;;1;;9;;"";;0;;Prefix
+sug;;skMacro;;tsug_template.tmpb;;macro (){.noSideEffect, gcsafe, locks: 0.};;$file;;2;;6;;"";;100;;Prefix
+sug;;skConverter;;tsug_template.tmpc;;converter ();;$file;;3;;10;;"";;100;;Prefix
+sug;;skTemplate;;tsug_template.tmpa;;template ();;$file;;1;;9;;"";;100;;Prefix
 """
diff --git a/nimsuggest/tests/tsug_typedecl.nim b/nimsuggest/tests/tsug_typedecl.nim
new file mode 100644
index 000000000..833043d31
--- /dev/null
+++ b/nimsuggest/tests/tsug_typedecl.nim
@@ -0,0 +1,26 @@
+# suggestions for type declarations
+
+from system import string, int, bool
+
+type
+  super = int
+  someType = bool
+
+let str = "hello"
+
+proc main() =
+  let a: s#[!]#
+
+# This output show seq, even though that's not imported. This is due to the
+# entire symbol table, regardless of import visibility is currently being
+# scanned. This is hardly ideal, but changing it with the current level of test
+# coverage is unwise as it might break more than it fixes.
+
+discard """
+$nimsuggest --tester $file
+>sug $1
+sug;;skType;;tsug_typedecl.someType;;someType;;*nimsuggest/tests/tsug_typedecl.nim;;7;;2;;"";;100;;Prefix
+sug;;skType;;tsug_typedecl.super;;super;;*nimsuggest/tests/tsug_typedecl.nim;;6;;2;;"";;100;;Prefix
+sug;;skType;;system.string;;string;;*lib/system.nim;;*;;*;;*;;100;;Prefix
+sug;;skType;;system.seq;;seq;;*lib/system.nim;;*;;*;;*;;100;;Prefix
+"""
\ No newline at end of file