Fri, 24 Apr 2020 03:58:51 +0100
Merge
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
duke@1 | 26 | * @bug 4102566 |
duke@1 | 27 | * @summary Test access methods for assignment targets. |
duke@1 | 28 | * @author William Maddox (maddox) |
duke@1 | 29 | * |
duke@1 | 30 | * @compile AccessMethodsLHS.java |
duke@1 | 31 | * @run main AccessMethodsLHS |
duke@1 | 32 | */ |
duke@1 | 33 | |
duke@1 | 34 | public class AccessMethodsLHS { |
duke@1 | 35 | |
duke@1 | 36 | static void fail(String msg) throws Exception { |
duke@1 | 37 | throw new Exception("FAIL: " + msg); |
duke@1 | 38 | } |
duke@1 | 39 | |
duke@1 | 40 | static int arg = 123456; |
duke@1 | 41 | |
duke@1 | 42 | private int i; |
duke@1 | 43 | private double d; |
duke@1 | 44 | |
duke@1 | 45 | private void m(int x) throws Exception { |
duke@1 | 46 | System.out.println("called AccessMethodsLHS.m"); |
duke@1 | 47 | if (x != 123456) |
duke@1 | 48 | AccessMethodsLHS.fail("bad argument"); |
duke@1 | 49 | } |
duke@1 | 50 | |
duke@1 | 51 | public static class Bar { |
duke@1 | 52 | private int i; |
duke@1 | 53 | private double d; |
duke@1 | 54 | private String s; |
duke@1 | 55 | |
duke@1 | 56 | private void m(int x) throws Exception { |
duke@1 | 57 | System.out.println("called AccessMethodsLHS.Bar.m"); |
duke@1 | 58 | if (x != 123456) |
duke@1 | 59 | AccessMethodsLHS.fail("bad argument"); |
duke@1 | 60 | } |
duke@1 | 61 | |
duke@1 | 62 | // Static members are permitted in a static inner class. |
duke@1 | 63 | |
duke@1 | 64 | static private int si; |
duke@1 | 65 | static private double sd; |
duke@1 | 66 | static private String ss; |
duke@1 | 67 | |
duke@1 | 68 | static private void sm(int x) throws Exception { |
duke@1 | 69 | System.out.println("called AccessMethodsLHS.Bar.sm"); |
duke@1 | 70 | if (x != 123456) |
duke@1 | 71 | AccessMethodsLHS.fail("bad argument"); |
duke@1 | 72 | } |
duke@1 | 73 | } |
duke@1 | 74 | |
duke@1 | 75 | public static class Baz { |
duke@1 | 76 | private int i; |
duke@1 | 77 | private double d; |
duke@1 | 78 | private String s; |
duke@1 | 79 | |
duke@1 | 80 | private void m(int x) throws Exception { |
duke@1 | 81 | System.out.println("called Baz.m"); |
duke@1 | 82 | if (x != 123456) |
duke@1 | 83 | AccessMethodsLHS.fail("bad argument"); |
duke@1 | 84 | } |
duke@1 | 85 | |
duke@1 | 86 | // Compiler rejects static members here correctly. |
duke@1 | 87 | |
duke@1 | 88 | // static private int si; |
duke@1 | 89 | // static private double sd; |
duke@1 | 90 | // static private String ss; |
duke@1 | 91 | } |
duke@1 | 92 | |
duke@1 | 93 | public class Quux { |
duke@1 | 94 | void DoIt () throws Exception { |
duke@1 | 95 | m(arg); |
duke@1 | 96 | i = 1; |
duke@1 | 97 | d = 1.0; |
duke@1 | 98 | i += 5; |
duke@1 | 99 | i--; |
duke@1 | 100 | } |
duke@1 | 101 | void DoMore(AccessMethodsLHS f) throws Exception { |
duke@1 | 102 | f.m(arg); |
duke@1 | 103 | } |
duke@1 | 104 | } |
duke@1 | 105 | |
duke@1 | 106 | public static class Quem { |
duke@1 | 107 | void DoIt () { |
duke@1 | 108 | // Illegal static refs to non-static vars |
duke@1 | 109 | // i = 1; |
duke@1 | 110 | // d = 1.0; |
duke@1 | 111 | // i += 5; |
duke@1 | 112 | // i--; |
duke@1 | 113 | } |
duke@1 | 114 | } |
duke@1 | 115 | |
duke@1 | 116 | static int effects = 0; |
duke@1 | 117 | |
duke@1 | 118 | static Bar iBar(Bar x) { effects++; return x; } |
duke@1 | 119 | |
duke@1 | 120 | static Baz iBaz(Baz x) { effects++; return x; } |
duke@1 | 121 | |
duke@1 | 122 | static void checkEffects(int i) throws Exception { |
duke@1 | 123 | if (effects != 1) { |
duke@1 | 124 | AccessMethodsLHS.fail("incorrect side-effect behavior (" + effects + "): " + i); |
duke@1 | 125 | } |
duke@1 | 126 | effects = 0; |
duke@1 | 127 | } |
duke@1 | 128 | |
duke@1 | 129 | static public void main(String args[]) throws Exception { |
duke@1 | 130 | |
duke@1 | 131 | Bar b = new Bar(); |
duke@1 | 132 | Baz c = new Baz(); |
duke@1 | 133 | |
duke@1 | 134 | System.out.println("testing assignment"); |
duke@1 | 135 | |
duke@1 | 136 | AccessMethodsLHS f = new AccessMethodsLHS(); |
duke@1 | 137 | |
duke@1 | 138 | Quux q1 = f.new Quux(); |
duke@1 | 139 | q1.DoIt(); |
duke@1 | 140 | q1.DoMore(f); |
duke@1 | 141 | |
duke@1 | 142 | Quem q2 = new Quem(); |
duke@1 | 143 | q2.DoIt(); |
duke@1 | 144 | |
duke@1 | 145 | // *** Static class, Non-static members *** |
duke@1 | 146 | |
duke@1 | 147 | b.m(arg); |
duke@1 | 148 | |
duke@1 | 149 | // Integer (1 word) |
duke@1 | 150 | |
duke@1 | 151 | b.i = 5; |
duke@1 | 152 | System.out.println(b.i); |
duke@1 | 153 | if (b.i != 5) |
duke@1 | 154 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 155 | System.out.println(b.i); |
duke@1 | 156 | |
duke@1 | 157 | |
duke@1 | 158 | if ((b.i += 10) != 15) |
duke@1 | 159 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 160 | System.out.println(b.i); |
duke@1 | 161 | |
duke@1 | 162 | if (b.i != 15) |
duke@1 | 163 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 164 | System.out.println(b.i); |
duke@1 | 165 | |
duke@1 | 166 | b.s = "foo"; |
duke@1 | 167 | if (!(b.s += "bar").equals("foobar")) |
duke@1 | 168 | AccessMethodsLHS.fail("concat-assign result"); |
duke@1 | 169 | System.out.println(b.s); |
duke@1 | 170 | |
duke@1 | 171 | if (!b.s.equals("foobar")) |
duke@1 | 172 | AccessMethodsLHS.fail("concat-assign effect"); |
duke@1 | 173 | System.out.println(b.s); |
duke@1 | 174 | |
duke@1 | 175 | b.s = "foo"; |
duke@1 | 176 | b.s += "bar"; |
duke@1 | 177 | if (!b.s.equals("foobar")) |
duke@1 | 178 | AccessMethodsLHS.fail("concat-assign effect (novalue)"); |
duke@1 | 179 | System.out.println(b.s); |
duke@1 | 180 | |
duke@1 | 181 | b.i = 0; |
duke@1 | 182 | b.i++; |
duke@1 | 183 | if (b.i != 1) |
duke@1 | 184 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 185 | System.out.println(b.i); |
duke@1 | 186 | |
duke@1 | 187 | b.i = 5; |
duke@1 | 188 | if (b.i++ != 5) |
duke@1 | 189 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 190 | if (b.i != 6) |
duke@1 | 191 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 192 | System.out.println(b.i); |
duke@1 | 193 | |
duke@1 | 194 | b.i = 1; |
duke@1 | 195 | --b.i; |
duke@1 | 196 | if (b.i != 0) |
duke@1 | 197 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 198 | |
duke@1 | 199 | b.i = 5; |
duke@1 | 200 | if (--b.i != 4) |
duke@1 | 201 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 202 | if (b.i != 4) |
duke@1 | 203 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 204 | System.out.println(b.i); |
duke@1 | 205 | |
duke@1 | 206 | // Double (2 word) |
duke@1 | 207 | |
duke@1 | 208 | b.d = 5.0; |
duke@1 | 209 | System.out.println(b.d); |
duke@1 | 210 | if (b.d != 5.0) |
duke@1 | 211 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 212 | System.out.println(b.d); |
duke@1 | 213 | |
duke@1 | 214 | if ((b.d += 10) != 15.0) |
duke@1 | 215 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 216 | System.out.println(b.d); |
duke@1 | 217 | |
duke@1 | 218 | if (b.d != 15.0) |
duke@1 | 219 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 220 | System.out.println(b.d); |
duke@1 | 221 | |
duke@1 | 222 | b.d = 0.0; |
duke@1 | 223 | b.d++; |
duke@1 | 224 | if (b.d != 1.0) |
duke@1 | 225 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 226 | System.out.println(b.d); |
duke@1 | 227 | |
duke@1 | 228 | b.d = 5.0; |
duke@1 | 229 | if (b.d++ != 5.0) |
duke@1 | 230 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 231 | if (b.d != 6.0) |
duke@1 | 232 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 233 | System.out.println(b.d); |
duke@1 | 234 | |
duke@1 | 235 | b.d = 1.0; |
duke@1 | 236 | --b.d; |
duke@1 | 237 | if (b.d != 0.0) |
duke@1 | 238 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 239 | |
duke@1 | 240 | b.d = 5.0; |
duke@1 | 241 | if (--b.d != 4.0) |
duke@1 | 242 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 243 | if (b.d != 4.0) |
duke@1 | 244 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 245 | System.out.println(b.d); |
duke@1 | 246 | |
duke@1 | 247 | // Integer (1 word) with side-effects in object reference |
duke@1 | 248 | |
duke@1 | 249 | iBar(b).i = 5; |
duke@1 | 250 | checkEffects(1); |
duke@1 | 251 | System.out.println(b.i); |
duke@1 | 252 | if (b.i != 5) |
duke@1 | 253 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 254 | |
duke@1 | 255 | System.out.println(b.i); |
duke@1 | 256 | |
duke@1 | 257 | if ((iBar(b).i += 10) != 15) |
duke@1 | 258 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 259 | checkEffects(2); |
duke@1 | 260 | System.out.println(b.i); |
duke@1 | 261 | |
duke@1 | 262 | if (b.i != 15) |
duke@1 | 263 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 264 | System.out.println(b.i); |
duke@1 | 265 | |
duke@1 | 266 | b.i = 0; |
duke@1 | 267 | iBar(b).i++; |
duke@1 | 268 | checkEffects(3); |
duke@1 | 269 | if (b.i != 1) |
duke@1 | 270 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 271 | System.out.println(b.i); |
duke@1 | 272 | |
duke@1 | 273 | b.i = 5; |
duke@1 | 274 | if (iBar(b).i++ != 5) |
duke@1 | 275 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 276 | checkEffects(4); |
duke@1 | 277 | if (b.i != 6) |
duke@1 | 278 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 279 | System.out.println(b.i); |
duke@1 | 280 | |
duke@1 | 281 | b.i = 1; |
duke@1 | 282 | --iBar(b).i; |
duke@1 | 283 | checkEffects(5); |
duke@1 | 284 | if (b.i != 0) |
duke@1 | 285 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 286 | |
duke@1 | 287 | b.i = 5; |
duke@1 | 288 | if (--iBar(b).i != 4) |
duke@1 | 289 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 290 | checkEffects(6); |
duke@1 | 291 | if (b.i != 4) |
duke@1 | 292 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 293 | System.out.println(b.i); |
duke@1 | 294 | |
duke@1 | 295 | |
duke@1 | 296 | // *** Static class, Static members *** |
duke@1 | 297 | |
duke@1 | 298 | Bar.sm(arg); |
duke@1 | 299 | |
duke@1 | 300 | // Integer (1 word) |
duke@1 | 301 | |
duke@1 | 302 | Bar.si = 5; |
duke@1 | 303 | System.out.println(Bar.si); |
duke@1 | 304 | if (Bar.si != 5) |
duke@1 | 305 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 306 | System.out.println(Bar.si); |
duke@1 | 307 | |
duke@1 | 308 | if ((Bar.si += 10) != 15) |
duke@1 | 309 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 310 | System.out.println(Bar.si); |
duke@1 | 311 | |
duke@1 | 312 | if (Bar.si != 15) |
duke@1 | 313 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 314 | System.out.println(Bar.si); |
duke@1 | 315 | |
duke@1 | 316 | Bar.ss = "foo"; |
duke@1 | 317 | if (!(Bar.ss += "bar").equals("foobar")) |
duke@1 | 318 | AccessMethodsLHS.fail("concat-assign result"); |
duke@1 | 319 | System.out.println(Bar.ss); |
duke@1 | 320 | |
duke@1 | 321 | if (!Bar.ss.equals("foobar")) |
duke@1 | 322 | AccessMethodsLHS.fail("concat-assign effect"); |
duke@1 | 323 | System.out.println(Bar.ss); |
duke@1 | 324 | |
duke@1 | 325 | Bar.ss = "foo"; |
duke@1 | 326 | Bar.ss += "bar"; |
duke@1 | 327 | if (!Bar.ss.equals("foobar")) |
duke@1 | 328 | AccessMethodsLHS.fail("concat-assign effect (novalue)"); |
duke@1 | 329 | System.out.println(Bar.ss); |
duke@1 | 330 | |
duke@1 | 331 | Bar.si = 0; |
duke@1 | 332 | Bar.si++; |
duke@1 | 333 | if (Bar.si != 1) |
duke@1 | 334 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 335 | System.out.println(Bar.si); |
duke@1 | 336 | |
duke@1 | 337 | Bar.si = 5; |
duke@1 | 338 | if (Bar.si++ != 5) |
duke@1 | 339 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 340 | if (Bar.si != 6) |
duke@1 | 341 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 342 | System.out.println(Bar.si); |
duke@1 | 343 | |
duke@1 | 344 | Bar.si = 1; |
duke@1 | 345 | --Bar.si; |
duke@1 | 346 | if (Bar.si != 0) |
duke@1 | 347 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 348 | |
duke@1 | 349 | Bar.si = 5; |
duke@1 | 350 | if (--Bar.si != 4) |
duke@1 | 351 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 352 | if (Bar.si != 4) |
duke@1 | 353 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 354 | System.out.println(Bar.si); |
duke@1 | 355 | |
duke@1 | 356 | // Double (2 word) |
duke@1 | 357 | |
duke@1 | 358 | Bar.sd = 5.0; |
duke@1 | 359 | System.out.println(Bar.sd); |
duke@1 | 360 | if (Bar.sd != 5.0) |
duke@1 | 361 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 362 | System.out.println(Bar.sd); |
duke@1 | 363 | |
duke@1 | 364 | if ((Bar.sd += 10) != 15.0) |
duke@1 | 365 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 366 | System.out.println(Bar.sd); |
duke@1 | 367 | |
duke@1 | 368 | if (Bar.sd != 15.0) |
duke@1 | 369 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 370 | System.out.println(Bar.sd); |
duke@1 | 371 | |
duke@1 | 372 | Bar.sd = 0.0; |
duke@1 | 373 | Bar.sd++; |
duke@1 | 374 | if (Bar.sd != 1.0) |
duke@1 | 375 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 376 | System.out.println(Bar.sd); |
duke@1 | 377 | |
duke@1 | 378 | Bar.sd = 5.0; |
duke@1 | 379 | if (Bar.sd++ != 5.0) |
duke@1 | 380 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 381 | if (Bar.sd != 6.0) |
duke@1 | 382 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 383 | System.out.println(Bar.sd); |
duke@1 | 384 | |
duke@1 | 385 | Bar.sd = 1.0; |
duke@1 | 386 | --Bar.sd; |
duke@1 | 387 | if (Bar.sd != 0.0) |
duke@1 | 388 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 389 | |
duke@1 | 390 | Bar.sd = 5.0; |
duke@1 | 391 | if (--Bar.sd != 4.0) |
duke@1 | 392 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 393 | if (Bar.sd != 4.0) |
duke@1 | 394 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 395 | System.out.println(Bar.sd); |
duke@1 | 396 | |
duke@1 | 397 | |
duke@1 | 398 | // *** Static class, Static members (invoked via object reference) *** |
duke@1 | 399 | |
duke@1 | 400 | b.sm(arg); |
duke@1 | 401 | |
duke@1 | 402 | iBar(b).sm(arg); |
duke@1 | 403 | checkEffects(101); |
duke@1 | 404 | |
duke@1 | 405 | // Integer (1 word) |
duke@1 | 406 | |
duke@1 | 407 | b.si = 5; |
duke@1 | 408 | System.out.println(b.si); |
duke@1 | 409 | if (b.si != 5) |
duke@1 | 410 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 411 | System.out.println(b.si); |
duke@1 | 412 | |
duke@1 | 413 | if ((b.si += 10) != 15) |
duke@1 | 414 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 415 | System.out.println(b.si); |
duke@1 | 416 | |
duke@1 | 417 | if (b.si != 15) |
duke@1 | 418 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 419 | System.out.println(b.si); |
duke@1 | 420 | |
duke@1 | 421 | b.ss = "foo"; |
duke@1 | 422 | if (!(b.ss += "bar").equals("foobar")) |
duke@1 | 423 | AccessMethodsLHS.fail("concat-assign result"); |
duke@1 | 424 | System.out.println(b.ss); |
duke@1 | 425 | |
duke@1 | 426 | if (!b.ss.equals("foobar")) |
duke@1 | 427 | AccessMethodsLHS.fail("concat-assign effect"); |
duke@1 | 428 | System.out.println(b.ss); |
duke@1 | 429 | |
duke@1 | 430 | b.ss = "foo"; |
duke@1 | 431 | b.ss += "bar"; |
duke@1 | 432 | if (!b.ss.equals("foobar")) |
duke@1 | 433 | AccessMethodsLHS.fail("concat-assign effect (novalue)"); |
duke@1 | 434 | System.out.println(b.ss); |
duke@1 | 435 | |
duke@1 | 436 | b.si = 0; |
duke@1 | 437 | b.si++; |
duke@1 | 438 | if (b.si != 1) |
duke@1 | 439 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 440 | System.out.println(b.si); |
duke@1 | 441 | |
duke@1 | 442 | b.si = 5; |
duke@1 | 443 | if (b.si++ != 5) |
duke@1 | 444 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 445 | if (b.si != 6) |
duke@1 | 446 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 447 | System.out.println(b.si); |
duke@1 | 448 | |
duke@1 | 449 | b.si = 1; |
duke@1 | 450 | --b.si; |
duke@1 | 451 | if (b.si != 0) |
duke@1 | 452 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 453 | |
duke@1 | 454 | b.si = 5; |
duke@1 | 455 | if (--b.si != 4) |
duke@1 | 456 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 457 | if (b.si != 4) |
duke@1 | 458 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 459 | System.out.println(b.si); |
duke@1 | 460 | |
duke@1 | 461 | // Double (2 word) |
duke@1 | 462 | |
duke@1 | 463 | b.sd = 5.0; |
duke@1 | 464 | System.out.println(b.sd); |
duke@1 | 465 | if (b.sd != 5.0) |
duke@1 | 466 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 467 | System.out.println(b.sd); |
duke@1 | 468 | |
duke@1 | 469 | if ((b.sd += 10) != 15.0) |
duke@1 | 470 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 471 | System.out.println(b.sd); |
duke@1 | 472 | |
duke@1 | 473 | if (b.sd != 15.0) |
duke@1 | 474 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 475 | System.out.println(b.sd); |
duke@1 | 476 | |
duke@1 | 477 | b.sd = 0.0; |
duke@1 | 478 | b.sd++; |
duke@1 | 479 | if (b.sd != 1.0) |
duke@1 | 480 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 481 | System.out.println(b.sd); |
duke@1 | 482 | |
duke@1 | 483 | b.sd = 5.0; |
duke@1 | 484 | if (b.sd++ != 5.0) |
duke@1 | 485 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 486 | if (b.sd != 6.0) |
duke@1 | 487 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 488 | System.out.println(b.sd); |
duke@1 | 489 | |
duke@1 | 490 | b.sd = 1.0; |
duke@1 | 491 | --b.sd; |
duke@1 | 492 | if (b.sd != 0.0) |
duke@1 | 493 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 494 | |
duke@1 | 495 | b.sd = 5.0; |
duke@1 | 496 | if (--b.sd != 4.0) |
duke@1 | 497 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 498 | if (b.sd != 4.0) |
duke@1 | 499 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 500 | System.out.println(b.sd); |
duke@1 | 501 | |
duke@1 | 502 | // Integer (1 word) with side-effects in object reference |
duke@1 | 503 | |
duke@1 | 504 | iBar(b).si = 5; |
duke@1 | 505 | checkEffects(7); |
duke@1 | 506 | System.out.println(b.si); |
duke@1 | 507 | if (b.si != 5) |
duke@1 | 508 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 509 | System.out.println(b.si); |
duke@1 | 510 | |
duke@1 | 511 | if ((iBar(b).si += 10) != 15) |
duke@1 | 512 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 513 | checkEffects(8); |
duke@1 | 514 | System.out.println(b.si); |
duke@1 | 515 | |
duke@1 | 516 | if (b.si != 15) |
duke@1 | 517 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 518 | System.out.println(b.si); |
duke@1 | 519 | |
duke@1 | 520 | iBar(b).si = 0; |
duke@1 | 521 | checkEffects(9); |
duke@1 | 522 | iBar(b).si++; |
duke@1 | 523 | checkEffects(10); |
duke@1 | 524 | if (b.si != 1) |
duke@1 | 525 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 526 | System.out.println(b.si); |
duke@1 | 527 | |
duke@1 | 528 | b.si = 5; |
duke@1 | 529 | if (iBar(b).si++ != 5) |
duke@1 | 530 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 531 | checkEffects(11); |
duke@1 | 532 | if (b.si != 6) |
duke@1 | 533 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 534 | System.out.println(b.si); |
duke@1 | 535 | |
duke@1 | 536 | b.si = 1; |
duke@1 | 537 | --iBar(b).si; |
duke@1 | 538 | checkEffects(12); |
duke@1 | 539 | if (b.si != 0) |
duke@1 | 540 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 541 | |
duke@1 | 542 | b.si = 5; |
duke@1 | 543 | if (--iBar(b).si != 4) |
duke@1 | 544 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 545 | checkEffects(13); |
duke@1 | 546 | if (b.si != 4) |
duke@1 | 547 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 548 | System.out.println(b.si); |
duke@1 | 549 | |
duke@1 | 550 | |
duke@1 | 551 | // *** Non-static class, Non-static members *** |
duke@1 | 552 | |
duke@1 | 553 | c.m(arg); |
duke@1 | 554 | |
duke@1 | 555 | iBaz(c).m(arg); |
duke@1 | 556 | checkEffects(102); |
duke@1 | 557 | |
duke@1 | 558 | // Integer (1 word) |
duke@1 | 559 | |
duke@1 | 560 | c.i = 5; |
duke@1 | 561 | System.out.println(c.i); |
duke@1 | 562 | if (c.i != 5) |
duke@1 | 563 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 564 | System.out.println(c.i); |
duke@1 | 565 | |
duke@1 | 566 | if ((c.i += 10) != 15) |
duke@1 | 567 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 568 | System.out.println(c.i); |
duke@1 | 569 | |
duke@1 | 570 | if (c.i != 15) |
duke@1 | 571 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 572 | System.out.println(c.i); |
duke@1 | 573 | |
duke@1 | 574 | c.s = "foo"; |
duke@1 | 575 | if (!(c.s += "bar").equals("foobar")) |
duke@1 | 576 | AccessMethodsLHS.fail("concat-assign result"); |
duke@1 | 577 | System.out.println(c.s); |
duke@1 | 578 | |
duke@1 | 579 | if (!c.s.equals("foobar")) |
duke@1 | 580 | AccessMethodsLHS.fail("concat-assign effect"); |
duke@1 | 581 | System.out.println(c.s); |
duke@1 | 582 | |
duke@1 | 583 | c.s = "foo"; |
duke@1 | 584 | c.s += "bar"; |
duke@1 | 585 | if (!c.s.equals("foobar")) |
duke@1 | 586 | AccessMethodsLHS.fail("concat-assign effect (novalue)"); |
duke@1 | 587 | System.out.println(c.s); |
duke@1 | 588 | |
duke@1 | 589 | c.i = 0; |
duke@1 | 590 | c.i++; |
duke@1 | 591 | if (c.i != 1) |
duke@1 | 592 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 593 | System.out.println(c.i); |
duke@1 | 594 | |
duke@1 | 595 | c.i = 5; |
duke@1 | 596 | if (c.i++ != 5) |
duke@1 | 597 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 598 | if (c.i != 6) |
duke@1 | 599 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 600 | System.out.println(c.i); |
duke@1 | 601 | |
duke@1 | 602 | c.i = 1; |
duke@1 | 603 | --c.i; |
duke@1 | 604 | if (c.i != 0) |
duke@1 | 605 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 606 | |
duke@1 | 607 | c.i = 5; |
duke@1 | 608 | if (--c.i != 4) |
duke@1 | 609 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 610 | if (c.i != 4) |
duke@1 | 611 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 612 | System.out.println(c.i); |
duke@1 | 613 | |
duke@1 | 614 | // Double (2 word) |
duke@1 | 615 | |
duke@1 | 616 | c.d = 5.0; |
duke@1 | 617 | System.out.println(c.d); |
duke@1 | 618 | if (c.d != 5.0) |
duke@1 | 619 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 620 | System.out.println(c.d); |
duke@1 | 621 | |
duke@1 | 622 | if ((c.d += 10) != 15.0) |
duke@1 | 623 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 624 | System.out.println(c.d); |
duke@1 | 625 | |
duke@1 | 626 | if (c.d != 15.0) |
duke@1 | 627 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 628 | System.out.println(c.d); |
duke@1 | 629 | |
duke@1 | 630 | c.d = 0.0; |
duke@1 | 631 | c.d++; |
duke@1 | 632 | if (c.d != 1.0) |
duke@1 | 633 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 634 | System.out.println(c.d); |
duke@1 | 635 | |
duke@1 | 636 | c.d = 5.0; |
duke@1 | 637 | if (c.d++ != 5.0) |
duke@1 | 638 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 639 | if (c.d != 6.0) |
duke@1 | 640 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 641 | System.out.println(c.d); |
duke@1 | 642 | |
duke@1 | 643 | c.d = 1.0; |
duke@1 | 644 | --c.d; |
duke@1 | 645 | if (c.d != 0.0) |
duke@1 | 646 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 647 | |
duke@1 | 648 | c.d = 5.0; |
duke@1 | 649 | if (--c.d != 4.0) |
duke@1 | 650 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 651 | if (c.d != 4.0) |
duke@1 | 652 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 653 | System.out.println(c.d); |
duke@1 | 654 | |
duke@1 | 655 | // Double (2 word) with side-effects in object reference |
duke@1 | 656 | |
duke@1 | 657 | iBaz(c).d = 5.0; |
duke@1 | 658 | checkEffects(14); |
duke@1 | 659 | System.out.println(c.d); |
duke@1 | 660 | if (c.d != 5.0) |
duke@1 | 661 | AccessMethodsLHS.fail("simple assignment"); |
duke@1 | 662 | System.out.println(c.d); |
duke@1 | 663 | |
duke@1 | 664 | if ((iBaz(c).d += 10) != 15.0) |
duke@1 | 665 | AccessMethodsLHS.fail("add-assign result"); |
duke@1 | 666 | checkEffects(15); |
duke@1 | 667 | System.out.println(c.d); |
duke@1 | 668 | |
duke@1 | 669 | if (c.d != 15.0) |
duke@1 | 670 | AccessMethodsLHS.fail("add-assign effect"); |
duke@1 | 671 | System.out.println(c.d); |
duke@1 | 672 | |
duke@1 | 673 | c.d = 0.0; |
duke@1 | 674 | iBaz(c).d++; |
duke@1 | 675 | checkEffects(16); |
duke@1 | 676 | if (c.d != 1.0) |
duke@1 | 677 | AccessMethodsLHS.fail("post-increment effect"); |
duke@1 | 678 | System.out.println(c.d); |
duke@1 | 679 | |
duke@1 | 680 | c.d = 5.0; |
duke@1 | 681 | if (iBaz(c).d++ != 5.0) |
duke@1 | 682 | AccessMethodsLHS.fail("post-increment result"); |
duke@1 | 683 | checkEffects(17); |
duke@1 | 684 | if (c.d != 6.0) |
duke@1 | 685 | AccessMethodsLHS.fail("post-increment effect (embedded)"); |
duke@1 | 686 | System.out.println(c.d); |
duke@1 | 687 | |
duke@1 | 688 | c.d = 1.0; |
duke@1 | 689 | --iBaz(c).d; |
duke@1 | 690 | checkEffects(18); |
duke@1 | 691 | if (c.d != 0.0) |
duke@1 | 692 | AccessMethodsLHS.fail("pre-decrement effect"); |
duke@1 | 693 | |
duke@1 | 694 | c.d = 5.0; |
duke@1 | 695 | if (--iBaz(c).d != 4.0) |
duke@1 | 696 | AccessMethodsLHS.fail("pre-decrement result"); |
duke@1 | 697 | checkEffects(19); |
duke@1 | 698 | if (c.d != 4.0) |
duke@1 | 699 | AccessMethodsLHS.fail("pre-decrement effect (embedded)"); |
duke@1 | 700 | System.out.println(c.d); |
duke@1 | 701 | |
duke@1 | 702 | // All done. |
duke@1 | 703 | |
duke@1 | 704 | System.out.println("done"); |
duke@1 | 705 | } |
duke@1 | 706 | } |