<commit_before>import com.msgilligan.moneta.NumberCategory
import org.javamoney.moneta.Money
import spock.lang.Specification
import spock.util.mop.ConfineMetaClassChanges
import spock.util.mop.Use

import javax.money.CurrencyUnit
import javax.money.MonetaryAmount
import javax.money.MonetaryCurrencies


/**
 * Tests of currency properties added in NumberCategory
 */
@Use(NumberCategory)
class NumberCategorySpec extends Specification {
    def "can make USD"() {
        when:
        def aBuck = 1.usd

        then:
        aBuck instanceof MonetaryAmount
        aBuck.number == 1
        aBuck.currency == MonetaryCurrencies.getCurrency("USD")
    }

    def "can make EUR"() {
        when:
        def aBuck = 1.eur

        then:
        aBuck instanceof MonetaryAmount
        aBuck.number == 1
        aBuck.currency == MonetaryCurrencies.getCurrency("EUR")
    }

    def "can make any supported currency via propertyMissing"() {
        when:
        def aBuck = 1.jpy

        then:
        aBuck instanceof MonetaryAmount
        aBuck.number == 1
        aBuck.currency == MonetaryCurrencies.getCurrency("JPY")
    }

    def "Undefined currency should throw UnknownCurrencyException"() {
        when:
        def aBuck = 1.invalid

        then:
        javax.money.UnknownCurrencyException e = thrown()
        aBuck == null
    }

    def "Works with decimals"() {
        when:
        def aBuck = 0.99.usd

        then:
        aBuck instanceof MonetaryAmount
        aBuck.number == 0.99
        aBuck.currency == MonetaryCurrencies.getCurrency("USD")
    }

}<commit_msg>Use better var name ‘amount’ rather than ‘aBuck’<commit_after>import com.msgilligan.moneta.NumberCategory
import org.javamoney.moneta.Money
import spock.lang.Specification
import spock.util.mop.ConfineMetaClassChanges
import spock.util.mop.Use

import javax.money.CurrencyUnit
import javax.money.MonetaryAmount
import javax.money.MonetaryCurrencies


/**
 * Tests of currency properties added in NumberCategory
 */
@Use(NumberCategory)
class NumberCategorySpec extends Specification {
    def "can make USD"() {
        when:
        def aBuck = 1.usd

        then:
        aBuck instanceof MonetaryAmount
        aBuck.number == 1
        aBuck.currency == MonetaryCurrencies.getCurrency("USD")
    }

    def "can make EUR"() {
        when:
        def amount = 1.eur

        then:
        amount instanceof MonetaryAmount
        amount.number == 1
        amount.currency == MonetaryCurrencies.getCurrency("EUR")
    }

    def "can make any supported currency via propertyMissing"() {
        when:
        def amount = 1.jpy

        then:
        amount instanceof MonetaryAmount
        amount.number == 1
        amount.currency == MonetaryCurrencies.getCurrency("JPY")
    }

    def "Undefined currency should throw UnknownCurrencyException"() {
        when:
        def amount = 1.invalid

        then:
        javax.money.UnknownCurrencyException e = thrown()
        amount == null
    }

    def "Works with decimals"() {
        when:
        def amount = 0.99.usd

        then:
        amount instanceof MonetaryAmount
        amount.number == 0.99
        amount.currency == MonetaryCurrencies.getCurrency("USD")
    }

}
{'fraction_non_alphanumeric': 0.08577599506325208, 'fraction_numerical': 0.008022215365627893, 'mean_word_length': 2.4126315789473685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7061146', 'n_tokens_mistral': 996, 'n_tokens_neox': 913, 'n_words': 231}