| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
 |