diff options
| author | Amaan Qureshi <amaanq12@gmail.com> | 2023-04-24 19:12:06 -0400 |
|---|---|---|
| committer | Amaan Qureshi <amaanq12@gmail.com> | 2023-04-25 02:37:31 -0400 |
| commit | b39e6bd61590e429b6fd42734f1485b94335af5f (patch) | |
| tree | 941510a65aa47b6456a1cfaf678a03afaeacf942 /tests/indent | |
| parent | feat(smali): update queries from upstream parser (diff) | |
| download | nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar.gz nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar.bz2 nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar.lz nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar.xz nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.tar.zst nvim-treesitter-b39e6bd61590e429b6fd42734f1485b94335af5f.zip | |
chore(smali): add tests
Diffstat (limited to 'tests/indent')
| -rw-r--r-- | tests/indent/smali/array_and_switch.smali | 58 | ||||
| -rw-r--r-- | tests/indent/smali/field.smali | 12 | ||||
| -rw-r--r-- | tests/indent/smali/method.smali | 8 | ||||
| -rw-r--r-- | tests/indent/smali/parameter.smali | 55 | ||||
| -rw-r--r-- | tests/indent/smali_spec.lua | 25 |
5 files changed, 158 insertions, 0 deletions
diff --git a/tests/indent/smali/array_and_switch.smali b/tests/indent/smali/array_and_switch.smali new file mode 100644 index 000000000..3ee3f6d01 --- /dev/null +++ b/tests/indent/smali/array_and_switch.smali @@ -0,0 +1,58 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public testMethod(ILjava/lang/String;)Ljava/lang/String; + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + .annotation system Lyet/another/annotation; + somevalue = 1234 + anothervalue = 3.14159 + .end annotation + + const-string v0, "testing\n123" + + goto switch: + + sget v0, Lbaksmali/test/class;->staticField:I + + switch: + packed-switch v0, pswitch: + + try_start: + const/4 v0, 7 + const v0, 10 + nop + try_end: + .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: + .catchall {try_start: .. try_end:} handler2: + + handler: + + Label10: + Label11: + Label12: + Label13: + return-object v0 + + + + .array-data 4 + 1 2 3 4 5 6 200 + .end array-data + + pswitch: + .packed-switch 10 + Label10: + Label11: + Label12: + Label13: + .end packed-switch + + handler2: + + return-void + +.end method diff --git a/tests/indent/smali/field.smali b/tests/indent/smali/field.smali new file mode 100644 index 000000000..ae48b7b3c --- /dev/null +++ b/tests/indent/smali/field.smali @@ -0,0 +1,12 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.field public static annotationStaticField:Lsome/annotation; = .subannotation Lsome/annotation; + value1 = "test" + value2 = .subannotation Lsome/annotation; + value1 = "test2" + value2 = Lsome/enum; + .end subannotation +.end subannotation diff --git a/tests/indent/smali/method.smali b/tests/indent/smali/method.smali new file mode 100644 index 000000000..2c139b0cb --- /dev/null +++ b/tests/indent/smali/method.smali @@ -0,0 +1,8 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public debugTest(IIIII)V + .registers 10 +.end method diff --git a/tests/indent/smali/parameter.smali b/tests/indent/smali/parameter.smali new file mode 100644 index 000000000..2e54da2f9 --- /dev/null +++ b/tests/indent/smali/parameter.smali @@ -0,0 +1,55 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public debugTest(IIIII)V + .registers 10 + + .parameter "Blah" + .parameter + .parameter "BlahWithAnnotations" + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .annotation runtime La/second/annotation; + .end annotation + .end parameter + .parameter + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .end parameter + .parameter "LastParam" + + .prologue + + nop + nop + + .source "somefile.java" + .line 101 + + nop + + + .line 50 + + .local v0, aNumber:I + const v0, 1234 + .end local v0 + + .source "someotherfile.java" + .line 900 + + const-string v0, "1234" + + .restart local v0 + const v0, 6789 + .end local v0 + + .epilogue + +.end method diff --git a/tests/indent/smali_spec.lua b/tests/indent/smali_spec.lua new file mode 100644 index 000000000..cddc4f9d2 --- /dev/null +++ b/tests/indent/smali_spec.lua @@ -0,0 +1,25 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/smali", { + tabstop = 4, + shiftwidth = 4, + expandtab = false, +}) + +describe("indent Smali:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("field.smali", { on_line = 7, text = 'value1 = "test"', indent = 1 }) + run:new_line("field.smali", { on_line = 10, text = "value2 = Lsome/enum;", indent = 2 }) + run:new_line("array_and_switch.smali", { on_line = 43, text = "1 2 3 4 5 6 200", indent = 2 }) + run:new_line("array_and_switch.smali", { on_line = 48, text = "Label10:", indent = 2 }) + run:new_line("method.smali", { on_line = 7, text = ".registers 10", indent = 1 }) + run:new_line("parameter.smali", { on_line = 20, text = ".annotation runtime Lsome/annotation;", indent = 3 }) + run:new_line("parameter.smali", { on_line = 21, text = 'something = "some value"', indent = 3 }) + end) +end) |
