diff options
author | Ben Gruver <bgruv@google.com> | 2015-03-17 21:18:19 -0700 |
---|---|---|
committer | Ben Gruver <bgruv@google.com> | 2015-03-17 21:18:19 -0700 |
commit | 1aad736c2052ddcd3b354122079759118b513ddf (patch) | |
tree | 01749ff1e8937ee43e747469172aff6b27de46b1 /baksmali | |
parent | 32e76b181b495b407f2f9ba5b8ffcdd90f4fbf0f (diff) | |
download | smali-1aad736c2052ddcd3b354122079759118b513ddf.tar.gz |
Ensure that sparse switch items are written out in the correct order
Diffstat (limited to 'baksmali')
3 files changed, 104 insertions, 0 deletions
diff --git a/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java b/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java new file mode 100644 index 00000000..48b64b22 --- /dev/null +++ b/baksmali/src/test/java/org/jf/baksmali/SwitchTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.baksmali; + +import org.junit.Test; + +public class SwitchTest extends RoundtripTest { + @Test + public void testUnorderedSparseSwitch() { + runTest("UnorderedSparseSwitch"); + } +} diff --git a/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali b/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali new file mode 100644 index 00000000..6e3d23d4 --- /dev/null +++ b/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchInput.smali @@ -0,0 +1,35 @@ +.class public LUnorderedSparseSwitch; +.super Ljava/lang/Object; + +.method public static test_sparse-switch()V + .registers 1 + + const v0, 13 + + sparse-switch v0, :SparseSwitch + +:Label10 + return-void + +:Label20 + return-void + +:Label15 + return-void + +:Label13 + return-void + +:Label99 + return-void + +# Note: unordered keys +:SparseSwitch + .sparse-switch + 10 -> :Label10 + 20 -> :Label20 + 15 -> :Label15 + 99 -> :Label99 + 13 -> :Label13 + .end sparse-switch +.end method
\ No newline at end of file diff --git a/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali b/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali new file mode 100644 index 00000000..c4c455b6 --- /dev/null +++ b/baksmali/src/test/resources/SwitchTest/UnorderedSparseSwitchOutput.smali @@ -0,0 +1,28 @@ +.class public LUnorderedSparseSwitch; +.super Ljava/lang/Object; +.method public static test_sparse-switch()V +.registers 1 +const v0, 0xd +sparse-switch v0, :sswitch_data_c +:sswitch_6 +return-void +:sswitch_7 +return-void +:sswitch_8 +return-void +:sswitch_9 +return-void +:sswitch_a +return-void +nop + +# Note: ordered keys +:sswitch_data_c +.sparse-switch +0xa -> :sswitch_6 +0xd -> :sswitch_9 +0xf -> :sswitch_8 +0x14 -> :sswitch_7 +0x63 -> :sswitch_a +.end sparse-switch +.end method
\ No newline at end of file |