diff options
| author | Jack Nagel | 2013-04-02 10:37:59 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-02 13:19:04 -0500 |
| commit | 9dd6d74b44d857d9b5906dffd896d4109229b1df (patch) | |
| tree | c32b31d386b3770f00dfb70118789e628142502d /Library/Homebrew | |
| parent | 2f49fd07b14875e7fad02ee8b8ac93af87ff7f72 (diff) | |
| download | brew-9dd6d74b44d857d9b5906dffd896d4109229b1df.tar.bz2 | |
Add new tests for fails_with DSL
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/test/test_fails_with.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_fails_with.rb b/Library/Homebrew/test/test_fails_with.rb new file mode 100644 index 000000000..2b344cc3d --- /dev/null +++ b/Library/Homebrew/test/test_fails_with.rb @@ -0,0 +1,60 @@ +require 'testing_env' +require 'test/testball' + +class FailsWithTests < Test::Unit::TestCase + class Double < Compiler + attr_accessor :name, :build + end + + def assert_fails_with(cc) + assert @f.new.fails_with?(cc) + end + + def assert_does_not_fail_with(cc) + assert !@f.new.fails_with?(cc) + end + + def fails_with(*args, &block) + @f.send(:fails_with, *args, &block) + end + + def build_cc(sym, build) + cc = Double.new + cc.name = sym + cc.build = build + cc + end + + def setup + @f = Class.new(TestBall) + end + + def test_fails_with_symbol + fails_with :clang + cc = build_cc(:clang, 425) + assert_fails_with cc + end + + def test_fails_with_build + fails_with(:clang) { build 211 } + cc = build_cc(:clang, 318) + assert_does_not_fail_with cc + end + + def test_fails_with_block_without_build + fails_with(:clang) { } + cc = build_cc(:clang, 425) + assert_fails_with cc + end + + def test_multiple_failures + fails_with(:llvm) + fails_with(:clang) + gcc = build_cc(:gcc, 5666) + llvm = build_cc(:llvm, 2336) + clang = build_cc(:clang, 425) + assert_fails_with llvm + assert_fails_with clang + assert_does_not_fail_with gcc + end +end |
