This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Exemplos de testes (emulando o modo procedural) em Java */ | |
| /* Arquivo: FatorialTest.java */ | |
| package exercicio13; | |
| import static exercicio13.Fatorial.fatorial; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def total | |
| soma = 0 | |
| itens_orcamento.each {|item| soma += item.total } | |
| soma | |
| end | |
| def total | |
| itens_orcamento.map {|item| item.total }.sum | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getattr(drew, "battle_cry")() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| module BrazilianDate | |
| def use_in_brazilian_format(*fields) | |
| unless methods.include?(:validate_dates) | |
| validate :validate_dates | |
| define_method :validate_dates do | |
| (@date_errors ||= {}).each_pair do |field, message| | |
| errors.add("#{field}_br".to_sym, message) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def should_behave_like_resource(opts = {}) | |
| before :each do | |
| @opts = opts | |
| end | |
| def class_for(str) | |
| str.capitalize.constantize | |
| end | |
| def clazz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| def initialize(&block) | |
| @block = block | |
| end | |
| def call | |
| @block.call | |
| end | |
| alias [] call | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Peca | |
| def self.iniciar | |
| @pecas = (0..6).collect {|lado1| | |
| (lado1..6).collect {|lado2| Peca.new(lado1, lado2) } | |
| }.flatten.shuffle | |
| end | |
| def self.proxima | |
| @pecas.pop | |
| end |
NewerOlder