diff options
| author | Jack Nagel | 2014-08-31 13:40:51 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-08-31 13:40:51 -0500 | 
| commit | 356c391dfb7e56ae9e1eefd43a25827005015225 (patch) | |
| tree | cb0aa073e43f4cfc6dac7a0139deca8abbfb046c /Library/Homebrew/test/test_compiler_failure.rb | |
| parent | 329e357d9acdd7989cb3ba6394f3b4839bb1e83f (diff) | |
| download | brew-356c391dfb7e56ae9e1eefd43a25827005015225.tar.bz2 | |
Rewrite fails_with tests as tests for CompilerFailure
Diffstat (limited to 'Library/Homebrew/test/test_compiler_failure.rb')
| -rw-r--r-- | Library/Homebrew/test/test_compiler_failure.rb | 52 | 
1 files changed, 52 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_compiler_failure.rb b/Library/Homebrew/test/test_compiler_failure.rb new file mode 100644 index 000000000..da656de7f --- /dev/null +++ b/Library/Homebrew/test/test_compiler_failure.rb @@ -0,0 +1,52 @@ +require "testing_env" +require "compilers" + +class CompilerFailureTests < Homebrew::TestCase +  Compiler = Struct.new(:name, :version) + +  def assert_fails_with(compiler, failure) +    assert_operator failure, :===, compiler +  end + +  def refute_fails_with(compiler, failure) +    refute_operator failure, :===, compiler +  end + +  def compiler(name, version) +    Compiler.new(name, version) +  end + +  def create(spec, &block) +    CompilerFailure.create(spec, &block) +  end + +  def test_create_with_symbol +    failure = create(:clang) +    assert_fails_with compiler(:clang, 425), failure +  end + +  def test_create_with_block +    failure = create(:clang) { build 211 } +    assert_fails_with compiler(:clang, 210), failure +    refute_fails_with compiler(:clang, 318), failure +  end + +  def test_create_with_block_without_build +    failure = create(:clang) { } +    assert_fails_with compiler(:clang, 425), failure +  end + +  def test_create_with_hash +    failure = create(:gcc => "4.8") +    assert_fails_with compiler("gcc-4.8", "4.8"), failure +    assert_fails_with compiler("gcc-4.8", "4.8.1"), failure +    refute_fails_with compiler("gcc-4.7", "4.7"), failure +  end + +  def test_create_with_hash_and_version +    failure = create(:gcc => "4.8") { version "4.8.1" } +    assert_fails_with compiler("gcc-4.8", "4.8"), failure +    assert_fails_with compiler("gcc-4.8", "4.8.1"), failure +    refute_fails_with compiler("gcc-4.8", "4.8.2"), failure +  end +end  | 
