1# 2# Copyright (C) 2015 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16.class public LMoveResult; 17.super Ljava/lang/Object; 18 19.method public constructor <init>()V 20.registers 1 21 invoke-direct {p0}, Ljava/lang/Object;-><init>()V 22 return-void 23.end method 24 25.method public static run()V 26.registers 8 27 invoke-static {}, LMoveResult;->testZ()V 28 invoke-static {}, LMoveResult;->testB()V 29 invoke-static {}, LMoveResult;->testS()V 30 invoke-static {}, LMoveResult;->testI()V 31 invoke-static {}, LMoveResult;->testC()V 32 invoke-static {}, LMoveResult;->testJ()V 33 invoke-static {}, LMoveResult;->testF()V 34 invoke-static {}, LMoveResult;->testD()V 35 invoke-static {}, LMoveResult;->testL()V 36 37 return-void 38.end method 39 40# Test that booleans are returned correctly via move-result. 41.method public static testZ()V 42 .registers 6 43 44 create-lambda v0, LMoveResult;->lambdaZ(J)Z 45 invoke-lambda v0, {} 46 move-result v2 47 const v3, 1 48 49 if-ne v3, v2, :is_not_equal 50 const-string v4, "(MoveResult) testZ success" 51 goto :end 52 53:is_not_equal 54 const-string v4, "(MoveResult) testZ failed" 55 56:end 57 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 58 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 59 return-void 60 61.end method 62 63# Lambda target for testZ. Always returns "true". 64.method public static lambdaZ(J)Z 65 .registers 3 66 67 const v0, 1 68 return v0 69 70.end method 71 72# Test that bytes are returned correctly via move-result. 73.method public static testB()V 74 .registers 6 75 76 create-lambda v0, LMoveResult;->lambdaB(J)B 77 invoke-lambda v0, {} 78 move-result v2 79 const v3, 15 80 81 if-ne v3, v2, :is_not_equal 82 const-string v4, "(MoveResult) testB success" 83 goto :end 84 85:is_not_equal 86 const-string v4, "(MoveResult) testB failed" 87 88:end 89 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 90 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 91 return-void 92 93.end method 94 95# Lambda target for testB. Always returns "15". 96.method public static lambdaB(J)B 97 .registers 3 # 1 parameters, 2 locals 98 99 const v0, 15 100 return v0 101 102.end method 103 104# Test that shorts are returned correctly via move-result. 105.method public static testS()V 106 .registers 6 107 108 create-lambda v0, LMoveResult;->lambdaS(J)S 109 invoke-lambda v0, {} 110 move-result v2 111 const/16 v3, 31000 112 113 if-ne v3, v2, :is_not_equal 114 const-string v4, "(MoveResult) testS success" 115 goto :end 116 117:is_not_equal 118 const-string v4, "(MoveResult) testS failed" 119 120:end 121 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 122 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 123 return-void 124 125.end method 126 127# Lambda target for testS. Always returns "31000". 128.method public static lambdaS(J)S 129 .registers 3 130 131 const/16 v0, 31000 132 return v0 133 134.end method 135 136# Test that ints are returned correctly via move-result. 137.method public static testI()V 138 .registers 6 139 140 create-lambda v0, LMoveResult;->lambdaI(J)I 141 invoke-lambda v0, {} 142 move-result v2 143 const v3, 128000 144 145 if-ne v3, v2, :is_not_equal 146 const-string v4, "(MoveResult) testI success" 147 goto :end 148 149:is_not_equal 150 const-string v4, "(MoveResult) testI failed" 151 152:end 153 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 154 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 155 return-void 156 157.end method 158 159# Lambda target for testI. Always returns "128000". 160.method public static lambdaI(J)I 161 .registers 3 162 163 const v0, 128000 164 return v0 165 166.end method 167 168# Test that chars are returned correctly via move-result. 169.method public static testC()V 170 .registers 7 171 172 create-lambda v0, LMoveResult;->lambdaC(J)C 173 invoke-lambda v0, {} 174 move-result v2 175 const v3, 65535 176 177 if-ne v3, v2, :is_not_equal 178 const-string v4, "(MoveResult) testC success" 179 goto :end 180 181:is_not_equal 182 const-string v4, "(MoveResult) testC failed" 183 184:end 185 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 186 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 187 return-void 188 189.end method 190 191# Lambda target for testC. Always returns "65535". 192.method public static lambdaC(J)C 193 .registers 3 194 195 const v0, 65535 196 return v0 197 198.end method 199 200# Test that longs are returned correctly via move-result. 201.method public static testJ()V 202 .registers 9 203 204 create-lambda v0, LMoveResult;->lambdaJ(J)J 205 invoke-lambda v0, {} 206 move-result v2 207 const-wide v4, 0xdeadf00dc0ffeeL 208 209 if-ne v4, v2, :is_not_equal 210 const-string v6, "(MoveResult) testJ success" 211 goto :end 212 213:is_not_equal 214 const-string v6, "(MoveResult) testJ failed" 215 216:end 217 sget-object v7, Ljava/lang/System;->out:Ljava/io/PrintStream; 218 invoke-virtual {v7, v6}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 219 return-void 220 221.end method 222 223# Lambda target for testC. Always returns "0xdeadf00dc0ffeeL". 224.method public static lambdaJ(J)J 225 .registers 5 226 227 const-wide v0, 0xdeadf00dc0ffeeL 228 return-wide v0 229 230.end method 231 232# Test that floats are returned correctly via move-result. 233.method public static testF()V 234 .registers 6 235 236 create-lambda v0, LMoveResult;->lambdaF(J)F 237 invoke-lambda v0, {} 238 move-result v2 239 const v3, infinityf 240 241 if-ne v3, v2, :is_not_equal 242 const-string v4, "(MoveResult) testF success" 243 goto :end 244 245:is_not_equal 246 const-string v4, "(MoveResult) testF failed" 247 248:end 249 sget-object v5, Ljava/lang/System;->out:Ljava/io/PrintStream; 250 invoke-virtual {v5, v4}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 251 return-void 252 253.end method 254 255# Lambda target for testF. Always returns "infinityf". 256.method public static lambdaF(J)F 257 .registers 4 258 259 const v0, infinityf 260 return v0 261 262.end method 263 264# Test that doubles are returned correctly via move-result. 265.method public static testD()V 266 .registers 8 267 268 create-lambda v0, LMoveResult;->lambdaD(J)D 269 invoke-lambda v0, {} 270 move-result-wide v2 271 const-wide v4, -infinity 272 273 if-ne v4, v2, :is_not_equal 274 const-string v6, "(MoveResult) testD success" 275 goto :end 276 277:is_not_equal 278 const-string v6, "(MoveResult) testD failed" 279 280:end 281 sget-object v7, Ljava/lang/System;->out:Ljava/io/PrintStream; 282 invoke-virtual {v7, v6}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 283 return-void 284 285.end method 286 287# Lambda target for testD. Always returns "infinity". 288.method public static lambdaD(J)D 289 .registers 5 290 291 const-wide v0, -infinity 292 return-wide v0 293 294.end method 295 296 297# Test that objects are returned correctly via move-result. 298.method public static testL()V 299 .registers 8 300 301 create-lambda v0, LMoveResult;->lambdaL(J)Ljava/lang/String; 302 invoke-lambda v0, {} 303 move-result-object v2 304 const-string v4, "Interned string" 305 306 # relies on string interning returning identical object references 307 if-ne v4, v2, :is_not_equal 308 const-string v6, "(MoveResult) testL success" 309 goto :end 310 311:is_not_equal 312 const-string v6, "(MoveResult) testL failed" 313 314:end 315 sget-object v7, Ljava/lang/System;->out:Ljava/io/PrintStream; 316 invoke-virtual {v7, v6}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 317 return-void 318 319.end method 320 321# Lambda target for testL. Always returns "Interned string" (string). 322.method public static lambdaL(J)Ljava/lang/String; 323 .registers 5 324 325 const-string v0, "Interned string" 326 return-object v0 327 328.end method 329 330 331