home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (BinaryIntOperationsTest.groovy)

This example Groovy source code file (BinaryIntOperationsTest.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

abstractbytecodetestcase, binaryintoperationstest, iadd, iadd, if_icmpge, if_icmpge, iload, iload, ldc, ldc

The Groovy BinaryIntOperationsTest.groovy source code

package org.codehaus.groovy.classgen.asm

/**
 * @author Guillaume Laforge
 */
class BinaryIntOperationsTest extends AbstractBytecodeTestCase {
    
    void testIntPlus() {
        assert compile("""\
            int i = 1
            int j = 2
            int k = i + j
        """).hasSequence([
                "ILOAD",
                "ILOAD",
                "IADD"
        ])
    }
    
    void testIntCompareLessThan() {
        assert compile("""\
            int i = 0
            if (i < 100) println "true"
        """).hasSequence([
                "ILOAD",
                "LDC 100",
                "IF_ICMPGE"
        ])
    }
    
    void testCompareLessThanInClosure() {
        // GROOVY-4741
        assert """
            int a = 0
            [].each {
                if (a < 0) {}
            }
            true
        """
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy BinaryIntOperationsTest.groovy source code file:

new blog posts

 

Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.