commit c35f8ce6a8098cb8048cc849ec193933735c4a68
parent d0b337fb09f31536ef836531b0893c135867bc50
Author: Alex Balgavy <alex@balgavy.eu>
Date: Fri, 4 Mar 2022 14:20:05 +0100
Add tests from Vim documentation
Diffstat:
9 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/tests/example_1.2.rb b/tests/example_1.2.rb
@@ -0,0 +1,2 @@
+puts "Another file"
+
diff --git a/tests/example_1.md b/tests/example_1.md
@@ -0,0 +1,17 @@
+# Example 1
+Example 1 from Vim documentation.
+
+<!-- :Tangle(ruby) DIRNAME/FILENAME.rb -->
+
+```ruby
+puts "Sample text"
+```
+
+```bash
+echo "Sample text"
+```
+
+<!-- :Tangle(ruby) DIRNAME/FILENAME.2.rb -->
+```ruby
+puts "Another file"
+```
diff --git a/tests/example_1.rb b/tests/example_1.rb
@@ -0,0 +1,2 @@
+puts "Sample text"
+
diff --git a/tests/example_2.md b/tests/example_2.md
@@ -0,0 +1,21 @@
+# Example 2
+Example 2 from the Vim documentation.
+
+<!-- :Tangle DIRNAME/FILENAME.out -->
+<!-- :Tangle(python) DIRNAME/FILENAME.py -->
+
+```ruby
+puts "Sample text"
+```
+
+```python
+print("Sample text")
+```
+
+```
+this is some pseudocode in a block with no language
+```
+
+```bash
+echo "Sample text"
+```
diff --git a/tests/example_2.out b/tests/example_2.out
@@ -0,0 +1,4 @@
+puts "Sample text"
+
+echo "Sample text"
+
diff --git a/tests/example_2.py b/tests/example_2.py
@@ -0,0 +1,2 @@
+print("Sample text")
+
diff --git a/tests/example_3.md b/tests/example_3.md
@@ -0,0 +1,31 @@
+# Example 3
+Example 3 from the Vim documentation.
+
+<!-- :Tangle(python) <^> DIRNAME/FILENAME.py -->
+```python
+<<function definitions>>
+
+def main():
+ <<main code>>
+
+if __name__ == '__main__':
+ main()
+```
+
+<!-- :Tangle(python) <function definitions> -->
+```python
+def double(n):
+ x = 2*n
+ return x
+```
+
+<!-- :Tangle(python) <> <main code> -->
+```python
+<<n definition>>
+print("Double of %d is %d" % (n, double(n)))
+```
+
+<!-- :Tangle(python) <n definition> -->
+```python
+n = 34.5
+```
diff --git a/tests/example_3.py b/tests/example_3.py
@@ -0,0 +1,13 @@
+
+def double(n):
+ x = 2*n
+ return x
+
+def main():
+
+
+ n = 34.5
+ print("Double of %d is %d" % (n, double(n)))
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/run.sh b/tests/run.sh
@@ -17,10 +17,10 @@ run_test() {
# Compare all generated files with expected files
find "$testdir" -type f -not -name "$1".md | while read -r f; do
difference="$(diff "$f" "./${f##*/}")"
- [ -n "$difference" ] && printf "Test %s FAILED.\nDiff expected vs actual:\n%s" "$1" "$difference"
+ [ -n "$difference" ] && printf "Test %s FAILED.\nDiff expected (%s) vs actual (%s):\n%s" "$1" "$f" "./${f##*/}" "$difference"
done
}
-for i in all_in_one_file only_specific_language two_different_languages simple_macros; do run_test "$i"; done
+for i in all_in_one_file only_specific_language two_different_languages simple_macros example_1 example_2 example_3; do run_test "$i"; done
# rm -r "$tempdir"
trap - INT TERM EXIT