5
5
using LibSass . Compiler . Options ;
6
6
using Xunit ;
7
7
using static LibSass . Tests . TestCommonsAndExtensions ;
8
+ using static System . IO . Path ;
9
+ using static System . IO . File ;
8
10
9
11
namespace LibSass . Tests . Spec
10
12
{
@@ -20,7 +22,21 @@ public static void Sass_Specs_Run(string source, string expected, bool error, st
20
22
}
21
23
. Compile ( ) ;
22
24
23
- Assert . Equal ( expected . SpecNormalize ( ) , result . Output . SpecNormalize ( ) ) ;
25
+ if ( ! string . IsNullOrEmpty ( result . ErrorMessage ) )
26
+ {
27
+ Assert . True ( error ) ;
28
+ }
29
+ else
30
+ {
31
+ Assert . False ( error ) ;
32
+ }
33
+
34
+ if ( ! string . IsNullOrEmpty ( expected ) )
35
+ {
36
+ Assert . Equal (
37
+ expected . SpecNormalize ( ) ,
38
+ result . Output . SpecNormalize ( ) ) ;
39
+ }
24
40
}
25
41
26
42
const string SpecInputFile = "input.scss" ;
@@ -50,27 +66,28 @@ private static IEnumerable<object> GetSassSpecDataSuites()
50
66
foreach ( var testDirectory in testDirectories )
51
67
{
52
68
var testPath = testDirectory . FullName ;
53
- var hasErrorFile = File . Exists ( Path . Combine ( testPath , SpecErrorFile ) ) ;
69
+ var hasErrorFile = Exists ( Combine ( testPath , SpecErrorFile ) ) ;
54
70
var hasError = false ;
71
+
55
72
if ( hasErrorFile )
56
73
{
57
- var errorFileContents = File . ReadAllText ( Path . Combine ( testPath , SpecErrorFile ) ) ;
74
+ var errorFileContents = ReadAllText ( Combine ( testPath , SpecErrorFile ) ) ;
58
75
hasError = ! ( errorFileContents . StartsWith ( "DEPRECATION WARNING" ) ||
59
76
errorFileContents . StartsWith ( "WARNING:" ) ||
60
77
Regex . IsMatch ( errorFileContents , @"^.*?\/input.scss:\d+ DEBUG:" ) ) ;
61
78
}
62
79
63
- var inputFile = Path . Combine ( testDirectory . FullName , SpecInputFile ) ;
80
+ var inputFile = Combine ( testDirectory . FullName , SpecInputFile ) ;
64
81
65
- if ( ! File . Exists ( inputFile ) )
82
+ if ( ! Exists ( inputFile ) )
66
83
continue ;
67
84
68
85
yield return new object [ ]
69
86
{
70
87
inputFile ,
71
- File . ReadAllText ( Path . Combine ( testDirectory . FullName , SpecExpectedFile ) ) ,
88
+ ReadAllText ( Combine ( testDirectory . FullName , SpecExpectedFile ) ) ,
72
89
hasErrorFile && hasError ,
73
- new [ ] { testPath , Path . Combine ( testPath , SpecSubDirectory ) }
90
+ new [ ] { testPath , Combine ( testPath , SpecSubDirectory ) }
74
91
} ;
75
92
}
76
93
}
@@ -80,7 +97,8 @@ private static string SpecNormalize(this string input)
80
97
{
81
98
return Regex . Replace ( input , @"\s+" , string . Empty )
82
99
. Replace ( "{\r " , "{" )
83
- . Replace ( "{" , "{\n " ) . Replace ( ";" , ";\n " ) ;
100
+ . Replace ( "{" , "{\n " )
101
+ . Replace ( ";" , ";\n " ) ;
84
102
}
85
103
}
86
104
}
0 commit comments