-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make live template contexts more specific
- Loading branch information
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/test/kotlin/org/move/ide/liveTemplates/MvLiveTemplatesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.move.ide.liveTemplates | ||
|
||
import com.intellij.openapi.actionSystem.IdeActions | ||
import org.intellij.lang.annotations.Language | ||
import org.move.utils.tests.MvTestBase | ||
|
||
class MvLiveTemplatesTest: MvTestBase() { | ||
|
||
fun `test no test function in type`() = noSnippet(""" | ||
module 0x1::m { | ||
struct S { val: t/*caret*/} | ||
} | ||
""") | ||
|
||
fun `test no test function in struct fields block`() = noSnippet(""" | ||
module 0x1::m { | ||
struct S { t/*caret*/ } | ||
} | ||
""") | ||
|
||
fun `test no test function in enum variants block`() = noSnippet(""" | ||
module 0x1::m { | ||
enum S { t/*caret*/ } | ||
} | ||
""") | ||
|
||
fun `test no test function in tuple struct type`() = noSnippet(""" | ||
module 0x1::m { | ||
struct S(u8, t/*caret*/) | ||
} | ||
""") | ||
|
||
fun `test no test function in expr`() = noSnippet(""" | ||
module 0x1::m { | ||
fun main() { | ||
t/*caret*/ | ||
} | ||
} | ||
""") | ||
|
||
fun `test no test function outside module`() = noSnippet(""" | ||
t/*caret*/ | ||
module 0x1::m { | ||
} | ||
""") | ||
|
||
fun `test test function in module body`() = expandSnippet(""" | ||
module 0x1::m { | ||
t/*caret*/ | ||
} | ||
""", """ | ||
module 0x1::m { | ||
#[test] | ||
fun /*caret*/() { | ||
} | ||
} | ||
""") | ||
|
||
private fun expandSnippet(@Language("Move") before: String, @Language("Move") after: String) = | ||
checkEditorAction(before, after, IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB) | ||
|
||
private fun noSnippet(@Language("Move") code: String) = expandSnippet(code, code) | ||
} |