| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  | require "formula" | 
					
						
							|  |  |  | require "cxxstdlib" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe CxxStdlib do | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   let(:clang) { described_class.create(:libstdcxx, :clang) } | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |   let(:gcc6) { described_class.create(:libstdcxx, "gcc-6") } | 
					
						
							|  |  |  |   let(:gcc7) { described_class.create(:libstdcxx, "gcc-7") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   let(:lcxx) { described_class.create(:libcxx, :clang) } | 
					
						
							|  |  |  |   let(:purec) { described_class.create(nil, :clang) } | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   describe "#compatible_with?" do | 
					
						
							|  |  |  |     specify "compatibility with itself" do | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       expect(gcc7).to be_compatible_with(gcc7) | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  |       expect(clang).to be_compatible_with(clang) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "Apple/GNU libstdcxx incompatibility" do | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       expect(clang).not_to be_compatible_with(gcc7) | 
					
						
							|  |  |  |       expect(gcc7).not_to be_compatible_with(clang) | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "GNU cross-version incompatibility" do | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       expect(gcc6).not_to be_compatible_with(gcc7) | 
					
						
							|  |  |  |       expect(gcc7).not_to be_compatible_with(gcc6) | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "libstdcxx and libcxx incompatibility" do | 
					
						
							|  |  |  |       expect(clang).not_to be_compatible_with(lcxx) | 
					
						
							|  |  |  |       expect(lcxx).not_to be_compatible_with(clang) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "compatibility for non-cxx software" do | 
					
						
							|  |  |  |       expect(purec).to be_compatible_with(clang) | 
					
						
							|  |  |  |       expect(clang).to be_compatible_with(purec) | 
					
						
							|  |  |  |       expect(purec).to be_compatible_with(purec) | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       expect(purec).to be_compatible_with(gcc7) | 
					
						
							|  |  |  |       expect(gcc7).to be_compatible_with(purec) | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "#apple_compiler?" do | 
					
						
							|  |  |  |     it "returns true for Apple compilers" do | 
					
						
							|  |  |  |       expect(clang).to be_an_apple_compiler | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "returns false for non-Apple compilers" do | 
					
						
							| 
									
										
										
										
											2019-01-08 19:13:46 +00:00
										 |  |  |       expect(gcc7).not_to be_an_apple_compiler | 
					
						
							| 
									
										
										
										
											2017-02-15 15:38:43 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "#type_string" do | 
					
						
							|  |  |  |     specify "formatting" do | 
					
						
							|  |  |  |       expect(clang.type_string).to eq("libstdc++") | 
					
						
							|  |  |  |       expect(lcxx.type_string).to eq("libc++") | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |