|
Groovy example source code file (PrimitiveTypesTest.groovy)
The Groovy PrimitiveTypesTest.groovy source code/* * Copyright 2003-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package groovy class PrimitiveTypesTest extends GroovyTestCase { int getInt() { return 1; } short getShort() { return 1; } boolean getBoolean() { return true; } double getDouble() { return 1.0; } float getFloat() { return 1.0; } byte getByte() { return 1; } long getLong() { return 1; } char getChar() { return 'a'; } int getNextInt(int i) { return i + 1 } short getNextShort(short i) { return i + 1 } void testPrimitiveTypes() { assert 1 == getInt() assert 1 == getShort() assert 1 == getByte() assert 1 == getLong() assert getBoolean() assert getDouble() > 0.99 assert getFloat() > 0.99 assert 'a' == getChar() } void testPrimitiveParameters() { assert getNextInt(1) == 2 assert 3 == getNextInt(2) assert getNextShort((Short) 1) == 2 assert 3 == getNextShort((Short) 2) } static void main(args) { new PrimitiveTypesTest().testPrimitiveTypes() } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy PrimitiveTypesTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.