Add tests for diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/components/prism-diff.js b/components/prism-diff.js
index f01858d..3c5351c 100644
--- a/components/prism-diff.js
+++ b/components/prism-diff.js
@@ -1,11 +1,11 @@
Prism.languages.diff = {
'coord': [
// Match all kinds of coord lines (prefixed by "+++", "---" or "***").
- /^(\*{3}|-{3}|\+{3}).*$/m,
+ /^(?:\*{3}|-{3}|\+{3}).*$/m,
// Match "@@ ... @@" coord lines in unified diff.
/^@@.*@@$/m,
// Match coord lines in normal diff (starts with a number).
- /^\d+.*$/m,
+ /^\d+.*$/m
],
// Match inserted and deleted lines. Support both +/- and >/< styles.
@@ -14,7 +14,7 @@ Prism.languages.diff = {
// Match "different" lines (prefixed with "!") in context diff.
'diff': {
- 'pattern': /^\!(?!\!).+$/m,
+ 'pattern': /^!(?!!).+$/m,
'alias': 'important'
}
-}
+};
\ No newline at end of file
diff --git a/components/prism-diff.min.js b/components/prism-diff.min.js
index 57cc657..091562e 100644
--- a/components/prism-diff.min.js
+++ b/components/prism-diff.min.js
@@ -1 +1 @@
-Prism.languages.diff={coord:[/^(\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d+.*$/m],deleted:/^[-<].+$/m,inserted:/^[+>].+$/m,diff:{pattern:/^\!(?!\!).+$/m,alias:"important"}};
\ No newline at end of file
+Prism.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d+.*$/m],deleted:/^[-<].+$/m,inserted:/^[+>].+$/m,diff:{pattern:/^!(?!!).+$/m,alias:"important"}};
\ No newline at end of file
diff --git a/tests/languages/diff/coord_feature.test b/tests/languages/diff/coord_feature.test
new file mode 100644
index 0000000..c082693
--- /dev/null
+++ b/tests/languages/diff/coord_feature.test
@@ -0,0 +1,21 @@
+7c7
+
+*** 4,8 ****
+--- 4,8 ----
+
+@@ -4,5 +4,5 @@
+
+----------------------------------------------------
+
+[
+ ["coord", "7c7"],
+
+ ["coord", "*** 4,8 ****"],
+ ["coord", "--- 4,8 ----"],
+
+ ["coord", "@@ -4,5 +4,5 @@"]
+]
+
+----------------------------------------------------
+
+Checks for coords.
\ No newline at end of file
diff --git a/tests/languages/diff/diff_feature.test b/tests/languages/diff/diff_feature.test
new file mode 100644
index 0000000..0e53490
--- /dev/null
+++ b/tests/languages/diff/diff_feature.test
@@ -0,0 +1,21 @@
+! qt: core
+
+- qt: core
++ qt: core gui
+
+< qt: core
+> qt: core quick
+
+----------------------------------------------------
+
+[
+ ["diff", "! qt: core"],
+ ["deleted", "- qt: core"],
+ ["inserted", "+ qt: core gui"],
+ ["deleted", "< qt: core"],
+ ["inserted", "> qt: core quick"]
+]
+
+----------------------------------------------------
+
+Checks for deleted, inserted and different lines.
\ No newline at end of file