diff --git a/.gitignore b/.gitignore index 06d8f4aa33..bd6653f6d1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ flamegraph.svg .idea sample_files/compare.result +tests/snapshots/*.snap.new notes.md diff --git a/manual/src/adding_a_parser.md b/manual/src/adding_a_parser.md index 8743fd062f..89c3b6eb76 100644 --- a/manual/src/adding_a_parser.md +++ b/manual/src/adding_a_parser.md @@ -139,6 +139,15 @@ $ ./sample_files/compare_all.sh $ cp sample_files/compare.result sample_files/compare.expected ``` +Run the CLI test and [update the snapshots][insta] as well. + +``` +$ cargo insta test +$ cargo insta accept +``` + +[insta]: https://insta.rs/docs/quickstart/#reviewing-snapshots + ## Maintenance To update a parser that is already imported, use `git subtree pull`. diff --git a/tests/cli.rs b/tests/cli.rs index fa0ea1df92..a88b4f5f38 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,4 +1,5 @@ use std::process::Command; +use std::str; use assert_cmd::prelude::*; use predicates::prelude::*; @@ -259,3 +260,39 @@ fn walk_hidden_items() { .and(predicate::str::contains("after")); cmd.assert().stdout(predicate_fn); } + +const MAX_SAMPLE_FILE_SIZE: u64 = 10_000; + +#[test] +fn samples_side_by_side() { + insta::glob!("../sample_files", "*_1.*", |left_file| { + let base_dir = left_file.parent().unwrap().parent().unwrap(); + let file_name = left_file.file_name().unwrap().to_str().unwrap(); + let right_file = left_file.with_file_name(file_name.replace("_1.", "_2.")); + // Large sample files are excluded because it's slow to diff with debug + // binary, and the snapshot results wouldn't help review changes. + if left_file.metadata().unwrap().len() > MAX_SAMPLE_FILE_SIZE + || right_file.metadata().unwrap().len() > MAX_SAMPLE_FILE_SIZE + { + eprintln!("Skipping large sample: {file_name}"); + return; + } + + let to_path_arg = |path: &Path| { + let short_path = path.strip_prefix(base_dir).unwrap(); + let short_str = short_path.to_str().unwrap(); + short_str.replace(std::path::MAIN_SEPARATOR, "/") + }; + let mut cmd = get_base_command(); + let assert = cmd + .arg("--color=always") + .arg("--display=side-by-side") + .arg("--width=160") + .arg(to_path_arg(left_file)) + .arg(to_path_arg(&right_file)) + .assert() + .success(); + let stdout = str::from_utf8(&assert.get_output().stdout).unwrap(); + insta::assert_snapshot!(stdout); + }); +} diff --git a/tests/snapshots/cli__samples_side_by_side@Session_1.kt.snap b/tests/snapshots/cli__samples_side_by_side@Session_1.kt.snap new file mode 100644 index 0000000000..f5c156c2cc --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@Session_1.kt.snap @@ -0,0 +1,32 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/Session_1.kt +--- +sample_files/Session_2.kt --- 1/2 --- Kotlin + 96  /**  96  /** + 97  * The session's photo URL.  97  * The session's photo URL. + 98  */  98  */ + 99  val photoUrl: String?,  99  val photoUrl: String, +100  100  +101  /** 101  /** +102  * IDs of the sessions related to this session. 102  * IDs of the sessions related to this session. + +sample_files/Session_2.kt --- 2/2 --- Kotlin +114  return startTime <= now && endTime >= now 114  return startTime <= now && endTime >= now +115  } 115  } +...  116  +...  117  val hasPhoto inline get() = photoUrl.isNotEmpty() +116  118  +117  /** 119  /** +118  * Returns whether the session has a video or not. A session could be l 120  * Returns whether the session has a video or not. A session could be l +... ive streaming or have a ... ive streaming or have a +119  * recorded session. Both live stream and recorded videos are stored in 121  * recorded session. Both live stream and recorded videos are stored in +...  [Session.youTubeUrl]. ...  [Session.youTubeUrl]. +120  */ 122  */ +121  fun hasVideo() = youTubeUrl.isNotEmpty() 123  val hasVideo inline get() = youTubeUrl.isNotEmpty() +...  124  +...  125  val hasPhotoOrVideo inline get() = hasPhoto || hasVideo +122  126  +123  /** 127  /** +124  * The year the session was held. 128  * The year the session was held. diff --git a/tests/snapshots/cli__samples_side_by_side@ada_1.adb.snap b/tests/snapshots/cli__samples_side_by_side@ada_1.adb.snap new file mode 100644 index 0000000000..23b06401a8 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@ada_1.adb.snap @@ -0,0 +1,14 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/ada_1.adb +--- +sample_files/ada_2.adb --- Ada +1  with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line ("Hello 1 with Ada.Text_IO; +.  WORLD!"); end Hello; .  +.  2  +.  3 procedure Hello is +.  4  package TIO renames Ada.Text_IO; +.  5 begin +.  6  TIO.Put_Line ("Hello World!"); +.  7 end Hello; diff --git a/tests/snapshots/cli__samples_side_by_side@added_line_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@added_line_1.txt.snap new file mode 100644 index 0000000000..cc56f80411 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@added_line_1.txt.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/added_line_1.txt +--- +sample_files/added_line_2.txt --- Text +1 1 potato +2 2 tomato + 3 legato diff --git a/tests/snapshots/cli__samples_side_by_side@align_footer_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@align_footer_1.txt.snap new file mode 100644 index 0000000000..7907c4b339 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@align_footer_1.txt.snap @@ -0,0 +1,10 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/align_footer_1.txt +--- +sample_files/align_footer_2.txt --- Text +1 before 1 before +2  foo x 2  x +3 y .  +4 after 3 after diff --git a/tests/snapshots/cli__samples_side_by_side@apex_1.cls.snap b/tests/snapshots/cli__samples_side_by_side@apex_1.cls.snap new file mode 100644 index 0000000000..85580dc12b --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@apex_1.cls.snap @@ -0,0 +1,7 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/apex_1.cls +--- +sample_files/apex_2.cls --- Apex +No syntactic changes. diff --git a/tests/snapshots/cli__samples_side_by_side@bad_combine_1.rs.snap b/tests/snapshots/cli__samples_side_by_side@bad_combine_1.rs.snap new file mode 100644 index 0000000000..b33907ab35 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@bad_combine_1.rs.snap @@ -0,0 +1,33 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/bad_combine_1.rs +--- +sample_files/bad_combine_2.rs --- 1/2 --- Rust + 1  .  + 2 fn column_widths( .  + 3  hunks: &[Hunk], .  + 4  lhs_mps: &[MatchedPos], .  + 5  rhs_mps: &[MatchedPos], .  + 6  max_lhs_src_line: LineNumber, .  + 7  max_rhs_src_line: LineNumber, .  + 8 ) { .  + 9 } .  +10  .  +11 fn display_line_nums( 1 fn display_line_nums( +12 ) -> (String, String) { 2 ) -> (String, String) { +13  let display_rhs_line_num: String = match rhs_line_num { 3  let display_rhs_line_num: String = match rhs_line_num { +14  Some(line_num) => { 4  Some(line_num) => { +15  let s = format_line_num_padded(line_num, rhs_column_width); 5  let s = format_line_num_padded(line_num, widths.rhs_line_nums); +16  if rhs_lines_with_novel.contains(&line_num) { 6  if rhs_lines_with_novel.contains(&line_num) { +17  s.bright_green().to_string() 7  s.bright_green().to_string() +18  } else { 8  } else { + +sample_files/bad_combine_2.rs --- 2/2 --- Rust +21  } 11  } +22  None => format_missing_line_num( 12  None => format_missing_line_num( +23  prev_rhs_line_num.unwrap_or_else(|| 10.into()), 13  prev_rhs_line_num.unwrap_or_else(|| 10.into()), +24  rhs_column_width, 14  widths.rhs_line_nums, +25  ), 15  ), +26  }; 16  }; +27  17  diff --git a/tests/snapshots/cli__samples_side_by_side@change_outer_1.el.snap b/tests/snapshots/cli__samples_side_by_side@change_outer_1.el.snap new file mode 100644 index 0000000000..f214ebb1e6 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@change_outer_1.el.snap @@ -0,0 +1,7 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/change_outer_1.el +--- +sample_files/change_outer_2.el --- Emacs Lisp +1 (lhs comma rhs) 1 [(lhs) comma rhs] diff --git a/tests/snapshots/cli__samples_side_by_side@chinese_1.po.snap b/tests/snapshots/cli__samples_side_by_side@chinese_1.po.snap new file mode 100644 index 0000000000..166b1f5d4c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@chinese_1.po.snap @@ -0,0 +1,35 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/chinese_1.po +--- +sample_files/chinese_2.po --- 1/3 --- Text +File permissions changed from 100755 to 100644. +1 #: ../errors.h:589 1 #: ../errors.h:589 +2 # reorder if possible 2 # reorder if possible +3 #, fuzzy, c-format 3 #, fuzzy, c-format +4 msgid "E244: Illegal %s name \"%s\" in font name \"%s\"" 4 # msgid "E244: Illegal %s name \"%s\" in font name \"%s\"" +5 msgstr "E244: 字体名 \"%3$s\" 中有非法 %1$s 名称 \"%2$s\"" 5 # msgstr "E244: 字体名 \"%3$s\" 中有非法 %1$s 名称 \"%2$s\"" +6  6  +7 #: ../errors.h:591 7 #: ../errors.h:591 +8 #, c-format 8 #, c-format + +sample_files/chinese_2.po --- 2/3 --- Text +21 #: ../errors.h:788 21 #: ../errors.h:788 +22 # reorder if possible 22 # reorder if possible +23 #, fuzzy, c-format 23 #, fuzzy, c-format +24 msgid "E316: ml_get: Cannot find line %ld in buffer %d %s" 24 # msgid "E316: ml_get: Cannot find line %ld in buffer %d %s" +25 msgstr "E316: ml_get: 在缓冲区 %2$d %3$s 中找不到第 %1$ld 行" 25 # msgstr "E316: ml_get: 在缓冲区 %2$d %3$s 中找不到第 %1$ld 行" +26  26  +27 #: ../errors.h:790 27 #: ../errors.h:790 +28 msgid "E317: Pointer block id wrong" 28 msgid "E317: Pointer block id wrong" + +sample_files/chinese_2.po --- 3/3 --- Text +43 #: ../errors.h:2705 43 #: ../errors.h:2705 +44 # reorder if possible 44 # reorder if possible +45 #, fuzzy, c-format 45 #, fuzzy, c-format +46 msgid "E1037: Cannot use \"%s\" with %s" 46 # msgid "E1037: Cannot use \"%s\" with %s" +47 msgstr "E1037: 不能对 %2$s 使用 \"%1$s\"" 47 # msgstr "E1037: 不能对 %2$s 使用 \"%1$s\"" +48  48  +49 #: ../errors.h:2707 49 #: ../errors.h:2707 +50 msgid "E1038: \"vim9script\" can only be used in a script" 50 msgid "E1038: \"vim9script\" can only be used in a script" diff --git a/tests/snapshots/cli__samples_side_by_side@clojure_1.clj.snap b/tests/snapshots/cli__samples_side_by_side@clojure_1.clj.snap new file mode 100644 index 0000000000..3e9a4566ae --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@clojure_1.clj.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/clojure_1.clj +--- +sample_files/clojure_2.clj --- Clojure +3 (defn example 3 (defn example +4  [x] 4  [x] +5  "Does stuff." 5  "Does stuff." +6  (println "hello!") .  +7  {:more (inc x) 6  (-> {:more (inc x) +8  :less (dec x)}) 7  :less (dec x)} +  8  (assoc :twice (+ x x)))) diff --git a/tests/snapshots/cli__samples_side_by_side@comma_1.js.snap b/tests/snapshots/cli__samples_side_by_side@comma_1.js.snap new file mode 100644 index 0000000000..7ba71e2fc7 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@comma_1.js.snap @@ -0,0 +1,20 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/comma_1.js +--- +sample_files/comma_2.js --- JavaScript +10  * @param {Function} comparator The comparator invoked per element. 10  * @param {Function} comparator The comparator invoked per element. +11  * @returns {boolean} Returns `true` if `target` is found, else `false`. 11  * @returns {boolean} Returns `true` if `target` is found, else `false`. +12  */ 12  */ +13 function arrayIncludesWith(array, value, comparator) { 13 function arrayIncludesWith(array, target, comparator) { +14  let index = -1 ..  +15  const length = array == null ? 0 : array.length 14  if (array == null) { +..  15  return false +..  16  } +16  17  +17  while (++index < length) { 18  for (const value of array) { +18  if (comparator(value, array[index])) { 19  if (comparator(target, value)) { +19  return true 20  return true +20  } 21  } +21  } 22  } diff --git a/tests/snapshots/cli__samples_side_by_side@comma_and_comment_1.js.snap b/tests/snapshots/cli__samples_side_by_side@comma_and_comment_1.js.snap new file mode 100644 index 0000000000..3afb3785b2 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@comma_and_comment_1.js.snap @@ -0,0 +1,7 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/comma_and_comment_1.js +--- +sample_files/comma_and_comment_2.js --- JavaScript +1 funName(1 /* foo */ , /* bar */) 1 funName(1 /* kinda like bar */ , /* foo */) diff --git a/tests/snapshots/cli__samples_side_by_side@comments_1.rs.snap b/tests/snapshots/cli__samples_side_by_side@comments_1.rs.snap new file mode 100644 index 0000000000..2eab46861c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@comments_1.rs.snap @@ -0,0 +1,31 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/comments_1.rs +--- +sample_files/comments_2.rs --- Rust + 1 // Unchanged comment.  1 // Unchanged comment. + 2 f1();  2 f1(); + 3   3  + 4 // Changing a single word.  4 // Changing a single word here. + 5 f2();  5 f2(); + 6   6  + 7 // A completely different sentence.  7 // A single comment about something. + 8 f3();  8 f3(); + 9   9  +10 if true {  .  +11  /* A multiline comment 10 /* A multiline comment +12  * whose indentation changes. 11  * whose indentation changes. +13  */ 12  */ +14 } ..  +15  13  +16 // An example environment variable: FOO="a-b" 14 // An example environment variable: FOO="x-y" +17  15  +18 // A single line comment. 16 // A single line comment. It has become +..  17 // a big block comment. Lorem ipsum dolor sit amet, +..  18 // consectetur adipiscing elit +19  19  +20 /** A doc comment. 20 /** A doc comment. +21  * 21  * +22  * This line will change. 22  * This line has changed. +23  */ 23  */ diff --git a/tests/snapshots/cli__samples_side_by_side@context_1.rs.snap b/tests/snapshots/cli__samples_side_by_side@context_1.rs.snap new file mode 100644 index 0000000000..e5902b1af3 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@context_1.rs.snap @@ -0,0 +1,22 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/context_1.rs +--- +sample_files/context_2.rs --- 1/2 --- Rust +1 fn print_diff_result() { 1 fn print_diff_result() { +2  if summary { 2  match () { +3  if print_unchanged { 3  x => { +4  } .  +5  } .  +6  .  +7  let opposite_to_lhs = opposite_positions(&summary.lhs_positions); 4  let opposite_to_lhs = opposite_positions(&summary.lhs_positions); +8  5  + +sample_files/context_2.rs --- 2/2 --- Rust +12  9  ); +13 10  +14 11  let lang_name; +.. 12  } +.. 13  } +15 14 } diff --git a/tests/snapshots/cli__samples_side_by_side@contiguous_1.js.snap b/tests/snapshots/cli__samples_side_by_side@contiguous_1.js.snap new file mode 100644 index 0000000000..7687e82454 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@contiguous_1.js.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/contiguous_1.js +--- +sample_files/contiguous_2.js --- JavaScript +1 1 // There are multiple possible diffs here, but we want to prefer +. 2 // showing A and B on the same line. +2 3 var x = [ +3 4  "A", "B", +. 5  "A", "B", +4 6  "C", "D", +5 7 ]; diff --git a/tests/snapshots/cli__samples_side_by_side@css_1.css.snap b/tests/snapshots/cli__samples_side_by_side@css_1.css.snap new file mode 100644 index 0000000000..fb50ee3843 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@css_1.css.snap @@ -0,0 +1,29 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/css_1.css +--- +sample_files/css_2.css --- CSS + 1 /* hello  1 /* hello + 2 world */  2 world */ + 3 .foo1 {  3 .bar { + 4  margin: 0 0 20px 0;  4  margin: 0; + 5 }  5 } + 6   6  + 7 .bar {  7 .foo1 { + 8  margin: 0;  8  margin: 0 0 20px 0; + .   9  color: green; + 9 } 10 } +10  11  +11 .baz { 12 .baz { +12  color: yellow; 13  color: blue; +13  font-family: "Before"; 14  font-family: "After"; +14 } 15 } +15  16  +16 .another { 17 .another { +17  margin-left: 0.5em; 18  margin-left: 1em; +18 } 19 } +  20  +  21 p { +  22  color: #000; +  23 } diff --git a/tests/snapshots/cli__samples_side_by_side@dart_1.dart.snap b/tests/snapshots/cli__samples_side_by_side@dart_1.dart.snap new file mode 100644 index 0000000000..aa617aee78 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@dart_1.dart.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/dart_1.dart +--- +sample_files/dart_2.dart --- Dart +1 void test() { 1 void test() { +2  if (x) { .  +3  Object().a().b(); 2  Object()..a()..b(); +4  } .  +5  3  +6  expect(a.b(c.d()).x); 4  expect(a.b.c.d()!.x); +7 } 5 } diff --git a/tests/snapshots/cli__samples_side_by_side@devicetree_1.dts.snap b/tests/snapshots/cli__samples_side_by_side@devicetree_1.dts.snap new file mode 100644 index 0000000000..d31ae3c186 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@devicetree_1.dts.snap @@ -0,0 +1,64 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/devicetree_1.dts +--- +sample_files/devicetree_2.dts --- 1/2 --- Device Tree + 5 /memreserve/ 0x0000000000000000 0x0000000000000014;  5 /memreserve/ 0x0000000000000000 0x0000000000000014; + 6   6  + 7 / {  7 / { + 8  model = "MyBoardName";  8  model = "MyBoardNamev2"; + 9  compatible = "MyBoardName", "MyBoardFamilyName";  9  compatible = "MyBoardName", "MyBoardFamilyName", "MyBoardRevision"; +10  #address-cells = <2>; 10  #address-cells = <2>; +11  #size-cells = <2>; 11  #size-cells = <2>; +12  12  + +sample_files/devicetree_2.dts --- 2/2 --- Device Tree +25  d-cache-size = <32768>; 25  d-cache-size = <32768>; +26  }; 26  }; +27  ..  +28  PowerPC,970@1 { ..  +29  name = "PowerPC,970"; ..  +30  device_type = "cpu"; ..  +31  reg = <0x00000001>; ..  +32  clock-frequency = <1600000000>; ..  +33  timebase-frequency = <33333333>; ..  +34  i-cache-size = <65536>; ..  +35  d-cache-size = <32768>; ..  +36  }; ..  +37  ..  +38  }; 27  }; +39  28  +..  29  randomparentnode { +40  randomnode { 30  randomnode { +41  string = "\xff\0stuffstuff\t\t\t\n\n\n"; 31  string = "\xff\0stuffstuff\t\t\t\n\n\n"; +42  blob = [0a 0b 0c 0d de ea ad be ef]; 32  blob = [0a 0b 0c 0d de ea ad be ef]; +43  ref = < &{/memory@0} >; 33  ref = < &{/memory@0} >; +44  mixed = "abc", [1234], <0xa 0xb 0xc>; 34  mixed = "abc", +..  35  [1234], +..  36  <0xa 0xb 0xc>; +45  old = <12345>; 37  new = <12345>; +46  }; 38  }; +..  39  }; +47  40  +48  memory@0 { 41  memory@0 { +49  device_type = "memory"; 42  device_type = "memory"; +50  memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; 43  memreg: reg = < +..  44  0x00000000 0x00000000 +..  45  0x00000000 0x20000000>; +51  }; 46  }; +..  47  +..  48  memory@100000 { +..  49  device_type = "memory"; +..  50  memreg: reg = < +..  51  0x00100000 0x00000000 +..  52  0x00100000 0x20000000>; +..  53  }; +52  54  +53  chosen { 55  chosen { +54  bootargs = "root=/dev/sda2"; ..  +55  linux,platform = <0x600>; 56  linux,platform = <0x600>; +..  57  bootargs = "root=/dev/sda2"; +56  }; 58  }; +57  59  +58 }; 60 }; diff --git a/tests/snapshots/cli__samples_side_by_side@elisp_1.el.snap b/tests/snapshots/cli__samples_side_by_side@elisp_1.el.snap new file mode 100644 index 0000000000..49b0daf052 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@elisp_1.el.snap @@ -0,0 +1,24 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/elisp_1.el +--- +sample_files/elisp_2.el --- 1/2 --- Emacs Lisp +3 ;; Copyright (C) 2013 Wilfred Hughes 3 ;; Copyright (C) 2013 Wilfred Hughes +4  4  +5 ;; Author: Wilfred Hughes  5 ;; Author: Wilfred Hughes  +6 ;; Version: 0.5 6 ;; Version: 0.6 +7 ;; Keywords: hash table, hash map, hash 7 ;; Keywords: hash table, hash map, hash +8  8  +9 ;; This program is free software; you can redistribute it and/or modify 9 ;; This program is free software; you can redistribute it and/or modify + +sample_files/elisp_2.el --- 2/2 --- Emacs Lisp +40 40 (defun ht-from-alist (alist) +41 41  "Create a hash table with initial values according to ALIST." +42 42  (let ((h (ht-create))) +.. 43  ;; the first key-value pair in an alist gets precedence, so we +.. 44  ;; start from the end of the list: +43 45  (dolist (pair (reverse alist) h) +44 46  (let ((key (car pair)) +45 47  (value (cdr pair))) +46 48  (ht-set h key value))))) diff --git a/tests/snapshots/cli__samples_side_by_side@elisp_contiguous_1.el.snap b/tests/snapshots/cli__samples_side_by_side@elisp_contiguous_1.el.snap new file mode 100644 index 0000000000..88201c315d --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@elisp_contiguous_1.el.snap @@ -0,0 +1,15 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/elisp_contiguous_1.el +--- +sample_files/elisp_contiguous_2.el --- Emacs Lisp +1 A B 1 A B +.  2 A B +2 C D 3 C D +3  4  +4 X Y 5 X Y +5 X Novel .  +6 X Z 6 X Z +7  7  +8 End 8 End diff --git a/tests/snapshots/cli__samples_side_by_side@elm_1.elm.snap b/tests/snapshots/cli__samples_side_by_side@elm_1.elm.snap new file mode 100644 index 0000000000..ba5cef5ba3 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@elm_1.elm.snap @@ -0,0 +1,65 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/elm_1.elm +--- +sample_files/elm_2.elm --- Elm + 1 module Main exposing (blue, green, list, x, y, z)  1 module Main exposing + .   2  ( blue + .   3  , list + .   4  , x + .   5  , y + .   6  ) + 2   7  + 3   8  + 4 {- bar  9 {- foo + 5  -} 10  -} + 6 list : List Int 11 list : List Int + 7 list = 12 list = + 8  [ 1, 2, 3 ] 13  [ 1 + .  14  , 2 + .  15  , 3 + .  16  , 4 + .  17  ] + 9  18  +10  19  +11 blue : a -> String 20 blue : a -> String +12 blue = 21 blue = +13  always "blue" 22  \_ -> "blue" +14  23  +15  24  +16 green : a -> String 25 green : String +17 green = 26 green = +18  always "blue" 27  "yellow" ++ "blue" +19  28  +20  29  +21 y : Int 30 x : Int +22  ..  +23  ..  +24 x = 31 x = +25  (*) 2 4 32  (*) 2 <| 4 +26  33  +27  34  +28 y : Int 35 y : Int +29 y = 36 y = +30  (*) 2 4 37  4 |> (*) 2 +31  ..  +32  ..  +33 z : String ..  +34 z = ..  +35  "abc" ..  +36  38  +37  39  +38 fn : () -> Int -> List String -> String 40 fn : +..  41  () +..  42  -> Int +..  43  -> List String +..  44  -> () +..  45  -> String +39 fn _ n strings = 46 fn () n strings () = +40  let ..  +41  foo : List String -> String ..  +42  foo = ..  +43  String.join (String.fromInt n) 47  String.join (String.fromInt n) strings +44  in   +45  foo strings   diff --git a/tests/snapshots/cli__samples_side_by_side@elvish_1.elv.snap b/tests/snapshots/cli__samples_side_by_side@elvish_1.elv.snap new file mode 100644 index 0000000000..fc39a6670b --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@elvish_1.elv.snap @@ -0,0 +1,18 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/elvish_1.elv +--- +sample_files/elvish_2.elv --- Elvish + 3 curl https://api.github.com/repos/elves/elvish/issues |  3 curl https://api.github.com/repos/elves/elvish/issues | + 4  from-json | all (one) |  4  from-json | all (one) | + 5  each {|x| echo (exact-num $x[number]): $x[title] } |  5  each {|x| echo (exact-num $x[number]): $x[title] } | + 6  head -n 7  6  head -n 5 + 7   7  + 8 if $true { echo good } else { echo bad }  8 if $false { echo good } else { echo bad } + 9   9  +10 for x [lorem ipsum] { 10 for x [lorem ipsum] { +11  echo $x.pdf 11  echo $x.rs +12 } 12 } +13  13  +14  try { 14  try { diff --git a/tests/snapshots/cli__samples_side_by_side@f_sharp_1.fs.snap b/tests/snapshots/cli__samples_side_by_side@f_sharp_1.fs.snap new file mode 100644 index 0000000000..35e25e818b --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@f_sharp_1.fs.snap @@ -0,0 +1,28 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/f_sharp_1.fs +--- +sample_files/f_sharp_2.fs --- Text (1 F# parse error, exceeded DFT_PARSE_ERROR_LIMIT) + 1 namespace X  1 namespace X + 2   2  + 3 open System  3 open System + .   4 open System.IO + 4   5  + 5 type A = A of int  6 type A =  + .   7     | A of int + .   8     | B of string + 6   9  + 7 type Record = { A : string } 10 type Record = {  + .  11     A : string + .  12     B : int + .  13 } + 8  14  + 9 module M = 15 module M = +10  16  +11     let f x = x + 1 17     let f y = y + 1 +12  18  +13     let list = [] 19     let list = [ +  20         "a" +  21         "b" +  22     ] diff --git a/tests/snapshots/cli__samples_side_by_side@hack_1.php.snap b/tests/snapshots/cli__samples_side_by_side@hack_1.php.snap new file mode 100644 index 0000000000..cc9dd39fa4 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@hack_1.php.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/hack_1.php +--- +sample_files/hack_2.php --- Hack +3 /**  +4  * Do stuff +5  */ +6 function foo(): vec<?int> { +7  $x = "foo"; +8  return vec[1, null]; +9 } diff --git a/tests/snapshots/cli__samples_side_by_side@hare_1.ha.snap b/tests/snapshots/cli__samples_side_by_side@hare_1.ha.snap new file mode 100644 index 0000000000..ae552ca5cd --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@hare_1.ha.snap @@ -0,0 +1,20 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/hare_1.ha +--- +sample_files/hare_2.ha --- Text (1 Hare parse error, exceeded DFT_PARSE_ERROR_LIMIT) +1 use fmt;  1 use fmt; +2   2  +3 export fn main() void = {  3 export fn main() void = { +4  fmt::println("Hello, world!");  4  const greetings = [ +.   5   "Hello, world!", +.   6   "¡Hola Mundo!", +.   7   "Γειά σου Κόσμε!", +.   8   "Привет, мир!", +.   9   "こんにちは世界!", +.  10  ]; +.  11  for (let i = 0z; i < len(greetings); i += 1) { +.  12   fmt::println(greetings[i])!; +.  13  }; +5 }; 14 }; diff --git a/tests/snapshots/cli__samples_side_by_side@haskell_1.hs.snap b/tests/snapshots/cli__samples_side_by_side@haskell_1.hs.snap new file mode 100644 index 0000000000..887f347d62 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@haskell_1.hs.snap @@ -0,0 +1,15 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/haskell_1.hs +--- +sample_files/haskell_2.hs --- Haskell +1  1 import System.Process +.  2  +2 foo x = x + 1 3 foo x y = x + 1 + W.peek y +3  4  +4 bar _ = 'c' 5 bar _ = 'c' +5  6  +6 -- | Hello world 7 -- | Goodbye world +7 isOne 1 = True 8 isOne 1 = True +8 isOne _ = False 9 isOne _ = False diff --git a/tests/snapshots/cli__samples_side_by_side@hcl_1.hcl.snap b/tests/snapshots/cli__samples_side_by_side@hcl_1.hcl.snap new file mode 100644 index 0000000000..e5ed0fc6a1 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@hcl_1.hcl.snap @@ -0,0 +1,71 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/hcl_1.hcl +--- +sample_files/hcl_2.hcl --- 1/4 --- HCL +10  esc2 = "$${} %%{}" 10  esc2 = "$${} %%{}" +11  num1 = 2 11  num1 = 2 +12  num2 = 2.112 12  num2 = 2.112 +13  num3 = 2.112e-12 13  num3 = "Hello, World" +14  num4 = 2.112e+12 14  num4 = 2.112e+12 +15  num5 = 2.112E+12 15  num5 = 2.112E+12 +16  num6 = 2.112E-12 16  num6 = 2.112E-12 +17  num7 = 0x21FF 17  num7 = 0x21FF +..  18  strx = "Hello, Hcl" +18 } 19 } +19  20  +20 resource "example" "comments" { 21 resource "example" "comments" { +21  // comment 22  // comment, World! +22  # comment ..  +23  /* 23  /* +24  comment 24  comment +25  */ 25  */ + +sample_files/hcl_2.hcl --- 2/4 --- HCL +34  for1 = { for i, v in ["a", "a", "b"] : v => i... } 34  for1 = { for i, v in ["a", "a", "b"] : v => i... } +35  for2 = [ for k, v in x : "${k}-${v}" ] 35  for2 = [ for k, v in x : "${k}-${v}" ] +36  for3 = { for k, v in x: k => v } 36  for3 = { for k, v in x: k => v } +37  for4 = [ for v in x : v ] ..  +38  for5 = { for v in x : v => v } 37  for5 = { for v in y : v => v + 1 } +39  for6 = [ for v in x : v if v < 3 ] 38  for6 = [ for v in x : v if v < 3 ] +40 } 39 } +41  40  +42 resource "example" "function_expressions" { 41 resource "example" "function_expressions" { +43  func1 = is_number("123") 42  func1 = is_number("123") +44  func2 = multiline( ..  +45  arg1, ..  +46  arg2, ..  +47  arg3... ..  +48  ) ..  +49  func3 = withobject({ 43  func3 = withobject({ +50  "foo" : 2, 44  "foo" : 2, +51  "bar" : baz, 45  "bar" : baz, + +sample_files/hcl_2.hcl --- 3/4 --- HCL +55 } 49 } +56  50  +57 resource "example" "binary_expressions" { 51 resource "example" "binary_expressions" { +58  cond1 = (1 == 2) ? 1 : "foobar" 52  cond1 = (1 == 2) ? 1 : "Hello, HCL" +59  bin1 = ((1+2)%3)*4 53  bin1 = ((1+2)%3)*4 +60 } 54 } +61  55  + +sample_files/hcl_2.hcl --- 4/4 --- HCL +78  %{~endif~} 72  %{~endif~} +79  EOF 73  EOF +80  74  +81  tpl6 = <<-EOF 75  tpl6 = <<-EOF +82  %{ for a in f(b) ~} 76  %{ for a in f(x) ~} +83  %{~if a~} "true" %{~else~} "false" %{~endif~} 77  %{~if a~} "true" %{~else~} "false" %{~endif~} +84  %{ endfor ~} 78  %{ endfor ~} +85  EOF 79  EOF +..  80  +..  81  tpl7 = <<-EOF +..  82  %{ for a in f(b) ~} +..  83  "true" +..  84  %{ endfor ~} +..  85  EOF +86 } 86 } +87  87  +88 resource "example" "nested_blocks" { 88 resource "example" "nested_blocks" { diff --git a/tests/snapshots/cli__samples_side_by_side@hello_world_1.smali.snap b/tests/snapshots/cli__samples_side_by_side@hello_world_1.smali.snap new file mode 100644 index 0000000000..2e8ab19cca --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@hello_world_1.smali.snap @@ -0,0 +1,28 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/hello_world_1.smali +--- +sample_files/hello_world_2.smali --- 1/2 --- Smali +1 .class public LHelloWorld; 1 .class public LHelloPerson; +2  2  +3 #Ye olde hello world application 3 #Ye olde hello world application +4 #To assemble and run this on a phone or emulator: 4 #To assemble and run this on a phone or emulator: + +sample_files/hello_world_2.smali --- 2/2 --- Smali +15 .super Ljava/lang/Object; 15 .super Ljava/lang/Object; +16  16  +17 .method public static main([Ljava/lang/String;)V 17 .method public static main([Ljava/lang/String;)V +18  .registers 2 18  .registers 3 +19  19  +20  sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; 20  sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; +21  21  +22  const-string v1, "Hello World!" 22  const-string v1, "Hello %s!" +23  23  +..  24  const-string v2, "Evan" +..  25  +24  invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/Strin 26  invoke-virtual {v0, v1, v2}, Ljava/io/PrintStream;->printf(Ljava/lang/St +.. g;)V .. ring;Ljava/lang/String;)V +25  27  +26  return-void 28  return-void +27 .end method 29 .end method diff --git a/tests/snapshots/cli__samples_side_by_side@helpful_1.el.snap b/tests/snapshots/cli__samples_side_by_side@helpful_1.el.snap new file mode 100644 index 0000000000..998f603bd7 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@helpful_1.el.snap @@ -0,0 +1,37 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/helpful_1.el +--- +sample_files/helpful_2.el --- 1/3 --- Emacs Lisp +13 13  (start-line (line-number-at-pos)) +14 14  (start-column (current-column)) +15 15  (primitive-p (helpful--primitive-p helpful--sym helpful--callable-p)) +.. 16  (canonical-sym (helpful--canonical-symbol helpful--sym helpful--callable-p)) +16 17  (look-for-src (or (not primitive-p) +17 18  find-function-C-source-directory)) +18 19  ((buf pos opened) + +sample_files/helpful_2.el --- 2/3 --- Emacs Lisp +217 218  +218 219  (insert +219 220  (helpful--heading +... 221  (if (eq helpful--sym canonical-sym) +... 222  "Source Code" +... 223  "Alias Source Code")) +220 224  (cond +221 225  (source-path +222 226  (concat + +sample_files/helpful_2.el --- 3/3 --- Emacs Lisp +251  (t 255  (t +252  (helpful--syntax-highlight 256  (helpful--syntax-highlight +253  (concat 257  (concat +...  258  (if (eq helpful--sym canonical-sym) +254  ";; Source file is unknown, showing raw function object.\n" 259  ";; Could not find source code, showing raw function object. +...  ... \n" +...  260  ";; Could not find alias source code, showing raw function obj +...  ... ect.\n") +255  (helpful--pretty-print source))))))) 261  (helpful--pretty-print source))))))) +256  262  +257  (helpful--insert-section-break) 263  (helpful--insert-section-break) diff --git a/tests/snapshots/cli__samples_side_by_side@html_1.html.snap b/tests/snapshots/cli__samples_side_by_side@html_1.html.snap new file mode 100644 index 0000000000..fb1f10978c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@html_1.html.snap @@ -0,0 +1,66 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/html_1.html +--- +sample_files/html_2.html --- 1/2 --- HTML + 1   1  + 2 <html>  2 <html> + 3 <head>  3  <head> + 4  <title>Example Domain  4  <title>Example Domain + 5   5  + 6  <!-- demo for tree-sitter -->  6  <!-- demo for difftastic --> + 7   7  + 8  <meta charset="utf-8" />  8  <meta charset="utf-8" /> + 9  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />  9  <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> +10  <meta name="viewport" content="width=device-width, initial-scale=1" /> 10  <meta name="viewport" content="width=device-width, initial-scale=1" /> +..  11  <style type="text/css"> +..  12  p { +..  13  color: #000; +..  14  } +..  15   +11  <style type="text/css"> 16  <style type="text/css"> +12  body { 17  body { +13  background-color: #f0f0f2; 18  background-color: #fdfdff; +14  margin: 0; 19  margin: 10; +15  padding: 0; 20  padding: 10; +16  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI 21  font-family: Helvetica, Arial, sans-serif; +.. ", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; ..  +17  ..  +18  } 22  } +19  div { 23  #main { +20  width: 600px; 24  width: 600px; +21  margin: 5em auto; 25  margin: 5em auto; +22  padding: 2em; 26  padding: 2em; +23  background-color: #fdfdff; 27  background-color: #f0f0f2; +24  border-radius: 0.5em; 28  border-radius: 0.5em; +25  box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02); 29  box-shadow: 2px 3px 7px 2px rgba(0, 0, 0, 0.02); +26  } 30  } + +sample_files/html_2.html --- 2/2 --- HTML +38  43  +39  44  +40 <body> 45  <body> +41 <div> 46  <div id="main"> +42  <h1>Example Domain 47  <h1>Example Domain +43  <p>This domain is for use in illustrative examples in documents. You may 48  <p> +..  use this ..  +..  49  This domain is for use in illustrative examples in documents. You ma +..  .. y +44     domain in literature without prior coordination or asking for permission 50        use this domain in literature without prior coordination or asking f +.. . .. or +..  51   permission. +..  52  +45  <p><a href="https://www.iana.org/domains/example">More information... +.. > ..  +..  54  <a href="https://www.iana.org/domains/example?utm_src=example-dot-or +..  .. g" +..  55  >More information... +..  57  +46  58  +47 <script>alert('welcome!'); 59  <script> +..  60  alert("goodbye!"); +..  61  +48  62  +49  63  diff --git a/tests/snapshots/cli__samples_side_by_side@html_simple_1.html.snap b/tests/snapshots/cli__samples_side_by_side@html_simple_1.html.snap new file mode 100644 index 0000000000..61409d27dc --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@html_simple_1.html.snap @@ -0,0 +1,15 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/html_simple_1.html +--- +sample_files/html_simple_2.html --- HTML +1 <html> 1 <html> +2 <head> 2 <head> +3  <title>Hi! 3  <title>Hi +4  4  +5 <body class="foo"> 5 <body class="bar"> +6  <h1>Foo 6  <h1 id="title">Bar +7  <p>Story about foo. 7  <p>Story about <strong>bar. +8  8  +9  9  diff --git a/tests/snapshots/cli__samples_side_by_side@identical_1.scala.snap b/tests/snapshots/cli__samples_side_by_side@identical_1.scala.snap new file mode 100644 index 0000000000..f289caf823 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@identical_1.scala.snap @@ -0,0 +1,7 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/identical_1.scala +--- +sample_files/identical_2.scala --- Scala +No changes. diff --git a/tests/snapshots/cli__samples_side_by_side@if_1.py.snap b/tests/snapshots/cli__samples_side_by_side@if_1.py.snap new file mode 100644 index 0000000000..0e7d7e3b1e --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@if_1.py.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/if_1.py +--- +sample_files/if_2.py --- Python +1 if x: 1 if x: +2  foo 2  foo +3  bar 3 bar diff --git a/tests/snapshots/cli__samples_side_by_side@insert_blank_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@insert_blank_1.txt.snap new file mode 100644 index 0000000000..04b23eea8b --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@insert_blank_1.txt.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/insert_blank_1.txt +--- +sample_files/insert_blank_2.txt --- Text +1 1 foo +2 .  +3 2 bar diff --git a/tests/snapshots/cli__samples_side_by_side@java_1.java.snap b/tests/snapshots/cli__samples_side_by_side@java_1.java.snap new file mode 100644 index 0000000000..93ef635272 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@java_1.java.snap @@ -0,0 +1,19 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/java_1.java +--- +sample_files/java_2.java --- Java + 1 class Foo {  1 class Foo { + 2  /**  2  /** + 3    * Hello world.  3    * Hello world. + 4    *  4    * + 5    * <p>More stuff here.</p>  5    * <p>More stuff here.</p> + 6    *  6    * + 7    * @param stuff {@code String} foo bar  7    * @param stuff {@code String} foo bar + 8    * @returns {@code Other}  8    * @returns {@code int} + 9    */  9    */ +10  public static Other blah() { 10  protected static int blah() { +11  throw new Exception("before"); 11  throw new Exception("before"); +12  } 12  } +13 } 13 } diff --git a/tests/snapshots/cli__samples_side_by_side@javascript_1.js.snap b/tests/snapshots/cli__samples_side_by_side@javascript_1.js.snap new file mode 100644 index 0000000000..f1dd18a8a0 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@javascript_1.js.snap @@ -0,0 +1,82 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/javascript_1.js +--- +sample_files/javascript_2.js --- 1/5 --- JavaScript + 7 });  7 }); + 8   8  + 9 describe("Authentication", () => {  9 describe("Authentication", () => { +10  test("Editing pages", done => { 10  test("/edit GET", done => { +11  request(app) 11  request(app) +12  .get("/edit/Foo") 12  .get("/edit/Foo") +13  .then(res => { 13  .then(res => { + +sample_files/javascript_2.js --- 2/5 --- JavaScript +16  done(); 16  done(); +17  }); 17  }); +18  }); 18  }); +..  19  test("/edit POST", done => { +..  20  db.createPage("EditAuthExample", "foo bar", (err, page) => { +..  21  expect(err).toBeNull(); +..  22  +..  23  request(app) +..  24  .post("/edit/" + page.rowid) +..  25  .type("form") +..  26  .send({ name: "EditPostExample", content: "hello world" }) +..  27  .then(res => { +..  28  expect(res.statusCode).toBe(401); +..  29  expect(res.headers["www-authenticate"]).toBe("Basic"); +..  30  done(); +..  31  }); +..  32  }); +..  33  }); +19  34  +20  test("Creating pages", done => { 35  test("/new GET", done => { +21  request(app) 36  request(app) +22  .get("/new") 37  .get("/new") +23  .then(res => { 38  .then(res => { + +sample_files/javascript_2.js --- 3/5 --- JavaScript +26 41  done(); +27 42  }); +28 43  }); +.. 44  test("/new POST", done => { +.. 45  request(app) +.. 46  .post("/new") +.. 47  .type("form") +.. 48  .send({ name: "FooBarBaz", content: "hello world" }) +.. 49  .expect(401, done); +.. 50  }); +29 51 }); +30 52  +31 53 const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || "admin"; + +sample_files/javascript_2.js --- 4/5 --- JavaScript +56  .expect(200, done); 78  .expect(200, done); +57  }); 79  }); +58  }); 80  }); +59  test("/edit GET", done => { 81  test("/edit POST", done => { +60  db.createPage("EditPostExample", "foo bar", (err, page) => { 82  db.createPage("EditPostExample", "foo bar", (err, page) => { +61  expect(err).toBeNull(); 83  expect(err).toBeNull(); +62  84  + +sample_files/javascript_2.js --- 5/5 --- JavaScript +70  92  }); +71  93 }); +72  94  +..  95 describe("Viewing", () => { +73  96  test("/all", done => { +74  97  request(app) +75  98  .get("/all") +76  99  .expect(200, done); +77 100  }); + 101  + 102  test("/AnExamplePage", done => { + 103  db.createPage("AnExamplePage", "foo bar", () => { + 104  request(app) + 105  .get("/AnExamplePage") + 106  .expect(200, done); + 107  }); + 108  }); + 109 }); diff --git a/tests/snapshots/cli__samples_side_by_side@javascript_simple_1.js.snap b/tests/snapshots/cli__samples_side_by_side@javascript_simple_1.js.snap new file mode 100644 index 0000000000..29dd90c9f8 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@javascript_simple_1.js.snap @@ -0,0 +1,17 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/javascript_simple_1.js +--- +sample_files/javascript_simple_2.js --- JavaScript +1 // hello  1 // hello +.   2 if (true) { +2 foo();  3  foo(); +3 bar(1);  4  bar(2); +4 baz();  5  baz(); +.   6 } +5   7  +6 var people = [  8 var people = [ +7  "john", "harry", "dick", "eric",  9  "john", "harry", "dick", "yvonne", +8  "jenny", "alexandra", 10  "eric", "jenny", "alexandra", +9 ]; 11 ]; diff --git a/tests/snapshots/cli__samples_side_by_side@json_1.json.snap b/tests/snapshots/cli__samples_side_by_side@json_1.json.snap new file mode 100644 index 0000000000..7265679955 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@json_1.json.snap @@ -0,0 +1,11 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/json_1.json +--- +sample_files/json_2.json --- JSON +1 { 1 { +2  "foo": [1, 2, 3, 4], 2  "foo": [2, 3, 4, 5], +3  "bar": "testing" 3  "zab": "testing", +.  4  "woo": ["foobar"] +4 } 5 } diff --git a/tests/snapshots/cli__samples_side_by_side@jsx_1.jsx.snap b/tests/snapshots/cli__samples_side_by_side@jsx_1.jsx.snap new file mode 100644 index 0000000000..1390a1e2ee --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@jsx_1.jsx.snap @@ -0,0 +1,19 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/jsx_1.jsx +--- +sample_files/jsx_2.jsx --- JavaScript JSX + 1 ReactDOM.render(  1 ReactDOM.render( + 2 

Hello, world!,  2 

+ .   3  <span>Hello, world! + .   4  , + 3  document.getElementById("root"));  5  document.getElementById("root") + .   6 ); + 4   7  + 5 var x = (  8 var x = ( + 6  <div>  .  + 7 

 9 

+ 8  foo 10  foo + 9   11  ); +10  );   diff --git a/tests/snapshots/cli__samples_side_by_side@julia_1.jl.snap b/tests/snapshots/cli__samples_side_by_side@julia_1.jl.snap new file mode 100644 index 0000000000..eb8ff2b0fa --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@julia_1.jl.snap @@ -0,0 +1,33 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/julia_1.jl +--- +sample_files/julia_2.jl --- 1/2 --- Julia +26 26 israwtext(::MIME"text/plain", x::AbstractString) = false +27 27 israwtext(::MIME, x) = false +.. 28  +.. 29 InlineIOContext(io, KVs::Pair...) = IOContext( +.. 30  io, +.. 31  :limit=>true, :color=>true, :jupyter=>true, +.. 32  KVs... +.. 33 ) +28 34  +29 35 # convert x to a string of type mime, making sure to use an +30 36 # IOContext that tells the underlying show function to limit output + +sample_files/julia_2.jl --- 2/2 --- Julia +34  if israwtext(mime, x) 40  if israwtext(mime, x) +35  return String(x) 41  return String(x) +36  else 42  else +37  show(IOContext(buf, :limit=>true, :color=>true), mime, x) 43  show(InlineIOContext(buf), mime, x) +38  end 44  end +39  else 45  else +40  b64 = Base64EncodePipe(buf) 46  b64 = Base64EncodePipe(buf) +41  if isa(x, Vector{UInt8}) 47  if isa(x, Vector{UInt8}) +42  write(b64, x) # x assumed to be raw binary data 48  write(b64, x) # x assumed to be raw binary data +43  else 49  else +44  show(IOContext(b64, :limit=>true, :color=>true), mime, x) 50  show(InlineIOContext(b64), mime, x) +45  end 51  end +46  close(b64) 52  close(b64) +47  end 53  end diff --git a/tests/snapshots/cli__samples_side_by_side@load_1.js.snap b/tests/snapshots/cli__samples_side_by_side@load_1.js.snap new file mode 100644 index 0000000000..bb03252af1 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@load_1.js.snap @@ -0,0 +1,194 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/load_1.js +--- +sample_files/load_2.js --- 1/4 --- JavaScript +12  12  +13 var total = 0; 13 var total = 0; +14  14  +..  15 function createResource(resourcePath, localPath) { +15 var MIME_TYPES = { 16  var MIME_TYPES = { +16  ".css": "text/css", 17  ".css": "text/css", +17  ".html": "text/html", 18  ".html": "text/html", +18  ".js": "application/javascript", 19  ".js": "application/javascript", +19  "": "text/x-markdown", 20  "": "text/x-markdown", +20 }; 21  }; +21  ..  +22 // Write localPath to the database. ..  +23 // ..  +24 // If no resourcePath is provided, convert "node_modules/foo/bar.js" to ..  +25 // "foo/bar.js". ..  +26 function createNodeModuleResource(localPath, resourcePath) { ..  +27  if (resourcePath == null) { ..  +28  resourcePath = path.relative("node_modules", localPath); ..  +29  } ..  +30  22  +31  return function (cb) { 23  return function (cb) { +32  total++; 24  total++; + +sample_files/load_2.js --- 2/4 --- JavaScript +40  bootstrapPath: localPath, 32  bootstrapPath: localPath, +41  }).save(cb); 33  }).save(cb); +42  }; 34  }; +43 } 35 } +44  ..  +45 function createResource(resourcePath, localPath) { ..  +46  return function (cb) { ..  +47  total++; ..  +48  new models.Resource({ ..  +49  path: resourcePath, ..  +50  mimeType: MIME_TYPES[path.extname(localPath)], ..  +51  content: fs.readFileSync(localPath, { ..  +52  encoding: "utf8", ..  +53  }), ..  +54  created: Date.now(), ..  +55  bootstrapPath: localPath, ..  +56  }).save(cb); ..  +57  }; ..  +58 } ..  +59  36  +60 function createBinaryResource(opts) { 37 function createBinaryResource(opts) { +61  return function (cb) { 38  return function (cb) { + +sample_files/load_2.js --- 3/4 --- JavaScript + 92  }),  69  }), + 93   70  + 94  // Base codemirror  71  // Base codemirror + 95  createNodeModuleResource(  72  createResource( + ..   73  "codemirror/lib/codemirror.css", + 96  "node_modules/codemirror/lib/codemirror.css"  74  "node_modules/codemirror/lib/codemirror.css" + 97  ),  75  ), + 98  createNodeModuleResource("node_modules/codemirror/lib/codemirror.  76  createResource( + .. js"),  ..  + ..   77  "codemirror/lib/codemirror.js", + ..   78  "node_modules/codemirror/lib/codemirror.js" + ..   79  ), + 99   80  +100  // Editor conveniences  81  // Editor conveniences +101  createNodeModuleResource(  82  createResource( +...   83  "codemirror/addon/edit/closebrackets.js", +102  "node_modules/codemirror/addon/edit/closebrackets.js"  84  "node_modules/codemirror/addon/edit/closebrackets.js" +103  ),  85  ), +104  createNodeModuleResource(  86  createResource( +...   87  "codemirror/addon/edit/matchbrackets.js", +105  "node_modules/codemirror/addon/edit/matchbrackets.js"  88  "node_modules/codemirror/addon/edit/matchbrackets.js" +106  ),  89  ), +107  createNodeModuleResource(  90  createResource( +...   91  "codemirror/addon/selection/active-line.js", +108  "node_modules/codemirror/addon/selection/active-line.js"  92  "node_modules/codemirror/addon/selection/active-line.js" +109  ),  93  ), +110   94  +111  // Linting in editor.  95  // Linting in editor. +112  createNodeModuleResource(  96  createResource( +...   97  "codemirror/addon/lint/lint.css", +113  "node_modules/codemirror/addon/lint/lint.css"  98  "node_modules/codemirror/addon/lint/lint.css" +114  ),  99  ), +115  createNodeModuleResource( 100  createResource( +...  101  "codemirror/addon/lint/lint.js", +116  "node_modules/codemirror/addon/lint/lint.js" 102  "node_modules/codemirror/addon/lint/lint.js" +117  ), 103  ), +118  createNodeModuleResource( 104  createResource( +...  105  "codemirror/addon/lint/javascript-lint.js", +119  "node_modules/codemirror/addon/lint/javascript-lint.js" 106  "node_modules/codemirror/addon/lint/javascript-lint.js" +120  ), 107  ), +121  108  +122  // Basic, dumb completion (dabbrev style). 109  // Basic, dumb completion (dabbrev style). +123  createNodeModuleResource( 110  createResource( +...  111  "codemirror/addon/hint/show-hint.css", +124  "node_modules/codemirror/addon/hint/show-hint.css" 112  "node_modules/codemirror/addon/hint/show-hint.css" +125  ), 113  ), +126  createNodeModuleResource( 114  createResource( +...  115  "codemirror/addon/hint/show-hint.js", +127  "node_modules/codemirror/addon/hint/show-hint.js" 116  "node_modules/codemirror/addon/hint/show-hint.js" +128  ), 117  ), +129  createNodeModuleResource( 118  createResource( +...  119  "codemirror/addon/hint/anyword-hint.js", +130  "node_modules/codemirror/addon/hint/anyword-hint.js" 120  "node_modules/codemirror/addon/hint/anyword-hint.js" +131  ), 121  ), +132  createNodeModuleResource( 122  createResource( +...  123  "codemirror/addon/hint/css-hint.js", +133  "node_modules/codemirror/addon/hint/css-hint.js" 124  "node_modules/codemirror/addon/hint/css-hint.js" +134  ), 125  ), +135  createNodeModuleResource( 126  createResource( +...  127  "codemirror/addon/hint/html-hint.js", +136  "node_modules/codemirror/addon/hint/html-hint.js" 128  "node_modules/codemirror/addon/hint/html-hint.js" +137  ), 129  ), +138  createNodeModuleResource( 130  createResource( +...  131  "codemirror/addon/hint/xml-hint.js", +139  "node_modules/codemirror/addon/hint/xml-hint.js" 132  "node_modules/codemirror/addon/hint/xml-hint.js" +140  ), 133  ), +141  134  +142  // Syntax highlighting 135  // Syntax highlighting +143  createNodeModuleResource( 136  createResource( +...  137  "codemirror/mode/javascript/javascript.js", +144  "node_modules/codemirror/mode/javascript/javascript.js" 138  "node_modules/codemirror/mode/javascript/javascript.js" +145  ), 139  ), +146  createNodeModuleResource("node_modules/codemirror/mode/meta.js"), 140  createResource( +...  141  "codemirror/mode/meta.js", +...  142  "node_modules/codemirror/mode/meta.js" +...  143  ), +147  createNodeModuleResource( 144  createResource( +...  145  "codemirror/mode/markdown/markdown.js", +148  "node_modules/codemirror/mode/markdown/markdown.js" 146  "node_modules/codemirror/mode/markdown/markdown.js" +149  ), 147  ), +150  createNodeModuleResource("node_modules/codemirror/mode/xml/xml.js 148  createResource( +... "), ...  +...  149  "codemirror/mode/xml/xml.js", +...  150  "node_modules/codemirror/mode/xml/xml.js" +...  151  ), +151  createNodeModuleResource("node_modules/codemirror/mode/css/css.js 152  createResource( +... "), ...  +...  153  "codemirror/mode/css/css.js", +...  154  "node_modules/codemirror/mode/css/css.js" +...  155  ), +152  156  +153  createNodeModuleResource("node_modules/requirejs/require.js"), 157  createResource( +...  158  "requirejs/require.js", +...  159  "node_modules/requirejs/require.js" +...  160  ), +154  161  +155  createNodeModuleResource( 162  createResource("backbone.js", "node_modules/backbone/backbone.js" +...  ... ), +156  "node_modules/backbone/backbone.js", ...  +157  "backbone.js" ...  +158  ), ...  +159  163  +160  createNodeModuleResource( 164  createResource( +161  "node_modules/underscore/underscore.js", ...  +162  "underscore.js" 165  "underscore.js", +...  166  "node_modules/underscore/underscore.js" +163  ), 167  ), +164  168  +165  createNodeModuleResource( 169  createResource("jquery.js", "node_modules/jquery/dist/jquery.js") +...  ... , +166  "node_modules/jquery/dist/jquery.js", ...  +167  "jquery.js" ...  +168  ), ...  +169  170  +170  createNodeModuleResource( 171  createResource( +171  "node_modules/marked/lib/marked.js", ...  +172  "marked/marked.js" 172  "marked/marked.js", +...  173  "node_modules/marked/lib/marked.js" +173  ), 174  ), +174  175  +175  createNodeModuleResource( 176  createResource( +176  "node_modules/handlebars/dist/handlebars.js", ...  +177  "handlebars/handlebars.js" 177  "handlebars/handlebars.js", +...  178  "node_modules/handlebars/dist/handlebars.js" +178  ), 179  ), +179  180  +180  // Notifications 181  // Notifications + +sample_files/load_2.js --- 4/4 --- JavaScript +192  localPath: "icons/Error-48.png", 193  localPath: "icons/Error-48.png", +193  }), 194  }), +194  195  +...  196  // TODO: it would be nice to have more systematic naming +...  197  // of our paths, based on the node_modules path. +195  createNodeModuleResource("node_modules/mocha/mocha.js"), 198  createResource("mocha/mocha.js", "node_modules/mocha/mocha.js"), +196  createNodeModuleResource("node_modules/mocha/mocha.css"), 199  createResource("mocha/mocha.css", "node_modules/mocha/mocha.css") +...  ... , +197  200  +198  createResource("metawiki/index.html", "src/frontend/index.html"), 201  createResource("metawiki/index.html", "src/frontend/index.html"), +199  202  diff --git a/tests/snapshots/cli__samples_side_by_side@lua_1.lua.snap b/tests/snapshots/cli__samples_side_by_side@lua_1.lua.snap new file mode 100644 index 0000000000..fdcee4b7f6 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@lua_1.lua.snap @@ -0,0 +1,20 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/lua_1.lua +--- +sample_files/lua_2.lua --- Lua + 1 function test()  1 function test(name) + 2  print("testing")  2  print("testing"..name) + 3  return 10  3  return 10 + 4 end  4 end + 5   5  + 6 if test() == 20 then  6 if test("myname") == 20 then + 7  print("30")  7  print("20") + 8 end  8 end + 9   9  +10 local list = { "A", "B", "D" } 10 local list = { "A", "B", "C", "D" } +11 local table = { a = "A", b = "B", d = "D" } 11 local table = { a = "A", b = "B", c = "C", d = "D" } +12  12  +13 for k, v in pairs(table) do 13 for k, v in pairs(table) do +14  print("k: "..k.." v: "..v) 14  print("k: "..k.." v: "..v) diff --git a/tests/snapshots/cli__samples_side_by_side@metadata_1.clj.snap b/tests/snapshots/cli__samples_side_by_side@metadata_1.clj.snap new file mode 100644 index 0000000000..5b1a7dbcba --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@metadata_1.clj.snap @@ -0,0 +1,35 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/metadata_1.clj +--- +sample_files/metadata_2.clj --- 1/3 --- Clojure +2 2  "Utilities for formatting binary data (byte arrays) or binary deltas." +3 3  (:require [io.aviso.ansi :as ansi] +4 4  [io.aviso.columns :as c]) +. 5  (:import (java.nio ByteBuffer))) +5 6  +6 7 (defprotocol BinaryData +7 8  "Allows various data sources to be treated as a byte-array data type that + +sample_files/metadata_2.clj --- 2/3 --- Clojure +17 18  (data-length [ary] (alength (bytes ary))) +18 19  (byte-at [ary index] (aget (bytes ary) index))) +.. 20  +.. 21 (extend-type ByteBuffer +.. 22  BinaryData +.. 23  (data-length [b] (.remaining b)) +.. 24  (byte-at [b index] (.get ^ByteBuffer b (int index)))) +19 25  +20 26 ;;; Extends String as a convenience; assumes that the +21 27 ;;; String is in utf-8. + +sample_files/metadata_2.clj --- 3/3 --- Clojure +34 (extend-type nil 40 (extend-type nil +35  BinaryData 41  BinaryData +36  (data-length [_] 0) 42  (data-length [_] 0) +37  (byte-at [_ index] (throw (IndexOutOfBoundsException. "Can't use byte-at w 43  (byte-at [_ _index] (throw (IndexOutOfBoundsException. "Can't use byte-at  +.. ith nil.")))) .. with nil.")))) +38  44  +39 (def ^:private ^:const bytes-per-diff-line 16) 45 (def ^:private ^:const bytes-per-diff-line 16) +40 (def ^:private ^:const bytes-per-ascii-line 16) 46 (def ^:private ^:const bytes-per-ascii-line 16) diff --git a/tests/snapshots/cli__samples_side_by_side@multibyte_1.py.snap b/tests/snapshots/cli__samples_side_by_side@multibyte_1.py.snap new file mode 100644 index 0000000000..4f3ddde6fb --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@multibyte_1.py.snap @@ -0,0 +1,7 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/multibyte_1.py +--- +sample_files/multibyte_2.py --- Python +1 "foo€".format() 1 "bar€".format() diff --git a/tests/snapshots/cli__samples_side_by_side@multiline_string_1.ml.snap b/tests/snapshots/cli__samples_side_by_side@multiline_string_1.ml.snap new file mode 100644 index 0000000000..84880d9dc3 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@multiline_string_1.ml.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/multiline_string_1.ml +--- +sample_files/multiline_string_2.ml --- OCaml +1 let x = 1 let x = +2  " 2  " +3 foo 3 foo +4  4  +5 bar 5 novel +6 " 6 " diff --git a/tests/snapshots/cli__samples_side_by_side@nested_slider_1.el.snap b/tests/snapshots/cli__samples_side_by_side@nested_slider_1.el.snap new file mode 100644 index 0000000000..70efb1d600 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@nested_slider_1.el.snap @@ -0,0 +1,14 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/nested_slider_1.el +--- +sample_files/nested_slider_2.el --- Emacs Lisp + 3  (let ((root default-directory) 3  (let ((root default-directory) + 4  (project (project-current))) 4  (project (project-current))) + 5  (when project 5  (when project + 6  (-when-let (roots (project-roots project)) .  + 7  (setq root (car roots)))) 6  (setq root (project-root project))) + 8  (when root 7  (when root + 9  (deadgrep--lookup-override root)))) 8  (deadgrep--lookup-override root)))) +10    diff --git a/tests/snapshots/cli__samples_side_by_side@nested_slider_1.rs.snap b/tests/snapshots/cli__samples_side_by_side@nested_slider_1.rs.snap new file mode 100644 index 0000000000..e4d50cbb93 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@nested_slider_1.rs.snap @@ -0,0 +1,17 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/nested_slider_1.rs +--- +sample_files/nested_slider_2.rs --- Rust +1  1 fn split_string_by_codepoint_brace() { +2  2  if true { +.  3  if pad_last { +3  4  x; +4  5  } +.  6  } +5  7 } +6  8  +7  9 fn split_string_by_codepoint_paren() { +8 10  foo(bar(x)) +9 11 } diff --git a/tests/snapshots/cli__samples_side_by_side@nesting_1.el.snap b/tests/snapshots/cli__samples_side_by_side@nesting_1.el.snap new file mode 100644 index 0000000000..9e902f2857 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@nesting_1.el.snap @@ -0,0 +1,10 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/nesting_1.el +--- +sample_files/nesting_2.el --- Emacs Lisp +.  1 a +1 b 2 b +2 (foo) .  +3 foo 3 foo diff --git a/tests/snapshots/cli__samples_side_by_side@nix_1.nix.snap b/tests/snapshots/cli__samples_side_by_side@nix_1.nix.snap new file mode 100644 index 0000000000..2a36c6b266 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@nix_1.nix.snap @@ -0,0 +1,33 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/nix_1.nix +--- +sample_files/nix_2.nix --- Nix + 2   2  + 3 rustPlatform.buildRustPackage rec {  3 rustPlatform.buildRustPackage rec { + 4  pname = "difftastic";  4  pname = "difftastic"; + 5  version = "0.12.0";  5  version = "0.24.0"; + 6   6  + 7  src = fetchFromGitHub {  7  src = fetchFromGitHub { + 8  owner = "wilfred";  8  owner = "wilfred"; + 9  repo = pname;  9  repo = pname; +10  rev = version; 10  rev = version; +11  sha256 = "sha256-A6Z3g6fbYBynyN4OhRrZNO0ZghvT3XnIahdUQ8SE8tU="; 11  sha256 = "sha256-Yp0WwzGo8nuRZuiHdUPxPM1SYBeeVA3SMDfHnQmqUqY="; +12  }; 12  }; +13  13  +14  cargoSha256 = "sha256-6/JwrPymtpj/CXqx3Pe43v+MJTNONArU2WEo/zgJhT4="; 14  cargoSha256 = "sha256-m80PT2UQYhA5KEh7ax/fhh6vuse0DXhbFsh2x4pwkWY="; +15  ..  +16  postPatch = '' ..  +17  pushd vendor ..  +18  for grammar in */; do ..  +19  if [ -d "${tree-sitter.grammars}/$grammar" ]; then ..  +20  rm -r "$grammar" ..  +21  ln -s "${tree-sitter.grammars}/$grammar" ..  +22  fi ..  +23  done ..  +24  popd ..  +25  ''; ..  +26  15  +27  meta = with lib; { 16  meta = with lib; { +28  description = "A syntax-aware diff"; 17  description = "A syntax-aware diff"; diff --git a/tests/snapshots/cli__samples_side_by_side@nullable_1.kt.snap b/tests/snapshots/cli__samples_side_by_side@nullable_1.kt.snap new file mode 100644 index 0000000000..b2eebb9557 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@nullable_1.kt.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/nullable_1.kt +--- +sample_files/nullable_2.kt --- Kotlin +1 class Foo { 1 class Foo { +2  val str: String? 2  val str: String +3 } 3 } diff --git a/tests/snapshots/cli__samples_side_by_side@objc_header_1.h.snap b/tests/snapshots/cli__samples_side_by_side@objc_header_1.h.snap new file mode 100644 index 0000000000..fe7dad876d --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@objc_header_1.h.snap @@ -0,0 +1,35 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/objc_header_1.h +--- +sample_files/objc_header_2.h --- 1/2 --- Objective-C +1 // 1 // +2 //  HttpServer.h 2 //  HttpServer.h after file +3 // 3 // +4 // Created by Nicholas Moore on 20/09/2022. 4 // Created by Nicholas Moore on 20/09/2022. +.  5 // A line added to the header. +5 // 6 // +6 // Added to difftastic test suite by the author. 7 // Added to difftastic test suite by the author. +7 // This source file is released by the author into the public domain. 8 // This source file is released by the author into the public domain. + +sample_files/objc_header_2.h --- 2/2 --- Objective-C + .  16  NSDictionary *heade + .  .. rs, + .  17  NSData *body); +14  18  +15 @interface PopHttpServer : NSObject 19 @interface PopHttpServer : NSObjectqq +16 @property (readonly) uint16_t port; 20 @property(readonly) uint16_t port; // comment +..  21 @property(readonly) NSString *host; +17 @property (readonly) NSString *lastError; 22 @property(readonly) NSString *lastError; +18 @property (readonly, getter=isListening) BOOL listening; 23 @property(readonly, getter=isListening) BOOL listening; +19 - (id)initWithPort:(uint16_t)port; 24 - (id)initWithPort:(uint16_t)port; +20 - (BOOL)start; 25 - (BOOL)start; +21 - (void)stop; 26 - (void)stop; +22 - (void)registerHandler:(NSString *)pathPrefix block:(PopHttpRequestHandler) 27 - (void)registerHandler:(NSString *_Nonnull)pathPrefix +.. myblock; ..  +..  28  block:(PopHttpRequestHandler)myblock +..  29  added:(BOOL *_Nullable)added; +23 @end 30 @end +24  31  +25 NS_ASSUME_NONNULL_END 32 NS_ASSUME_NONNULL_END diff --git a/tests/snapshots/cli__samples_side_by_side@ocaml_1.ml.snap b/tests/snapshots/cli__samples_side_by_side@ocaml_1.ml.snap new file mode 100644 index 0000000000..1c30b439db --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@ocaml_1.ml.snap @@ -0,0 +1,26 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/ocaml_1.ml +--- +sample_files/ocaml_2.ml --- OCaml + 3   3  + 4 type foo =  4 type foo = + 5  | Bar  5  | Bar + 6  | Baz of int * ('ex, 'en) list  .  + 7  | Biz of ('ex, 'en) list  6  | Biz of ('ex, 'en) list + 8   7  + 9 let do_stuff x =  8 let do_stuff x = +10  match x with  9  match x with +11  | `Foo -> 1 10  | `Foo -> 1 +12  | `Bar -> 2 ..  +13  | _ -> 3 11  | _ -> 3 +14  12  +15 let stuffs y = 13 let stuffs y = +16  y + 1 14  y + 1 +17  15  +18 type thing = 16 type thing = +19  | X 17  | X [@visitor.opaque] +20  | Y 18  | Y +  19 [@@visitor.opaque] +  20  diff --git a/tests/snapshots/cli__samples_side_by_side@outer_delimiter_1.el.snap b/tests/snapshots/cli__samples_side_by_side@outer_delimiter_1.el.snap new file mode 100644 index 0000000000..4ebb832a6b --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@outer_delimiter_1.el.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/outer_delimiter_1.el +--- +sample_files/outer_delimiter_2.el --- Emacs Lisp + 1 (foo +1 2  (read) +. 3  ) diff --git a/tests/snapshots/cli__samples_side_by_side@pascal_1.pascal.snap b/tests/snapshots/cli__samples_side_by_side@pascal_1.pascal.snap new file mode 100644 index 0000000000..7ca3306ff3 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@pascal_1.pascal.snap @@ -0,0 +1,18 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/pascal_1.pascal +--- +sample_files/pascal_2.pascal --- Pascal +13  if N < K then 13  if N < K then +14  Result:= 0 // Error 14  Result:= 0 // Error +15  else begin 15  else begin +16  if K > N - K then ..  +17  K:= N - K; // Optimization ..  +18  Result:= 1; 16  Result:= 1; +19  L:= 0; 17  L:= 0; +20  while L < K do begin 18  while L < K do begin +21  Result:= Result * (N - L); 19  Result:= Result * (N - 1); +22  Inc(L); 20  Inc(L); +23  Result:= Result div L; 21  Result:= Result div L; +24  end; 22  end; diff --git a/tests/snapshots/cli__samples_side_by_side@perl_1.pl.snap b/tests/snapshots/cli__samples_side_by_side@perl_1.pl.snap new file mode 100644 index 0000000000..fe39ffdd09 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@perl_1.pl.snap @@ -0,0 +1,38 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/perl_1.pl +--- +sample_files/perl_2.pl --- Perl + 9 print "Pi equals ", PI, "...\n";  9 print "Pi equals ", PI, "...\n"; +10  10  +11 use constant { 11 use constant { +12  SEC => 0, # foo bar 12  SEC => 0, # foo +13  MIN => 1, 13  MIN => 1, +14  HOUR => 2, 14  HOUR => 2, +15  MDAY => 3, 15  MDAY => 3, +16  MON => 4, 16  MON => 4, +17  YEAR => 5, 17  YEAR => 5, +18  WDAY => 6, 18  WDAY => 6, +19  YDAY => 7, 19  YDAY => 7, +20  ISDST => 8, 20  ISDST => 10, +21 }; 21 }; +..  22  +..  23 my $setting = { +..  24  open => 1, +..  25  close => 2, +..  26  run => 3, +..  27  awesome => 'yes', +..  28 }; +..  29 my %final; +..  30 foreach my $key (woof()) { +..  31  $final{IRONMAN}{$key} = $setting->{$key}; +..  32  +..  33  print Dumper \%final; +..  34 } +22  35  +23 use constant WEEKDAYS => qw( 36 use constant WEEKDAYS => qw( +24  Sunday Monday Tuesday Wednesday Thursday Friday Saturday 37  Sunday Monday Tuesday Wednesday Thursday Friday Saturday +25 ); 38 ); +26  39  +27 $f =~ s/foo/bar/g; 40 $f =~ s/foo/abc/g; diff --git a/tests/snapshots/cli__samples_side_by_side@prefer_outer_1.el.snap b/tests/snapshots/cli__samples_side_by_side@prefer_outer_1.el.snap new file mode 100644 index 0000000000..1282f0feeb --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@prefer_outer_1.el.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/prefer_outer_1.el +--- +sample_files/prefer_outer_2.el --- Emacs Lisp +1 1 (defun deadgrep--find-file (path) +2 .  (save-match-data +3 2  (let* ((initial-buffers (buffer-list)) +4 3  (buf (save-match-data (find-file-noselect path)))) +5 4  (unless (-contains-p initial-buffers buf) +6 5  (setq opened t)) +7 6  (cons buf opened)))) diff --git a/tests/snapshots/cli__samples_side_by_side@preprocesor_1.h.snap b/tests/snapshots/cli__samples_side_by_side@preprocesor_1.h.snap new file mode 100644 index 0000000000..3dcda50758 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@preprocesor_1.h.snap @@ -0,0 +1,10 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/preprocesor_1.h +--- +sample_files/preprocesor_2.h --- C++ +1 1 #include "foo.h" +. 2 #include "novel.h" +2 3  +3 4 struct Bar {}; diff --git a/tests/snapshots/cli__samples_side_by_side@qml_1.qml.snap b/tests/snapshots/cli__samples_side_by_side@qml_1.qml.snap new file mode 100644 index 0000000000..58d2c2059f --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@qml_1.qml.snap @@ -0,0 +1,34 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/qml_1.qml +--- +sample_files/qml_2.qml --- 1/2 --- QML +1 // Taken from https://doc.qt.io/qt-6/qmlapplications.html +2 import QtQuick 2.15 +3 import QtQuick.Controls 2.15 +4  +5 ApplicationWindow { +6  width: 400 + +sample_files/qml_2.qml --- 2/2 --- QML + 9   9  +10  Button { 10  Button { +11  id: button 11  id: button +..  12  hoverEnabled: true +12  text: "A Special Button" 13  text: "A Special Button" +13  background: Rectangle { 14  background: Rectangle { +14  implicitWidth: 100 15  implicitWidth: 100 +15  implicitHeight: 40 16  implicitHeight: 40 +16  color: button.down ? "#d6d6d6" : "#f6f6f6" 17  color: { +..  18  if (button.down || button.hovered) { +..  19  "#d6d6d6" +..  20  } else { +..  21  "#f6f6f6" +..  22  } +..  23  } +17  border.color: "#26282a" 24  border.color: "#26282a" +18  border.width: 1 25  border.width: button.down ? 2 : 1 +19  radius: 4 26  radius: 4 +20  } 27  } +21  } 28  } diff --git a/tests/snapshots/cli__samples_side_by_side@racket_1.rkt.snap b/tests/snapshots/cli__samples_side_by_side@racket_1.rkt.snap new file mode 100644 index 0000000000..9027129e6e --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@racket_1.rkt.snap @@ -0,0 +1,23 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/racket_1.rkt +--- +sample_files/racket_2.rkt --- Racket + 1 #lang racket/base  1 #lang racket + 2   2  + 3 (define (append lst1 lst2)  3 (define (append lst1 lst2) + 4  (cond [(null? lst1) lst2]  4  (if (null? lst1) + .   5  lst2 + 5  [else (cons (car lst1)  6  (cons (car lst1) + 6  (append (cdr lst1) lst2))]))  7  (append (cdr lst1) lst2)))) + 7   8  + 8 (append '(a b c) '(d e))  9 (append '(a b c) '(d e f)) + 9  10  +10 "Hello, world!" 11 "Hello, world!\n" +11 #(1 2 3) 12 #(0 1 2 3 4) +12 #\" 13 #\space +13  14  +14 #<<END 15 #<<E +15 abc 16 abc +16 END 17 E diff --git a/tests/snapshots/cli__samples_side_by_side@ruby_1.rb.snap b/tests/snapshots/cli__samples_side_by_side@ruby_1.rb.snap new file mode 100644 index 0000000000..3b2b30a82c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@ruby_1.rb.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/ruby_1.rb +--- +sample_files/ruby_2.rb --- 1/2 --- Ruby +1 1 # Hello world +2 . gem "jekyll", "~> #{Jekyll::VERSION}" + +sample_files/ruby_2.rb --- 2/2 --- Ruby +1 1 VALID_FILENAME_CHARS = 'foo' +2 .  diff --git a/tests/snapshots/cli__samples_side_by_side@scala_1.scala.snap b/tests/snapshots/cli__samples_side_by_side@scala_1.scala.snap new file mode 100644 index 0000000000..bbd4290f26 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@scala_1.scala.snap @@ -0,0 +1,28 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/scala_1.scala +--- +sample_files/scala_2.scala --- Scala + 1 package foo  1 package foo + 2   2  + 3 // A Scala program.  3 // A Scala program. + 4 import foo.Bar  4 import foo.Baz + 5   5  + 6 class Foo {  6 class Foo { + 7   7  + 8  def blah(): Int {  8  private def blah(): Other { + 9  /* foo */  9  /* foo */ +10  throw new Exception("before"); 10  throw new Exception("after"); +11  } 11  } +12  12  +13  var result = Option.empty[T] 13  var result = Option.empty[T] +..  14  val fn = pf.lift +14  object traverser extends SimpleTraverser { 15  object traverser extends SimpleTraverser { +15  override def apply(t: Tree): Unit = { 16  override def apply(t: Tree): Unit = { +16  if (result.isEmpty && pf.isDefinedAt(t)) { ..  +17  result = Some(pf(t)) 17  result = fn(t).orElse(result) +18  } else if (result.isEmpty) { 18  if (result.nonEmpty) { +19  super.apply(t) 19  super.apply(t) +20  } 20  } +21  } 21  } diff --git a/tests/snapshots/cli__samples_side_by_side@scheme_1.scm.snap b/tests/snapshots/cli__samples_side_by_side@scheme_1.scm.snap new file mode 100644 index 0000000000..59e2eb9ee3 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@scheme_1.scm.snap @@ -0,0 +1,10 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/scheme_1.scm +--- +sample_files/scheme_2.scm --- Scheme +1 |# A block comment before a very simple function. #| 1 |# A block comment before a simple function, but changed. #| +2 (define (add x y) ; This function returns the sum of it 2 (define (sub x y) ; This function returns the differenc +. s arguments . e of its arguments +3  (+ x y)) 3  (- x y)) diff --git a/tests/snapshots/cli__samples_side_by_side@simple_1.js.snap b/tests/snapshots/cli__samples_side_by_side@simple_1.js.snap new file mode 100644 index 0000000000..5c5f8050dc --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@simple_1.js.snap @@ -0,0 +1,8 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/simple_1.js +--- +sample_files/simple_2.js --- JavaScript +1 const React = require('react'); 1 import React, {useState} from 'react'; +2 console.log('hello world'); 2 console.log('hello world'); diff --git a/tests/snapshots/cli__samples_side_by_side@simple_1.scss.snap b/tests/snapshots/cli__samples_side_by_side@simple_1.scss.snap new file mode 100644 index 0000000000..874bcbe3d1 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@simple_1.scss.snap @@ -0,0 +1,33 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/simple_1.scss +--- +sample_files/simple_2.scss --- 1/2 --- SCSS + 1 @mixin buttons($basicBorder:1px, $gradient1:#fff, $gradient2:#d8dee7){  1 @mixin buttons($basicBorder:1px, $gradient1:#333, $gradient2:#d8dee7){ + 2  button{  2  button{ + 3  border:$basicBorder solid #acbed3;  3  border:$basicBorder dotted #acbed3; + 4  //brings in Compass' background-image mixin: http://compass-style.org/r  4  //brings in Compass' background-image mixin: http://compass-style.org/r + . eference/compass/css3/images/  . eference/compass/css3/images/ + 5  @include background-image(linear-gradient($gradient1, $gradient2));  5  @include background-image(linear-gradient($gradient1, $gradient2)); + 6  padding:3px 14px;  6  padding:3px 14px; + 7  font-size:12px;  7  font-size:1rem; + 8  color:#3b557d;  8  color:#3b557d; + 9  //brings in Compass' border-radius mixin: http://compass-style.org/refer  9  //brings in Compass' border-radius mixin: http://compass-style.org/refer + . ence/compass/css3/border_radius/  . ence/compass/css3/border_radius/ +10  @include border-radius($border-radius, $border-radius); 10  @include border-radius($border-radius, $border-radius); + +sample_files/simple_2.scss --- 2/2 --- SCSS +13  //& attribute adds  13  //& attribute adds  +14  14  +15  &.primary { 15  &.primary { +16  border:2px solid #3b557d; 16  border:2px dotted #3b557d; +17  padding:5px 15px; 17  padding:5px 15px; +18  //requires a $border-radius variable 18  //requires a $border-radius variable +19  @include border-radius($border-radius + 2, $border-radius + 2); 19  @include border-radius($border-radius + 2, $border-radius + 2); +20  } 20  } +21  &.disabled { 21  &.disabled { +22  opacity: .8; 22  opacity: .6; +23  } 23  } +24  &:hover { 24  &:hover { +25  @include background-image(linear-gradient($gradient2, $gradient1)); 25  @include background-image(linear-gradient($gradient2, $gradient1)); diff --git a/tests/snapshots/cli__samples_side_by_side@simple_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@simple_1.txt.snap new file mode 100644 index 0000000000..8aed0784de --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@simple_1.txt.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/simple_1.txt +--- +sample_files/simple_2.txt --- 1/2 --- Text +1 1 foo +. 2  + +sample_files/simple_2.txt --- 2/2 --- Text +1 1 bar +. 2 baz diff --git a/tests/snapshots/cli__samples_side_by_side@slider_at_end_1.json.snap b/tests/snapshots/cli__samples_side_by_side@slider_at_end_1.json.snap new file mode 100644 index 0000000000..e8642cfb3c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@slider_at_end_1.json.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/slider_at_end_1.json +--- +sample_files/slider_at_end_2.json --- JSON +1 1 [ +2 2  "one", +3 .  "novel-1", +4 3  "two", +5 .  "novel-2", +6 4  "three" +7 5 ] diff --git a/tests/snapshots/cli__samples_side_by_side@small_1.js.snap b/tests/snapshots/cli__samples_side_by_side@small_1.js.snap new file mode 100644 index 0000000000..1c1b07f942 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@small_1.js.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/small_1.js +--- +sample_files/small_2.js --- JavaScript + 7 });  7 }); + 8   8  + 9 describe("Authentication", () => {  9 describe("Authentication", () => { +10  test("Editing pages", done => { 10  test("/edit GET", done => { +11  request(app) 11  request(app) +12  .get("/edit/Foo") 12  .get("/edit/Foo") +13  .then(res => { 13  .then(res => { diff --git a/tests/snapshots/cli__samples_side_by_side@string_subwords_1.el.snap b/tests/snapshots/cli__samples_side_by_side@string_subwords_1.el.snap new file mode 100644 index 0000000000..fb6bfd1e47 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@string_subwords_1.el.snap @@ -0,0 +1,20 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/string_subwords_1.el +--- +sample_files/string_subwords_2.el --- Emacs Lisp + 1 (format "SoloWiki Viewing: %s" name)  1 (format "%s: %s" (site-name) name) + 2   2  + 3 (defcustom deadgrep-max-buffers  3 (defcustom deadgrep-max-buffers + 4  4  4  4 + 5  "Deadgrep will kill the least recently used results buffer  5  "The maximum number of deadgrep results buffers. + 6 if there are more than this many.  6  + 7   7 If the number of results buffers exceeds this value, deadgrep + 8 To disable cleanup entirely, set this variable to nil."  8 will kill results buffers. The least recently used buffers are + .   9 killed first. + .  10  + .  11 To disable cleanup entirely, set this variable to nil." + 9  :type '(choice 12  :type '(choice +10  (number :tag "Maximum of buffers allowed") 13  (number :tag "Maximum of buffers allowed") +11  (const :tag "Disable cleanup" nil)) 14  (const :tag "Disable cleanup" nil)) diff --git a/tests/snapshots/cli__samples_side_by_side@swift_1.swift.snap b/tests/snapshots/cli__samples_side_by_side@swift_1.swift.snap new file mode 100644 index 0000000000..f4231d6c0d --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@swift_1.swift.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/swift_1.swift +--- +sample_files/swift_2.swift --- Swift +1 func f(_ x: Int) -> Int { 1 func f(_ x: Int) -> Int { +2  x * 2 2  x * 3 +3 } 3 } diff --git a/tests/snapshots/cli__samples_side_by_side@syntax_error_1.js.snap b/tests/snapshots/cli__samples_side_by_side@syntax_error_1.js.snap new file mode 100644 index 0000000000..650dfde438 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@syntax_error_1.js.snap @@ -0,0 +1,9 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/syntax_error_1.js +--- +sample_files/syntax_error_2.js --- Text (2 JavaScript parse errors, exceeded DFT_PARSE_ERROR_LIMIT) +1 if (true) { 1 if (false) { +2   foo(1); 2   foo(2); +3 }} 3 }} diff --git a/tests/snapshots/cli__samples_side_by_side@tab_1.c.snap b/tests/snapshots/cli__samples_side_by_side@tab_1.c.snap new file mode 100644 index 0000000000..d1cc8807f4 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@tab_1.c.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/tab_1.c +--- +sample_files/tab_2.c --- C +1 #include  1 #include  +2  2  +3 int main() { 3 int main() { +4  printf("Hello World"); 4  printf("Goodbye World"); +5  return 0; 5  return 0; +6 } 6 } diff --git a/tests/snapshots/cli__samples_side_by_side@tab_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@tab_1.txt.snap new file mode 100644 index 0000000000..169892c70f --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@tab_1.txt.snap @@ -0,0 +1,15 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/tab_1.txt +--- +sample_files/tab_2.txt --- Text +1  export const ORIGIN = new URL( +2   env.VERCEL_ENV === "production" +3    ? "https://alpha.sweets.community" +4    : env.VERCEL_ENV === "preview" +5     ? `https://${env.VERCEL_URL}` +6     : "http://localhost:3000" +7  ); +8   +9 1 export default env; diff --git a/tests/snapshots/cli__samples_side_by_side@tailwind_1.css.snap b/tests/snapshots/cli__samples_side_by_side@tailwind_1.css.snap new file mode 100644 index 0000000000..899abcd310 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@tailwind_1.css.snap @@ -0,0 +1,11 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/tailwind_1.css +--- +sample_files/tailwind_2.css --- CSS +2  /* This isn't valid vanilla CSS, and tree-sitter-css produces an ERROR 2  /* This isn't valid vanilla CSS, and tree-sitter-css produces an ERROR +3  node with children. Ensure the whole ERROR is treated as an 3  node with children. Ensure the whole ERROR is treated as an +4  atom. */ 4  atom. */ +5  @apply rounded-md bg-gray-600; 5  @apply rounded-md bg-hss-dark-gray; +6 } 6 } diff --git a/tests/snapshots/cli__samples_side_by_side@text_1.txt.snap b/tests/snapshots/cli__samples_side_by_side@text_1.txt.snap new file mode 100644 index 0000000000..dc994d6db8 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@text_1.txt.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/text_1.txt +--- +sample_files/text_2.txt --- Text +1 hello 1 hello +.  2 novel +2 world 3 world +3  4  +4 foo 5 foo bar +5 c07e640b246c7885cbc3d5c627acbcb2d2ab9c95 6 31df1778815171897c907daf454c4419cfaa46f9 diff --git a/tests/snapshots/cli__samples_side_by_side@todomvc_1.gleam.snap b/tests/snapshots/cli__samples_side_by_side@todomvc_1.gleam.snap new file mode 100644 index 0000000000..805633546e --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@todomvc_1.gleam.snap @@ -0,0 +1,31 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/todomvc_1.gleam +--- +sample_files/todomvc_2.gleam --- 1/3 --- Gleam +16  let db = start_database_connection_pool() 16  let db = start_database_connection_pool() +17  let web = routes.stack(application_secret, db) 17  let web = routes.stack(application_secret, db) +18  18  +..  19  let log_string = +19  string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) 20  string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) +20  |> log.info 21  log.info(log_string) +21  22  +22  assert Ok(_) = elli.become(web, on_port: port) 23  assert Ok(_) = elli.become(web, on_port: port) +23 } 24 } + +sample_files/todomvc_2.gleam --- 2/3 --- Gleam +29  |> result.lazy_unwrap(fn() { 30  |> result.lazy_unwrap(fn() { +30  pgo.Config( 31  pgo.Config( +31  ..pgo.default_config(), 32  ..pgo.default_config(), +32  host: "localhost", 33  host: "0.0.0.0", +33  database: "gleam_todomvc_dev", 34  database: "gleam_todomvc_dev", +34  user: "postgres", 35  user: "postgres", +35  password: option.Some("postgres"), 36  password: option.Some("postgres"), + +sample_files/todomvc_2.gleam --- 3/3 --- Gleam +47 fn load_port() -> Int { 48 fn load_port() -> Int { +48  os.get_env("PORT") 49  os.get_env("PORT") +49  |> result.then(int.parse) 50  |> result.then(int.parse) +50  |> result.unwrap(3000) 51  |> result.unwrap(8080) +51 } 52 } diff --git a/tests/snapshots/cli__samples_side_by_side@toml_1.toml.snap b/tests/snapshots/cli__samples_side_by_side@toml_1.toml.snap new file mode 100644 index 0000000000..c70428b717 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@toml_1.toml.snap @@ -0,0 +1,32 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/toml_1.toml +--- +sample_files/toml_2.toml --- 1/2 --- TOML + 1 # This is a TOML document  1 # This is a TOML document + 2   2  + 3 title = "TOML Example"  3 title = "TOML Example Changed" + 4   4  + 5 [owner]  5 [owner] + 6 name = "Tom Preston-Werner"  6 name = "Tom Preston-Werner" + 7 dob = 1979-05-27T07:32:00-08:00  7 dob = 2000-01-31T07:32:00-08:00 + 8   8  + 9 [database]  9 [database] +10 enabled = true 10 enabled = true +11 ports = [ 8000, 8001, 8002 ] 11 ports = [ 8000, 8002 ] +12 data = [ ["delta", "phi"], [3.14] ] 12 data = [ ["delta", "phi"], [3.14] ] +13 temp_targets = { cpu = 79.5, case = 72.0 } 13 temp_targets = { cpu = 79.5, case = 72.0 } +14  14  + +sample_files/toml_2.toml --- 2/2 --- TOML +26 26 Roses are red +27 27 Violets are blue""" +28   +29  str2 = """\ +30   The quick brown \ +31   fox jumps over \ +32   the lazy dog.\ +33   """ +34   +35  path = 'C:\Users\nodejs\templates' diff --git a/tests/snapshots/cli__samples_side_by_side@trailling_newline_1.yaml.snap b/tests/snapshots/cli__samples_side_by_side@trailling_newline_1.yaml.snap new file mode 100644 index 0000000000..e5ae826e0f --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@trailling_newline_1.yaml.snap @@ -0,0 +1,8 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/trailling_newline_1.yaml +--- +sample_files/trailling_newline_2.yaml --- YAML +1 foo: | 1 foo: | +2  ${{ BAR }} 2  bar diff --git a/tests/snapshots/cli__samples_side_by_side@typescript_1.ts.snap b/tests/snapshots/cli__samples_side_by_side@typescript_1.ts.snap new file mode 100644 index 0000000000..f63b57ea51 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@typescript_1.ts.snap @@ -0,0 +1,11 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/typescript_1.ts +--- +sample_files/typescript_2.ts --- TypeScript +1 1 type Symbol = { +2 2  kind: "symbol"; +. 3  name: string; +3 4  items: string[]; +4 5 }; diff --git a/tests/snapshots/cli__samples_side_by_side@utf16_1.py.snap b/tests/snapshots/cli__samples_side_by_side@utf16_1.py.snap new file mode 100644 index 0000000000..5204ef053e --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@utf16_1.py.snap @@ -0,0 +1,11 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/utf16_1.py +--- +sample_files/utf16_2.py --- Python +1 # coding=utf_16 1 # coding=utf_16 +2 # This file contains a Byte Order Mark denoting little-endianness. 2 # This file contains a Byte Order Mark denoting little-endianness. +3  3  +4 print("hello ☃ snowman") 4 print("no snowman") +  5 print("こんにちは世界") diff --git a/tests/snapshots/cli__samples_side_by_side@vhdl_1.vhd.snap b/tests/snapshots/cli__samples_side_by_side@vhdl_1.vhd.snap new file mode 100644 index 0000000000..7596d189a5 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@vhdl_1.vhd.snap @@ -0,0 +1,37 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/vhdl_1.vhd +--- +sample_files/vhdl_2.vhd --- VHDL + 5 entity blinky is  5 entity blinky is + 6  port (  6  port ( + 7  clk: in std_logic;  7  clk: in std_logic; + 8  led: out std_logic  8  led: out std_logic_vector(3 downto 0) + 9  );  9  ); +10 end entity; 10 end entity; +11  11  +12 architecture a of blinky is 12 architecture a of blinky is +13  constant CLK_FREQ: positive := 12_000_000; 13  constant CLK_FREQ: positive := 48_000_000; +14  signal counter: unsigned(23 downto 0) := (others => '0'); 14  signal counter1: unsigned(25 downto 0) := (others => '0'); +..  15  signal counter2: unsigned(1 downto 0) := (others => '0'); +15 begin 16 begin +16  process(clk) 17  process(clk) +17  begin 18  begin +18  if rising_edge(clk) then 19  if rising_edge(clk) then +19  if to_integer(counter) = CLK_FREQ / 2 then 20  if to_integer(counter1) = CLK_FREQ / 2 then +20  led <= not led; 21  counter2 <= counter2 + 1; +21  counter <= (others => '0'); 22  counter1 <= (others => '0'); +22  else 23  else +23  counter <= counter + 1; 24  counter1 <= counter1 + 1; +24  end if; 25  end if; +25  end if; 26  end if; +26  end process; 27  end process; +..  28  +..  29  process(counter2) +..  30  begin +..  31  for n in 0 to 3 loop +..  32  led(n) <= '1' when to_integer(counter2) = n else '0'; +..  33  end loop; +..  34  end process; +27 end architecture; 35 end architecture; diff --git a/tests/snapshots/cli__samples_side_by_side@whitespace_1.tsx.snap b/tests/snapshots/cli__samples_side_by_side@whitespace_1.tsx.snap new file mode 100644 index 0000000000..09a88eb25c --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@whitespace_1.tsx.snap @@ -0,0 +1,13 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/whitespace_1.tsx +--- +sample_files/whitespace_2.tsx --- TypeScript TSX +20 20  <FontAwesomeIcon + 21  icon={faPlus} + 22  /> + 23  {" "} + 24  Adicionar arquivos + 25  {" "} + 26  diff --git a/tests/snapshots/cli__samples_side_by_side@xml_1.xml.snap b/tests/snapshots/cli__samples_side_by_side@xml_1.xml.snap new file mode 100644 index 0000000000..780e8a94c9 --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@xml_1.xml.snap @@ -0,0 +1,10 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/xml_1.xml +--- +sample_files/xml_2.xml --- XML +1 <root> 1 <root> +2 <b>foo bar baz 2 <b>foo bar baz x +.  3 <stuff/> +3  4  diff --git a/tests/snapshots/cli__samples_side_by_side@yaml_1.yaml.snap b/tests/snapshots/cli__samples_side_by_side@yaml_1.yaml.snap new file mode 100644 index 0000000000..f72315aacd --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@yaml_1.yaml.snap @@ -0,0 +1,16 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/yaml_1.yaml +--- +sample_files/yaml_2.yaml --- YAML +1 --- 1 --- +2 foo: [foobar] 2 foo: [bar, foobar] +3 hello: 3 hello: +4  - "world" 4  - "world" +.  5  - 'item' +5  - other 6  - other +6    +7 stuff: |   +8  a   +9  b   diff --git a/tests/snapshots/cli__samples_side_by_side@zig_1.zig.snap b/tests/snapshots/cli__samples_side_by_side@zig_1.zig.snap new file mode 100644 index 0000000000..4cdc849f5f --- /dev/null +++ b/tests/snapshots/cli__samples_side_by_side@zig_1.zig.snap @@ -0,0 +1,12 @@ +--- +source: tests/cli.rs +expression: stdout +input_file: sample_files/zig_1.zig +--- +sample_files/zig_2.zig --- Zig +.  1 const std = @import("std"); +.  2  +1 pub fn main() void { 3 pub fn main() void { +2  std.debug.print("Hello, {s}!", .{"world"}); 4  std.debug.print("Hello, {s}!", .{"user"}); +.  5  std.debug.print("Hello, again!", .{}); +3 } 6 }