Source Code Cross Referenced for AutoboxTest.java in  » Ajax » GWT » com » google » gwt » dev » jjs » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » GWT » com.google.gwt.dev.jjs.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.dev.jjs.test;
017:
018:        import com.google.gwt.junit.client.GWTTestCase;
019:
020:        /**
021:         * Tests autoboxing.
022:         */
023:        public class AutoboxTest extends GWTTestCase {
024:
025:            private boolean unboxedBoolean = true;
026:
027:            private byte unboxedByte = (byte) 0xAB;
028:
029:            private char unboxedChar = 'c';
030:
031:            private short unboxedShort = 6550;
032:
033:            private int unboxedInt = 20000000;
034:
035:            private long unboxedLong = 1231231231231L;
036:
037:            private float unboxedFloat = 1.2F;
038:
039:            private double unboxedDouble = 1.2323;
040:
041:            private Boolean boxedBoolean = Boolean.TRUE;
042:
043:            private Byte boxedByte = new Byte((byte) 0xAB);
044:
045:            private Character boxedChar = new Character('c');
046:
047:            private Short boxedShort = new Short((short) 6550);
048:
049:            private Integer boxedInt = new Integer(20000000);
050:
051:            private Long boxedLong = new Long(1231231231231L);
052:
053:            private Float boxedFloat = new Float(1.2F);
054:
055:            private Double boxedDouble = new Double(1.2323);
056:
057:            public String getModuleName() {
058:                return "com.google.gwt.dev.jjs.CompilerSuite";
059:            }
060:
061:            public void testBoxing() {
062:                Boolean boolean_ = unboxedBoolean;
063:                assertTrue(boolean_.booleanValue() == unboxedBoolean);
064:                Byte byte_ = unboxedByte;
065:                assertTrue(byte_.byteValue() == unboxedByte);
066:                Character char_ = unboxedChar;
067:                assertTrue(char_.charValue() == unboxedChar);
068:                Short short_ = unboxedShort;
069:                assertTrue(short_.shortValue() == unboxedShort);
070:                Integer int_ = unboxedInt;
071:                assertTrue(int_.intValue() == unboxedInt);
072:                Long long_ = unboxedLong;
073:                assertTrue(long_.longValue() == unboxedLong);
074:                Float float_ = unboxedFloat;
075:                assertTrue(float_.floatValue() == unboxedFloat);
076:                Double double_ = unboxedDouble;
077:                assertTrue(double_.doubleValue() == unboxedDouble);
078:
079:                // test boxing of return values
080:                assertTrue(box(unboxedBoolean).booleanValue() == unboxedBoolean);
081:                assertTrue(box(unboxedByte).byteValue() == unboxedByte);
082:                assertTrue(box(unboxedShort).shortValue() == unboxedShort);
083:                assertTrue(box(unboxedChar).charValue() == unboxedChar);
084:                assertTrue(box(unboxedInt).intValue() == unboxedInt);
085:                assertTrue(box(unboxedLong).longValue() == unboxedLong);
086:                assertTrue(box(unboxedFloat).floatValue() == unboxedFloat);
087:                assertTrue(box(unboxedDouble).doubleValue() == unboxedDouble);
088:
089:                // test boxing of parameters
090:                assertTrue(unbox(unboxedBoolean) == unboxedBoolean);
091:                assertTrue(unbox(unboxedByte) == unboxedByte);
092:                assertTrue(unbox(unboxedShort) == unboxedShort);
093:                assertTrue(unbox(unboxedChar) == unboxedChar);
094:                assertTrue(unbox(unboxedInt) == unboxedInt);
095:                assertTrue(unbox(unboxedLong) == unboxedLong);
096:                assertTrue(unbox(unboxedFloat) == unboxedFloat);
097:                assertTrue(unbox(unboxedDouble) == unboxedDouble);
098:            }
099:
100:            /* TODO: Determine whether we fully support the JLS spec in regards to
101:             * caching of autoboxed values.
102:             *
103:            public void testCaching() {
104:            }
105:             */
106:
107:            public void testUnboxing() {
108:                boolean boolean_ = boxedBoolean;
109:                assertTrue(boolean_ == boxedBoolean.booleanValue());
110:                byte byte_ = boxedByte;
111:                assertTrue(byte_ == boxedByte.byteValue());
112:                char char_ = boxedChar;
113:                assertTrue(char_ == boxedChar.charValue());
114:                short short_ = boxedShort;
115:                assertTrue(short_ == boxedShort.shortValue());
116:                int int_ = boxedInt;
117:                assertTrue(int_ == boxedInt.intValue());
118:                long long_ = boxedLong;
119:                assertTrue(long_ == boxedLong.longValue());
120:                float float_ = boxedFloat;
121:                assertTrue(float_ == boxedFloat.floatValue());
122:                double double_ = boxedDouble;
123:                assertTrue(double_ == boxedDouble.doubleValue());
124:
125:                // test unboxing of return values
126:                assertTrue(unbox(boxedBoolean) == unboxedBoolean);
127:                assertTrue(unbox(boxedByte) == unboxedByte);
128:                assertTrue(unbox(boxedShort) == unboxedShort);
129:                assertTrue(unbox(boxedChar) == unboxedChar);
130:                assertTrue(unbox(boxedInt) == unboxedInt);
131:                assertTrue(unbox(boxedLong) == unboxedLong);
132:                assertTrue(unbox(boxedFloat) == unboxedFloat);
133:                assertTrue(unbox(boxedDouble) == unboxedDouble);
134:
135:                // test unboxing of parameters
136:                assertTrue(box(boxedBoolean).booleanValue() == unboxedBoolean);
137:                assertTrue(box(boxedByte).byteValue() == unboxedByte);
138:                assertTrue(box(boxedShort).shortValue() == unboxedShort);
139:                assertTrue(box(boxedChar).charValue() == unboxedChar);
140:                assertTrue(box(boxedInt).intValue() == unboxedInt);
141:                assertTrue(box(boxedLong).longValue() == unboxedLong);
142:                assertTrue(box(boxedFloat).floatValue() == unboxedFloat);
143:                assertTrue(box(boxedDouble).doubleValue() == unboxedDouble);
144:            }
145:
146:            private Boolean box(boolean b) {
147:                return b;
148:            }
149:
150:            private Byte box(byte b) {
151:                return b;
152:            }
153:
154:            private Character box(char c) {
155:                return c;
156:            }
157:
158:            private Short box(short s) {
159:                return s;
160:            }
161:
162:            private Integer box(int i) {
163:                return i;
164:            }
165:
166:            private Long box(long l) {
167:                return l;
168:            }
169:
170:            private Float box(float f) {
171:                return f;
172:            }
173:
174:            private Double box(double d) {
175:                return d;
176:            }
177:
178:            private boolean unbox(Boolean b) {
179:                return b;
180:            }
181:
182:            private byte unbox(Byte b) {
183:                return b;
184:            }
185:
186:            private char unbox(Character c) {
187:                return c;
188:            }
189:
190:            private short unbox(Short s) {
191:                return s;
192:            }
193:
194:            private int unbox(Integer i) {
195:                return i;
196:            }
197:
198:            private long unbox(Long l) {
199:                return l;
200:            }
201:
202:            private float unbox(Float f) {
203:                return f;
204:            }
205:
206:            private double unbox(Double d) {
207:                return d;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.