1 /* 2 * Copyright (C) 2014 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 17 // Simple test for field accesses. 18 19 public class Main extends TestCase { main(String[] args)20 public static void main(String[] args) { 21 $opt$testAll(); 22 } 23 $opt$testAll()24 static void $opt$testAll() { 25 AllFields fields = new AllFields(); 26 27 assertEquals(false, fields.iZ); 28 assertEquals(0, fields.iB); 29 assertEquals(0, fields.iC); 30 assertEquals(0, fields.iI); 31 assertEquals(0, fields.iJ); 32 assertEquals(0, fields.iS); 33 assertNull(fields.iObject); 34 35 long longValue = -1122198787987987987L; 36 fields.iZ = true; 37 fields.iB = -2; 38 fields.iC = 'c'; 39 fields.iI = 42; 40 fields.iJ = longValue; 41 fields.iS = 68; 42 fields.iObject = fields; 43 44 assertEquals(true, fields.iZ); 45 assertEquals(-2, fields.iB); 46 assertEquals('c', fields.iC); 47 assertEquals(42, fields.iI); 48 assertEquals(longValue, fields.iJ); 49 assertEquals(68, fields.iS); 50 assertEquals(fields, fields.iObject); 51 } 52 53 static class AllFields { 54 boolean iZ; 55 byte iB; 56 char iC; 57 double iD; 58 float iF; 59 int iI; 60 long iJ; 61 short iS; 62 Object iObject; 63 } 64 } 65