true 1.0.1 → 2.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +34 -33
- data/VERSION +1 -1
- data/sass/true/_assert.scss +123 -39
- data/sass/true/_messages.scss +24 -5
- data/sass/true/_modules.scss +16 -43
- data/sass/true/_results.scss +134 -8
- data/sass/true/_settings.scss +19 -10
- data/sass/true/_tests.scss +21 -54
- data/sass/true/_utilities.scss +37 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37fe1fa3625dd64810916dbff4ebfb8b00b7dec6
|
4
|
+
data.tar.gz: ae02b6aa2ff13fb3102e494e2d3322832e1a6170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffde38be2ebbe2c7d44b5e8615ae25520b065ccfd39f56c7baf8fc6c21279692c667194e2969e083f9b84a998f8d606968fb2d12c46d7050b7cf1b4b7e2d95df
|
7
|
+
data.tar.gz: 68fc5538a15aa885ad0bf1bcdb04dfea75badd82a85ab59e361c3c47d3f3d78e9b46ea96abf0ad183e79912ce88833ecfa44755ba7ec398043ff6b2f9263617c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
True Changelog
|
2
2
|
==============
|
3
3
|
|
4
|
+
2.0 (unreleased)
|
5
|
+
----------------
|
6
|
+
- Improve internal logic, and namespace private functions behind `_true-*`.
|
7
|
+
- Add `assert()`, `input`, and `expect` mixins for testing CSS output.
|
8
|
+
- Support for LibSass
|
9
|
+
- Simplify output options down to single `$true-terminal-output` setting.
|
10
|
+
|
11
|
+
|
12
|
+
1.0.1 (10/18/14)
|
13
|
+
----------------
|
14
|
+
- LibSass 3.0 compatability.
|
15
|
+
|
16
|
+
|
4
17
|
1.0.0 (10/3/14)
|
5
18
|
---------------
|
6
19
|
- Add command-line interface: `true-cli <path-to-file>`
|
data/README.md
CHANGED
@@ -1,26 +1,20 @@
|
|
1
|
-
[](https://travis-ci.org/ericam/true)
|
2
|
-
|
3
|
-
|
4
1
|
True
|
5
2
|
====
|
6
3
|
|
4
|
+
[](https://travis-ci.org/ericam/true)
|
5
|
+
|
7
6
|
*Verb*
|
8
7
|
|
9
8
|
1. To make true; shape, adjust, place, etc., exactly or accurately:
|
10
9
|
*True the wheels of a bicycle after striking a pothole.*
|
11
10
|
2. To make even, symmetrical, level, etc. (often followed by *up*):
|
12
11
|
*True up the sides of a door.*
|
13
|
-
3. To test your Sass
|
12
|
+
3. To test your Sass code; debug, perfect, etc. (often using *True*):
|
14
13
|
*True your sweet plugin before you deploy.*
|
15
14
|
|
16
15
|
At this point
|
17
|
-
True can only test values,
|
18
|
-
not property/value output.
|
19
|
-
I'm working on output tests as well.
|
20
|
-
For now,
|
21
|
-
use True for logical unit tests,
|
22
|
-
and use version-control for integration testing
|
23
|
-
by comparing changes in output files.
|
16
|
+
True can only test values (e.g. function returns),
|
17
|
+
not property/value output (e.g. mixin output).
|
24
18
|
|
25
19
|
|
26
20
|
Install
|
@@ -28,17 +22,21 @@ Install
|
|
28
22
|
|
29
23
|
in command line:
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
```bash
|
26
|
+
# ruby gem
|
27
|
+
gem install true
|
34
28
|
|
35
|
-
|
29
|
+
# bower package
|
30
|
+
bower install true
|
31
|
+
```
|
36
32
|
|
37
33
|
|
38
34
|
Command Line
|
39
|
-
|
35
|
+
------------
|
40
36
|
|
41
|
-
|
37
|
+
```bash
|
38
|
+
true-cli [options] PATH
|
39
|
+
```
|
42
40
|
|
43
41
|
Options:
|
44
42
|
* `-s` slient
|
@@ -47,7 +45,7 @@ Options:
|
|
47
45
|
|
48
46
|
Config file (optional):
|
49
47
|
|
50
|
-
```
|
48
|
+
```yaml
|
51
49
|
options:
|
52
50
|
color: true #enables colored output
|
53
51
|
|
@@ -78,7 +76,7 @@ Usage
|
|
78
76
|
'Returns the sum of two numeric maps');
|
79
77
|
}
|
80
78
|
|
81
|
-
@include test('
|
79
|
+
@include test('Is Equal [function]') {
|
82
80
|
$test: is-equal(1, 1rem);
|
83
81
|
@include assert-equal($test, false,
|
84
82
|
'Returns false for equal numbers with different units.');
|
@@ -88,19 +86,22 @@ Usage
|
|
88
86
|
'Returns true for numbers that are truely equal.');
|
89
87
|
}
|
90
88
|
}
|
91
|
-
```
|
92
89
|
|
93
|
-
|
94
|
-
|
95
|
-
Here's a sample of the CSS output:
|
96
|
-
|
97
|
-
```css
|
98
|
-
/* ### Utilities ---------- */
|
99
|
-
/* - Map Add [function] (1 Assertions, 1 Passed, 0 Failed) */
|
100
|
-
/* - Strict Equal [function] (2 Assertions, 2 Passed, 0 Failed) */
|
101
|
-
/*
|
102
|
-
*/
|
103
|
-
/* 2 Tests: */
|
104
|
-
/* - 2 Passed */
|
105
|
-
/* - 0 Failed */
|
90
|
+
@include report;
|
106
91
|
```
|
92
|
+
|
93
|
+
Settings
|
94
|
+
--------
|
95
|
+
|
96
|
+
There is only one setting.
|
97
|
+
`$true-terminal-output` controls what output (if any)
|
98
|
+
is shown in the terminal.
|
99
|
+
The default setting is `true`,
|
100
|
+
which will show warnings in the terminal
|
101
|
+
when an assertion fails.
|
102
|
+
You can set it to `false` to turn off all terminal output,
|
103
|
+
or `details` to show more `@debug` info on failures,
|
104
|
+
and a final summary of the results.
|
105
|
+
|
106
|
+
* LibSass doesn't support `@debug`.
|
107
|
+
* The Ruby CLI requires the final summary output.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.alpha.1
|
data/sass/true/_assert.scss
CHANGED
@@ -1,73 +1,157 @@
|
|
1
1
|
// Assert
|
2
2
|
// ======
|
3
3
|
|
4
|
+
|
4
5
|
@mixin assert-true(
|
5
6
|
$assert,
|
6
|
-
$
|
7
|
+
$description: ''
|
7
8
|
) {
|
8
|
-
|
9
|
-
$debug-message: '#{inspect($assert)} is not true';
|
9
|
+
@include _true-assert-start($description);
|
10
10
|
$result: if($assert, pass, fail);
|
11
|
-
|
11
|
+
|
12
|
+
.assert-true {
|
13
|
+
-result: to-upper-case($result);
|
14
|
+
-description: $description;
|
15
|
+
|
16
|
+
@if $result == fail {
|
17
|
+
@include _true-fail-details(true, $assert);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
@include _true-assert-stop($result);
|
12
22
|
}
|
13
23
|
|
24
|
+
|
14
25
|
@mixin assert-false(
|
15
26
|
$assert,
|
16
|
-
$
|
27
|
+
$description: ''
|
17
28
|
) {
|
18
|
-
|
19
|
-
$
|
20
|
-
|
21
|
-
|
29
|
+
@include _true-assert-start($description);
|
30
|
+
$result: if($assert, fail, pass);
|
31
|
+
|
32
|
+
.assert-false {
|
33
|
+
-result: to-upper-case($result);
|
34
|
+
-description: $description;
|
35
|
+
|
36
|
+
@if $result == fail {
|
37
|
+
@include _true-fail-details(false, $assert);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
@include _true-assert-stop($result);
|
22
42
|
}
|
23
43
|
|
44
|
+
|
24
45
|
@mixin assert-equal(
|
25
46
|
$assert,
|
26
47
|
$expected,
|
27
|
-
$
|
48
|
+
$description: ''
|
28
49
|
) {
|
29
|
-
|
30
|
-
$
|
31
|
-
|
32
|
-
|
33
|
-
|
50
|
+
@include _true-assert-start($description);
|
51
|
+
$result: if(_true-is-equal($assert, $expected), pass, fail);
|
52
|
+
|
53
|
+
.assert-equal {
|
54
|
+
-result: to-upper-case($result);
|
55
|
+
-description: $description;
|
56
|
+
|
57
|
+
@if $result == fail {
|
58
|
+
@include _true-fail-details($expected, $assert);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
@include _true-assert-stop($result);
|
34
63
|
}
|
35
64
|
|
65
|
+
|
36
66
|
@mixin assert-unequal(
|
37
67
|
$assert,
|
38
68
|
$expected,
|
39
|
-
$
|
69
|
+
$description: ''
|
70
|
+
) {
|
71
|
+
@include _true-assert-start($description);
|
72
|
+
$result: if(_true-is-equal($assert, $expected), fail, pass);
|
73
|
+
|
74
|
+
.assert-unequal {
|
75
|
+
-result: to-upper-case($result);
|
76
|
+
-description: $description;
|
77
|
+
|
78
|
+
@if $result == fail {
|
79
|
+
@include _true-fail-details($expected, $assert);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
@include _true-assert-stop($result);
|
84
|
+
}
|
85
|
+
|
86
|
+
|
87
|
+
// CSS Output Tests
|
88
|
+
// ----------------
|
89
|
+
|
90
|
+
@mixin assert(
|
91
|
+
$description
|
40
92
|
) {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
93
|
+
@include _true-assert-start($description);
|
94
|
+
|
95
|
+
#{_true-selector(assert)} {
|
96
|
+
@content;
|
97
|
+
}
|
98
|
+
|
99
|
+
@include _true-assert-stop(output-to-css);
|
100
|
+
}
|
101
|
+
|
102
|
+
@mixin input {
|
103
|
+
.input {
|
104
|
+
@content;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
@mixin expect {
|
109
|
+
.expect {
|
110
|
+
@content;
|
111
|
+
}
|
46
112
|
}
|
47
113
|
|
48
|
-
// Pass / Fail
|
49
|
-
// -----------
|
50
114
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
$
|
115
|
+
// Assert Start
|
116
|
+
// ------------
|
117
|
+
|
118
|
+
@mixin _true-assert-start(
|
119
|
+
$name
|
56
120
|
) {
|
57
|
-
@
|
58
|
-
|
121
|
+
@include _true-context(assert, $name);
|
122
|
+
}
|
59
123
|
|
60
|
-
|
61
|
-
|
62
|
-
|
124
|
+
@mixin _true-assert-stop(
|
125
|
+
$result
|
126
|
+
) {
|
127
|
+
@include _true-update(test, $result);
|
128
|
+
@include _true-context(assert, null);
|
129
|
+
}
|
63
130
|
|
64
|
-
@if $fail-message {
|
65
|
-
@warn $fail-message;
|
66
|
-
}
|
67
131
|
|
68
|
-
|
69
|
-
|
132
|
+
// Details
|
133
|
+
// -------
|
134
|
+
|
135
|
+
@mixin _true-fail-details(
|
136
|
+
$expected,
|
137
|
+
$returned,
|
138
|
+
$terminal: $true-terminal-output
|
139
|
+
) {
|
140
|
+
$expected-type: type-of($expected);
|
141
|
+
$returned-type: type-of($returned);
|
142
|
+
|
143
|
+
-expected--#{$expected-type}: _true-inspect($expected);
|
144
|
+
-returned--#{$returned-type}: _true-inspect($returned);
|
145
|
+
|
146
|
+
@if $terminal == details {
|
147
|
+
@debug '[FAIL] #{_true-context(test)} » #{_true-context(assert)}';
|
148
|
+
@debug 'Expected #{$expected-type} »';
|
149
|
+
@debug inspect($expected);
|
150
|
+
@debug 'Returned #{$returned-type} »';
|
151
|
+
@debug inspect($returned);
|
70
152
|
}
|
71
153
|
|
72
|
-
|
154
|
+
@if $terminal {
|
155
|
+
@warn '#{_true-context(test)} » #{_true-context(assert)}';
|
156
|
+
}
|
73
157
|
}
|
data/sass/true/_messages.scss
CHANGED
@@ -3,17 +3,36 @@
|
|
3
3
|
|
4
4
|
$-tnl: "\a ";
|
5
5
|
|
6
|
-
|
6
|
+
|
7
|
+
// Return a CSS selector for the current context
|
8
|
+
@function _true-selector(
|
9
|
+
$scope
|
10
|
+
) {
|
11
|
+
$selector: null;
|
12
|
+
|
13
|
+
@each $layer in $scope {
|
14
|
+
$this: '[data-#{$layer}="#{_true-context($layer)}"]';
|
15
|
+
$selector: if($selector, '#{$selector} #{$this}', $this);
|
16
|
+
}
|
17
|
+
|
18
|
+
@return $selector;
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
// Output a spacer comment
|
23
|
+
@mixin _true-spacer() {
|
7
24
|
/*
|
8
25
|
*/
|
9
26
|
}
|
10
27
|
|
11
|
-
|
28
|
+
|
29
|
+
// Output a message to CSS, Terminal, or Comments
|
30
|
+
@mixin _true-message(
|
12
31
|
$message,
|
13
|
-
$output
|
32
|
+
$output: comments
|
14
33
|
) {
|
15
|
-
$lines: str-split($message, $-tnl);
|
16
|
-
@if index($output,
|
34
|
+
$lines: _true-str-split($message, $-tnl);
|
35
|
+
@if index($output, comments) {
|
17
36
|
@each $line in $lines {
|
18
37
|
/* #{$line} */
|
19
38
|
}
|
data/sass/true/_modules.scss
CHANGED
@@ -1,60 +1,33 @@
|
|
1
1
|
// Test Module
|
2
2
|
// ===========
|
3
3
|
|
4
|
-
$module-results: null;
|
5
4
|
|
6
5
|
@mixin test-module(
|
7
|
-
$name
|
8
|
-
$output: map-get($true, output)
|
6
|
+
$name
|
9
7
|
) {
|
10
|
-
|
11
|
-
@include setup-module($name, $output);
|
8
|
+
@include _true-module-start($name);
|
12
9
|
@content;
|
13
|
-
@include
|
14
|
-
$module-results: null !global;
|
10
|
+
@include _true-module-stop;
|
15
11
|
}
|
16
12
|
|
17
13
|
|
18
|
-
// Module
|
14
|
+
// Module Start (private)
|
19
15
|
// ----------------------
|
20
|
-
@mixin setup-module(
|
21
|
-
$name,
|
22
|
-
$output: map-get($true, output)
|
23
|
-
) {
|
24
|
-
// Initial CSS Output
|
25
|
-
@if index($output, css) {
|
26
|
-
@include result-message('### #{$name} ----------', css);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
@mixin report-module(
|
34
|
-
$name,
|
35
|
-
$module-results,
|
36
|
-
$output: map-get($true, output)
|
17
|
+
@mixin _true-module-start(
|
18
|
+
$name
|
37
19
|
) {
|
20
|
+
@include _true-reset(module);
|
21
|
+
@include _true-context(module, $name);
|
22
|
+
@include _true-message('# #{$name} ----------', comments);
|
23
|
+
}
|
38
24
|
|
39
|
-
// Terminal Results
|
40
|
-
@if index($output, terminal) {
|
41
|
-
$debug-message: '#{$name}: #{report($module-results, Tests)})';
|
42
|
-
@include result-message($debug-message, debug);
|
43
|
-
}
|
44
|
-
|
45
|
-
// CSS Results
|
46
|
-
@if index($output, css) {
|
47
|
-
$run: map-get($module-results, run);
|
48
|
-
$pass: map-get($module-results, pass);
|
49
|
-
$fail: map-get($module-results, fail);
|
50
|
-
|
51
|
-
$css-message: '#{$run} Tests:#{$-tnl} - #{$pass} Passed#{$-tnl} - #{$fail} Failed';
|
52
25
|
|
53
|
-
|
54
|
-
|
55
|
-
@include spacer-comment;
|
56
|
-
}
|
26
|
+
// Module Stop (private)
|
27
|
+
// ---------------------
|
57
28
|
|
58
|
-
|
59
|
-
|
29
|
+
@mixin _true-module-stop {
|
30
|
+
@include _true-update(global, null);
|
31
|
+
@include _true-reset(module);
|
32
|
+
@include _true-context(module, null);
|
60
33
|
}
|
data/sass/true/_results.scss
CHANGED
@@ -1,24 +1,150 @@
|
|
1
1
|
// Results
|
2
2
|
// =======
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
$_true-results-reset: (
|
5
|
+
run: 0,
|
6
|
+
pass: 0,
|
7
|
+
fail: 0,
|
8
|
+
output-to-css: 0,
|
9
|
+
);
|
10
|
+
|
11
|
+
$_true-results: (
|
12
|
+
global: $_true-results-reset,
|
13
|
+
module: $_true-results-reset,
|
14
|
+
test: $_true-results-reset,
|
15
|
+
);
|
16
|
+
|
17
|
+
|
18
|
+
// Reset
|
19
|
+
// -----
|
20
|
+
|
21
|
+
@mixin _true-reset(
|
22
|
+
$scope
|
23
|
+
) {
|
24
|
+
@if $scope == global {
|
25
|
+
$_true-results: (
|
26
|
+
global: $_true-results-reset,
|
27
|
+
module: $_true-results-reset,
|
28
|
+
test: $_true-results-reset,
|
29
|
+
) !global;
|
30
|
+
} @else if $scope == module {
|
31
|
+
$update: (
|
32
|
+
module: $_true-results-reset,
|
33
|
+
test: $_true-results-reset,
|
34
|
+
);
|
35
|
+
$_true-results: map-merge($_true-results, $update) !global;
|
36
|
+
} @else if $scope == test {
|
37
|
+
$update: (
|
38
|
+
test: $_true-results-reset
|
39
|
+
);
|
40
|
+
$_true-results: map-merge($_true-results, $update) !global;
|
41
|
+
} @else {
|
42
|
+
@warn "#{$scope} is not a valid scope for _true-reset().";
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
// Get Results
|
48
|
+
// -----------
|
49
|
+
|
50
|
+
@function _true-get-results(
|
51
|
+
$scope
|
7
52
|
) {
|
53
|
+
@return map-get($_true-results, $scope);
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
// Get Result
|
58
|
+
// ----------
|
59
|
+
|
60
|
+
@function _true-get-result(
|
61
|
+
$scope
|
62
|
+
) {
|
63
|
+
$results: _true-get-results($scope);
|
64
|
+
$return: if(map-get($results, output-to-css) > 0, output-to-css, null);
|
65
|
+
|
66
|
+
@if map-get($results, fail) > 0 {
|
67
|
+
@return if($return, $return fail, fail);
|
68
|
+
} @else if map-get($results, pass) > 0 {
|
69
|
+
@return if($return, $return pass, pass);
|
70
|
+
} @else {
|
71
|
+
@return $return;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
// Update
|
77
|
+
// ------
|
78
|
+
|
79
|
+
@mixin _true-update(
|
80
|
+
$scope,
|
81
|
+
$results
|
82
|
+
) {
|
83
|
+
$current: _true-get-results($scope);
|
84
|
+
$update: (run: 1);
|
85
|
+
|
86
|
+
@if $scope == global {
|
87
|
+
$update: _true-get-results(module);
|
88
|
+
} @else {
|
89
|
+
@each $result in $results {
|
90
|
+
@if $result {
|
91
|
+
$update: map-merge($update, ($result: 1));
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
$scope: ($scope: _true-map-increment($current, $update));
|
97
|
+
$_true-results: map-merge($_true-results, $scope) !global;
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
// Report Message
|
102
|
+
// --------------
|
103
|
+
|
104
|
+
@function _true-report-message(
|
105
|
+
$scope: test,
|
106
|
+
$lines: single
|
107
|
+
) {
|
108
|
+
$results: _true-get-results($scope);
|
8
109
|
$run: map-get($results, run);
|
9
110
|
$pass: map-get($results, pass);
|
10
111
|
$fail: map-get($results, fail);
|
112
|
+
$output-to-css: map-get($results, output-to-css);
|
11
113
|
|
12
|
-
$
|
114
|
+
$items: null;
|
115
|
+
$message: null;
|
116
|
+
|
117
|
+
@if $scope == global or $scope == module {
|
118
|
+
$items: Tests;
|
119
|
+
} @else if $scope == test {
|
120
|
+
$items: Assertions;
|
121
|
+
}
|
122
|
+
|
123
|
+
@if $lines == single {
|
124
|
+
$message: '#{$run} #{$items}, #{$pass} Passed, #{$fail} Failed';
|
125
|
+
$message: if($output-to-css > 0, $message + ', #{$output-to-css} Output to CSS', $message);
|
126
|
+
} @else {
|
127
|
+
$message: '#{$run $items}:#{$-tnl} - #{$pass} Passed#{$-tnl} - #{$fail} Failed';
|
128
|
+
$message: if($output-to-css > 0, $message + '#{$-tnl} - #{$output-to-css} Output to CSS', $message);
|
129
|
+
}
|
13
130
|
|
14
131
|
@return $message;
|
15
132
|
}
|
16
133
|
|
134
|
+
|
135
|
+
// Report
|
136
|
+
// ------
|
137
|
+
|
17
138
|
@mixin report(
|
18
|
-
$
|
139
|
+
$terminal: $true-terminal-output
|
19
140
|
) {
|
20
|
-
$message: report(
|
21
|
-
@
|
22
|
-
|
141
|
+
$message: _true-report-message(global, multiple);
|
142
|
+
@include _true-message('# SUMMARY ----------', comments);
|
143
|
+
@include _true-message($message, comments);
|
144
|
+
@include _true-message('--------------------', comments);
|
145
|
+
|
146
|
+
@if $terminal == details {
|
147
|
+
$message: _true-report-message(global, single);
|
148
|
+
@include _true-message($message, debug);
|
23
149
|
}
|
24
150
|
}
|
data/sass/true/_settings.scss
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
// True Settings
|
2
2
|
// =============
|
3
3
|
|
4
|
-
$true:
|
5
|
-
output: css,
|
6
|
-
summary: terminal css
|
7
|
-
) !default;
|
4
|
+
$true-terminal-output: true !default;
|
8
5
|
|
9
6
|
|
10
|
-
//
|
7
|
+
// Context (private)
|
11
8
|
// -----------------
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
|
10
|
+
$_true-context: (
|
11
|
+
module: null,
|
12
|
+
test: null,
|
13
|
+
assert: null,
|
16
14
|
);
|
17
15
|
|
18
|
-
|
16
|
+
@mixin _true-context(
|
17
|
+
$scope,
|
18
|
+
$name
|
19
|
+
) {
|
20
|
+
$_true-context: map-merge($_true-context, ($scope: $name)) !global;
|
21
|
+
}
|
22
|
+
|
23
|
+
@function _true-context(
|
24
|
+
$scope
|
25
|
+
) {
|
26
|
+
@return map-get($_true-context, $scope);
|
27
|
+
}
|
data/sass/true/_tests.scss
CHANGED
@@ -1,69 +1,36 @@
|
|
1
1
|
// Tests
|
2
2
|
// =====
|
3
3
|
|
4
|
-
$test-results: null;
|
5
|
-
$test-details: '';
|
6
4
|
|
7
|
-
// Establish a new test
|
8
5
|
@mixin test(
|
9
|
-
$name
|
10
|
-
$output: map-get($true, output)
|
6
|
+
$name
|
11
7
|
) {
|
12
|
-
|
13
|
-
$test-details: '' !global;
|
14
|
-
@content;
|
15
|
-
@include report-test($name, $test-results, $output, $test-details);
|
16
|
-
$test-results: null !global;
|
17
|
-
$test-details: '' !global;
|
18
|
-
}
|
19
|
-
|
20
|
-
// Report test results
|
21
|
-
// -------------------
|
22
|
-
|
23
|
-
@mixin report-test(
|
24
|
-
$name,
|
25
|
-
$results,
|
26
|
-
$output: map-get($true, output),
|
27
|
-
$details: ''
|
28
|
-
) {
|
29
|
-
$pass: map-get($results, pass);
|
30
|
-
$fail: map-get($results, fail);
|
31
|
-
$result: if($fail > 0 or $pass < 1, fail, pass);
|
32
|
-
|
33
|
-
$message: '#{$name} (#{report($results, Assertions)})';
|
8
|
+
@include _true-test-start($name);
|
34
9
|
|
35
|
-
|
10
|
+
#{_true-selector(module test)} {
|
11
|
+
@content;
|
12
|
+
@include _true-test-stop;
|
13
|
+
}
|
36
14
|
}
|
37
15
|
|
38
|
-
// Pass / Fail Tests
|
39
|
-
// -----------------
|
40
16
|
|
41
|
-
|
42
|
-
|
43
|
-
$message: '',
|
44
|
-
$output: map-get($true, output),
|
45
|
-
$details: ''
|
46
|
-
) {
|
47
|
-
$css: null;
|
48
|
-
$terminal: null;
|
17
|
+
// Module Start (private)
|
18
|
+
// ----------------------
|
49
19
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
$terminal: if($message, $message, '');
|
58
|
-
}
|
20
|
+
@mixin _true-test-start(
|
21
|
+
$name
|
22
|
+
) {
|
23
|
+
@include _true-reset(test);
|
24
|
+
@include _true-context(test, $name);
|
25
|
+
@include _true-message($name, comments);
|
26
|
+
}
|
59
27
|
|
60
|
-
@if index($output, terminal) and $terminal {
|
61
|
-
@include result-message($terminal, debug);
|
62
|
-
}
|
63
28
|
|
64
|
-
|
65
|
-
|
66
|
-
}
|
29
|
+
// Module Stop (private)
|
30
|
+
// ---------------------
|
67
31
|
|
68
|
-
|
32
|
+
@mixin _true-test-stop {
|
33
|
+
@include _true-update(module, _true-get-result(test));
|
34
|
+
@include _true-reset(test);
|
35
|
+
@include _true-context(test, null);
|
69
36
|
}
|
data/sass/true/_utilities.scss
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
// =========
|
3
3
|
|
4
4
|
// Add map values together
|
5
|
-
@function map-
|
5
|
+
@function _true-map-increment(
|
6
6
|
$base,
|
7
7
|
$add
|
8
8
|
) {
|
9
|
-
@each $key
|
9
|
+
@each $key in map-keys($add) {
|
10
|
+
$value: map-get($add, $key);
|
11
|
+
|
10
12
|
@if $value {
|
11
13
|
$base-value: map-get($base, $key);
|
12
14
|
$new-value: if($base-value, $base-value + $value, $value);
|
@@ -18,7 +20,10 @@
|
|
18
20
|
}
|
19
21
|
|
20
22
|
// Split a string
|
21
|
-
@function str-split(
|
23
|
+
@function _true-str-split(
|
24
|
+
$string,
|
25
|
+
$substring
|
26
|
+
) {
|
22
27
|
$strings: ();
|
23
28
|
$found-at: str-index($string, $substring);
|
24
29
|
@while $found-at {
|
@@ -30,11 +35,39 @@
|
|
30
35
|
@return $strings;
|
31
36
|
}
|
32
37
|
|
38
|
+
|
33
39
|
// Check for strict equality
|
34
|
-
@function is-equal($one, $two) {
|
40
|
+
@function _true-is-equal($one, $two) {
|
35
41
|
@if type-of($one) == number and type-of($two) == number {
|
36
42
|
@return $one == $two and unit($one) == unit($two);
|
37
43
|
} @else {
|
38
44
|
@return $one == $two;
|
39
45
|
}
|
40
46
|
}
|
47
|
+
|
48
|
+
|
49
|
+
// Inspect
|
50
|
+
@function _true-inspect(
|
51
|
+
$value
|
52
|
+
) {
|
53
|
+
@if function-exists(inspect) {
|
54
|
+
@if type-of($value) == map {
|
55
|
+
@return '#{inspect($value)}';
|
56
|
+
} @else {
|
57
|
+
@return inspect($value);
|
58
|
+
}
|
59
|
+
} @else if $value == null {
|
60
|
+
@return 'null';
|
61
|
+
} @else if type-of($value) == map {
|
62
|
+
$map: '(';
|
63
|
+
$keys: map-keys($value);
|
64
|
+
@each $key in $keys {
|
65
|
+
$val: map-get($value, $key);
|
66
|
+
$last: if(index($keys, $key) == length($keys), true, false);
|
67
|
+
$map: '#{$map}#{$key}: #{$val}#{if($last, ")", ", ")}';
|
68
|
+
}
|
69
|
+
@return $map;
|
70
|
+
} @else {
|
71
|
+
@return $value;
|
72
|
+
}
|
73
|
+
}
|