|
|
@@ -11,9 +11,14 @@
|
|
11
|
11
|
--color-failed: #a00;
|
|
12
|
12
|
--color-errored: #a80;
|
|
13
|
13
|
--color-untested: #888;
|
|
|
14
|
+ --color-background: #fff;
|
|
|
15
|
+ --color-text: #000;
|
|
|
16
|
+ --color-secondary: #888;
|
|
|
17
|
+ background-color: var(--color-background);
|
|
|
18
|
+ color: var(--color-text);
|
|
14
|
19
|
}
|
|
15
|
20
|
.testclass {
|
|
16
|
|
- border: 1px solid black;
|
|
|
21
|
+ border: 1px solid var(--color-secondary);
|
|
17
|
22
|
padding: 0.5em 1em;
|
|
18
|
23
|
margin-bottom: 1em;
|
|
19
|
24
|
max-width: 50em;
|
|
|
@@ -23,9 +28,6 @@
|
|
23
|
28
|
font-size: 1.25rem;
|
|
24
|
29
|
padding-bottom: 0.25em;
|
|
25
|
30
|
}
|
|
26
|
|
- .testclassstatus {
|
|
27
|
|
-
|
|
28
|
|
- }
|
|
29
|
31
|
.testclassstatus.passed { color: var(--color-passed); }
|
|
30
|
32
|
.testclassstatus.failed { color: var(--color-failed); }
|
|
31
|
33
|
.testclassstatus.errored { color: var(--color-errored); }
|
|
|
@@ -36,7 +38,7 @@
|
|
36
|
38
|
margin-left: 2em;
|
|
37
|
39
|
}
|
|
38
|
40
|
.testcase {
|
|
39
|
|
- border-top: 1px solid #888;
|
|
|
41
|
+ border-top: 1px solid var(--color-secondary);
|
|
40
|
42
|
}
|
|
41
|
43
|
.testcasename {
|
|
42
|
44
|
font-family: monospace;
|
|
|
@@ -48,7 +50,7 @@
|
|
48
|
50
|
}
|
|
49
|
51
|
.testcasetiming {
|
|
50
|
52
|
float: right;
|
|
51
|
|
- color: #888;
|
|
|
53
|
+ color: var(--color-secondary);
|
|
52
|
54
|
font-size: 80%;
|
|
53
|
55
|
}
|
|
54
|
56
|
.testcaseresult {
|
|
|
@@ -58,19 +60,30 @@
|
|
58
|
60
|
clear: both;
|
|
59
|
61
|
}
|
|
60
|
62
|
.result-untested {
|
|
61
|
|
- color: #888;
|
|
|
63
|
+ color: var(--color-untested);
|
|
62
|
64
|
}
|
|
63
|
65
|
.result-testing {
|
|
64
|
|
- color: black;
|
|
|
66
|
+ color: var(--color-text);
|
|
65
|
67
|
}
|
|
66
|
68
|
.result-passed {
|
|
67
|
|
- color: #090;
|
|
|
69
|
+ color: var(--color-passed);
|
|
68
|
70
|
}
|
|
69
|
71
|
.result-failed {
|
|
70
|
|
- color: #a00;
|
|
|
72
|
+ color: var(--color-failed);
|
|
71
|
73
|
}
|
|
72
|
74
|
.result-errored {
|
|
73
|
|
- color: #a80;
|
|
|
75
|
+ color: var(--color-errored);
|
|
|
76
|
+ }
|
|
|
77
|
+ @media (prefers-color-scheme: dark) {
|
|
|
78
|
+ :root {
|
|
|
79
|
+ --color-passed: #090;
|
|
|
80
|
+ --color-failed: #a00;
|
|
|
81
|
+ --color-errored: #a80;
|
|
|
82
|
+ --color-untested: #888;
|
|
|
83
|
+ --color-background: #000;
|
|
|
84
|
+ --color-text: #fff;
|
|
|
85
|
+ --color-secondary: #888;
|
|
|
86
|
+ }
|
|
74
|
87
|
}
|
|
75
|
88
|
</style>
|
|
76
|
89
|
<script src="js/markdown.js"></script>
|
|
|
@@ -424,14 +437,14 @@
|
|
424
|
437
|
<script>
|
|
425
|
438
|
function onLoad() {
|
|
426
|
439
|
let testClasses = [
|
|
427
|
|
- // FIXME: Reenable these! Disabled temporarily to test spreadsheets faster.
|
|
428
|
|
- // TokenTests,
|
|
429
|
|
- // UtilsTests,
|
|
430
|
|
- // InlineTests,
|
|
431
|
|
- // BlockTests,
|
|
|
440
|
+ TokenTests,
|
|
|
441
|
+ UtilsTests,
|
|
|
442
|
+ InlineTests,
|
|
|
443
|
+ BlockTests,
|
|
432
|
444
|
CellValueTests,
|
|
433
|
445
|
CellAddressRangeTests,
|
|
434
|
446
|
ExpressionSetTests,
|
|
|
447
|
+ SpreadsheetMarkdownIntegrationTests,
|
|
435
|
448
|
];
|
|
436
|
449
|
TestClassRunner.runAll(testClasses);
|
|
437
|
450
|
}
|
|
|
@@ -1555,6 +1568,8 @@
|
|
1555
|
1568
|
this._test_simple_formula('=AND(FALSE, TRUE)', false);
|
|
1556
|
1569
|
this._test_simple_formula('=AND(TRUE, FALSE)', false);
|
|
1557
|
1570
|
this._test_simple_formula('=AND(TRUE, TRUE)', true);
|
|
|
1571
|
+ this._test_simple_formula('=AND(TRUE, TRUE, TRUE, TRUE)', true);
|
|
|
1572
|
+ this._test_simple_formula('=AND(TRUE, TRUE, TRUE, FALSE)', false);
|
|
1558
|
1573
|
}
|
|
1559
|
1574
|
|
|
1560
|
1575
|
test_func_average() {
|
|
|
@@ -1638,6 +1653,9 @@
|
|
1638
|
1653
|
this._test_simple_formula('=ROUND(-3.1)', -3);
|
|
1639
|
1654
|
this._test_simple_formula('=ROUND(-3.5)', -3);
|
|
1640
|
1655
|
this._test_simple_formula('=ROUND(-3.9)', -4);
|
|
|
1656
|
+ this._test_simple_formula('=ROUND(3.1415926535, 1)', 3.1);
|
|
|
1657
|
+ this._test_simple_formula('=ROUND(3.1415926535, 2)', 3.14);
|
|
|
1658
|
+ this._test_simple_formula('=ROUND(31.415926535, -1)', 30);
|
|
1641
|
1659
|
}
|
|
1642
|
1660
|
|
|
1643
|
1661
|
test_func_sqrt() {
|
|
|
@@ -1671,6 +1689,45 @@
|
|
1671
|
1689
|
this._test_simple_formula('=2.718281828459045 ; currency 2', new CellValue('$2.72', 2.718281828459045, 'currency', 2));
|
|
1672
|
1690
|
}
|
|
1673
|
1691
|
}
|
|
|
1692
|
+
|
|
|
1693
|
+ class SpreadsheetMarkdownIntegrationTests extends BaseTest {
|
|
|
1694
|
+ parser;
|
|
|
1695
|
+
|
|
|
1696
|
+ setUp() {
|
|
|
1697
|
+ this.parser = new Markdown([ ...Markdown.allBlockReaders, new SpreadsheetBlockReader() ], Markdown.allInlineReaders);
|
|
|
1698
|
+ }
|
|
|
1699
|
+
|
|
|
1700
|
+ md(markdown) {
|
|
|
1701
|
+ return normalizeWhitespace(this.parser.toHTML(markdown));
|
|
|
1702
|
+ }
|
|
|
1703
|
+
|
|
|
1704
|
+ test_integration() {
|
|
|
1705
|
+ const markdown = '| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | =A*B |';
|
|
|
1706
|
+ const expected = '<table> <thead> ' +
|
|
|
1707
|
+ '<tr> <th>A</th> <th>B</th> <th>C</th> </tr> ' +
|
|
|
1708
|
+ '</thead> <tbody> <tr> ' +
|
|
|
1709
|
+ '<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td> ' +
|
|
|
1710
|
+ '<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td> ' +
|
|
|
1711
|
+ '<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12">12</td> ' +
|
|
|
1712
|
+ '</tr> </tbody> </table>';
|
|
|
1713
|
+ const result = this.md(markdown);
|
|
|
1714
|
+ this.assertEqual(result, expected);
|
|
|
1715
|
+ }
|
|
|
1716
|
+
|
|
|
1717
|
+ test_bailOut() {
|
|
|
1718
|
+ // If no formulas found table isn't modified
|
|
|
1719
|
+ const markdown = '| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | A*B |';
|
|
|
1720
|
+ const expected = '<table> <thead> ' +
|
|
|
1721
|
+ '<tr> <th>A</th> <th>B</th> <th>C</th> </tr> ' +
|
|
|
1722
|
+ '</thead> <tbody> <tr> ' +
|
|
|
1723
|
+ '<td>3</td> ' +
|
|
|
1724
|
+ '<td>4</td> ' +
|
|
|
1725
|
+ '<td>A*B</td> ' +
|
|
|
1726
|
+ '</tr> </tbody> </table>';
|
|
|
1727
|
+ const result = this.md(markdown);
|
|
|
1728
|
+ this.assertEqual(result, expected);
|
|
|
1729
|
+ }
|
|
|
1730
|
+ }
|
|
1674
|
1731
|
</script>
|
|
1675
|
1732
|
</head>
|
|
1676
|
1733
|
<body>
|