1- import { test } from 'tap' ;
1+ import { test } from 'node:test' ;
2+ import { strict as assert } from 'node:assert' ;
23import * as Diff3 from '../index.mjs' ;
34
4- test ( 'diff3Merge' , t => {
5+ test ( 'diff3Merge' , async t => {
56
6- t . test ( 'performs diff3 merge on arrays' , t => {
7+ await t . test ( 'performs diff3 merge on arrays' , t => {
78 const o = [ 'AA' , 'ZZ' , '00' , 'M' , '99' ] ;
89 const a = [ 'AA' , 'a' , 'b' , 'c' , 'ZZ' , 'new' , '00' , 'a' , 'a' , 'M' , '99' ] ;
910 const b = [ 'AA' , 'a' , 'd' , 'c' , 'ZZ' , '11' , 'M' , 'z' , 'z' , '99' ] ;
@@ -38,115 +39,106 @@ test('diff3Merge', t => {
3839 99
3940 */
4041
41- t . same ( result [ 0 ] . ok , [ 'AA' ] ) ;
42- t . same ( result [ 0 ] . conflict , undefined ) ;
42+ assert . deepEqual ( result [ 0 ] . ok , [ 'AA' ] ) ;
43+ assert . deepEqual ( result [ 0 ] . conflict , undefined ) ;
4344
44- t . same ( result [ 1 ] . ok , undefined ) ;
45- t . same ( result [ 1 ] . conflict . o , [ ] ) ;
46- t . same ( result [ 1 ] . conflict . a , [ 'a' , 'b' , 'c' ] ) ;
47- t . same ( result [ 1 ] . conflict . b , [ 'a' , 'd' , 'c' ] ) ;
45+ assert . deepEqual ( result [ 1 ] . ok , undefined ) ;
46+ assert . deepEqual ( result [ 1 ] . conflict . o , [ ] ) ;
47+ assert . deepEqual ( result [ 1 ] . conflict . a , [ 'a' , 'b' , 'c' ] ) ;
48+ assert . deepEqual ( result [ 1 ] . conflict . b , [ 'a' , 'd' , 'c' ] ) ;
4849
49- t . same ( result [ 2 ] . ok , [ 'ZZ' ] ) ;
50- t . same ( result [ 2 ] . conflict , undefined ) ;
50+ assert . deepEqual ( result [ 2 ] . ok , [ 'ZZ' ] ) ;
51+ assert . deepEqual ( result [ 2 ] . conflict , undefined ) ;
5152
52- t . same ( result [ 3 ] . ok , undefined ) ;
53- t . same ( result [ 3 ] . conflict . o , [ '00' ] ) ;
54- t . same ( result [ 3 ] . conflict . a , [ 'new' , '00' , 'a' , 'a' ] ) ;
55- t . same ( result [ 3 ] . conflict . b , [ '11' ] ) ;
53+ assert . deepEqual ( result [ 3 ] . ok , undefined ) ;
54+ assert . deepEqual ( result [ 3 ] . conflict . o , [ '00' ] ) ;
55+ assert . deepEqual ( result [ 3 ] . conflict . a , [ 'new' , '00' , 'a' , 'a' ] ) ;
56+ assert . deepEqual ( result [ 3 ] . conflict . b , [ '11' ] ) ;
5657
57- t . same ( result [ 4 ] . ok , [ 'M' , 'z' , 'z' , '99' ] ) ;
58- t . same ( result [ 4 ] . conflict , undefined ) ;
59-
60- t . end ( ) ;
58+ assert . deepEqual ( result [ 4 ] . ok , [ 'M' , 'z' , 'z' , '99' ] ) ;
59+ assert . deepEqual ( result [ 4 ] . conflict , undefined ) ;
6160 } ) ;
6261
6362
64- t . test ( 'strings split on whitespace by default to avoid surprises - issue #9' , t => {
63+ await t . test ( 'strings split on whitespace by default to avoid surprises - issue #9' , t => {
6564 const o = 'was touring' ;
6665 const a = 'was here touring' ;
6766 const b = 'was into touring' ;
6867 const result = Diff3 . diff3Merge ( a , o , b ) ;
6968
70- t . same ( result [ 0 ] . ok , [ 'was' ] ) ;
71- t . same ( result [ 0 ] . conflict , undefined ) ;
72-
73- t . same ( result [ 1 ] . ok , undefined ) ;
74- t . same ( result [ 1 ] . conflict . o , [ ] ) ;
75- t . same ( result [ 1 ] . conflict . a , [ 'here' ] ) ;
76- t . same ( result [ 1 ] . conflict . b , [ 'into' ] ) ;
69+ assert . deepEqual ( result [ 0 ] . ok , [ 'was' ] ) ;
70+ assert . deepEqual ( result [ 0 ] . conflict , undefined ) ;
7771
78- t . same ( result [ 2 ] . ok , [ 'touring' ] ) ;
79- t . same ( result [ 2 ] . conflict , undefined ) ;
72+ assert . deepEqual ( result [ 1 ] . ok , undefined ) ;
73+ assert . deepEqual ( result [ 1 ] . conflict . o , [ ] ) ;
74+ assert . deepEqual ( result [ 1 ] . conflict . a , [ 'here' ] ) ;
75+ assert . deepEqual ( result [ 1 ] . conflict . b , [ 'into' ] ) ;
8076
81- t . end ( ) ;
77+ assert . deepEqual ( result [ 2 ] . ok , [ 'touring' ] ) ;
78+ assert . deepEqual ( result [ 2 ] . conflict , undefined ) ;
8279 } ) ;
8380
84- t . test ( 'strings can optionally split on given separator' , t => {
81+ await t . test ( 'strings can optionally split on given separator' , t => {
8582 const o = 'new hampshire, new mexico, north carolina' ;
8683 const a = 'new hampshire, new jersey, north carolina' ;
8784 const b = 'new hampshire, new york, north carolina' ;
8885 const result = Diff3 . diff3Merge ( a , o , b , { stringSeparator : / , \s + / } ) ;
8986
90- t . same ( result [ 0 ] . ok , [ 'new hampshire' ] ) ;
91- t . same ( result [ 0 ] . conflict , undefined ) ;
87+ assert . deepEqual ( result [ 0 ] . ok , [ 'new hampshire' ] ) ;
88+ assert . deepEqual ( result [ 0 ] . conflict , undefined ) ;
9289
93- t . same ( result [ 1 ] . ok , undefined ) ;
94- t . same ( result [ 1 ] . conflict . o , [ 'new mexico' ] ) ;
95- t . same ( result [ 1 ] . conflict . a , [ 'new jersey' ] ) ;
96- t . same ( result [ 1 ] . conflict . b , [ 'new york' ] ) ;
90+ assert . deepEqual ( result [ 1 ] . ok , undefined ) ;
91+ assert . deepEqual ( result [ 1 ] . conflict . o , [ 'new mexico' ] ) ;
92+ assert . deepEqual ( result [ 1 ] . conflict . a , [ 'new jersey' ] ) ;
93+ assert . deepEqual ( result [ 1 ] . conflict . b , [ 'new york' ] ) ;
9794
98- t . same ( result [ 2 ] . ok , [ 'north carolina' ] ) ;
99- t . same ( result [ 2 ] . conflict , undefined ) ;
100-
101- t . end ( ) ;
95+ assert . deepEqual ( result [ 2 ] . ok , [ 'north carolina' ] ) ;
96+ assert . deepEqual ( result [ 2 ] . conflict , undefined ) ;
10297 } ) ;
10398
10499
105- t . test ( 'excludes false conflicts by default' , t => {
100+ await t . test ( 'excludes false conflicts by default' , t => {
106101 const o = 'AA ZZ' ;
107102 const a = 'AA a b c ZZ' ;
108103 const b = 'AA a b c ZZ' ;
109104 const result = Diff3 . diff3Merge ( a , o , b ) ;
110105
111- t . same ( result [ 0 ] . ok , [ 'AA' , 'a' , 'b' , 'c' , 'ZZ' ] ) ;
112- t . same ( result [ 0 ] . conflict , undefined ) ;
113- t . end ( ) ;
106+ assert . deepEqual ( result [ 0 ] . ok , [ 'AA' , 'a' , 'b' , 'c' , 'ZZ' ] ) ;
107+ assert . deepEqual ( result [ 0 ] . conflict , undefined ) ;
114108 } ) ;
115109
116110
117- t . test ( 'can include false conflicts with option' , t => {
111+ await t . test ( 'can include false conflicts with option' , t => {
118112 const o = 'AA ZZ' ;
119113 const a = 'AA a b c ZZ' ;
120114 const b = 'AA a b c ZZ' ;
121115 const result = Diff3 . diff3Merge ( a , o , b , { excludeFalseConflicts : false } ) ;
122116
123- t . same ( result [ 0 ] . ok , [ 'AA' ] ) ;
124- t . same ( result [ 0 ] . conflict , undefined ) ;
117+ assert . deepEqual ( result [ 0 ] . ok , [ 'AA' ] ) ;
118+ assert . deepEqual ( result [ 0 ] . conflict , undefined ) ;
125119
126- t . same ( result [ 1 ] . ok , undefined ) ;
127- t . same ( result [ 1 ] . conflict . o , [ ] ) ;
128- t . same ( result [ 1 ] . conflict . a , [ 'a' , 'b' , 'c' ] ) ;
129- t . same ( result [ 1 ] . conflict . b , [ 'a' , 'b' , 'c' ] ) ;
120+ assert . deepEqual ( result [ 1 ] . ok , undefined ) ;
121+ assert . deepEqual ( result [ 1 ] . conflict . o , [ ] ) ;
122+ assert . deepEqual ( result [ 1 ] . conflict . a , [ 'a' , 'b' , 'c' ] ) ;
123+ assert . deepEqual ( result [ 1 ] . conflict . b , [ 'a' , 'b' , 'c' ] ) ;
130124
131- t . same ( result [ 2 ] . ok , [ 'ZZ' ] ) ;
132- t . same ( result [ 2 ] . conflict , undefined ) ;
133- t . end ( ) ;
125+ assert . deepEqual ( result [ 2 ] . ok , [ 'ZZ' ] ) ;
126+ assert . deepEqual ( result [ 2 ] . conflict , undefined ) ;
134127 } ) ;
135128
136129
137- t . test ( 'avoids improper hunk sorting - see openstreetmap/iD#3058' , t => {
130+ await t . test ( 'avoids improper hunk sorting - see openstreetmap/iD#3058' , t => {
138131 const o = [ 'n4100522632' , 'n4100697091' , 'n4100697136' , 'n4102671583' , 'n4102671584' , 'n4102671585' , 'n4102671586' , 'n4102671587' , 'n4102671588' , 'n4102677889' , 'n4102677890' , 'n4094374176' ] ;
139132 const a = [ 'n4100522632' , 'n4100697091' , 'n4100697136' , 'n-10000' , 'n4102671583' , 'n4102671584' , 'n4102671585' , 'n4102671586' , 'n4102671587' , 'n4102671588' , 'n4102677889' , 'n4102677890' , 'n4094374176' ] ;
140133 const b = [ 'n4100522632' , 'n4100697091' , 'n4100697136' , 'n4102671583' , 'n4102671584' , 'n4102671585' , 'n4102671586' , 'n4102671587' , 'n4102671588' , 'n4102677889' , 'n4105613618' , 'n4102677890' , 'n4105613617' , 'n4094374176' ] ;
141134 const expected = [ 'n4100522632' , 'n4100697091' , 'n4100697136' , 'n-10000' , 'n4102671583' , 'n4102671584' , 'n4102671585' , 'n4102671586' , 'n4102671587' , 'n4102671588' , 'n4102677889' , 'n4105613618' , 'n4102677890' , 'n4105613617' , 'n4094374176' ] ;
142135 const result = Diff3 . diff3Merge ( a , o , b ) ;
143136
144- t . same ( result [ 0 ] . ok , expected ) ;
145- t . end ( ) ;
137+ assert . deepEqual ( result [ 0 ] . ok , expected ) ;
146138 } ) ;
147139
148140
149- t . test ( 'yaml comparison - issue #46' , t => {
141+ await t . test ( 'yaml comparison - issue #46' , t => {
150142 const o = `title: "title"
151143description: "description"` ;
152144 const a = `title: "title"
@@ -155,12 +147,9 @@ description: "description changed"`;
155147description: "description"` ;
156148 const result = Diff3 . diff3Merge ( a , o , b , { stringSeparator : / [ \r \n ] + / } ) ;
157149
158- t . same ( result [ 0 ] . ok , undefined ) ;
159- t . same ( result [ 0 ] . conflict . o , [ 'title: "title"' , 'description: "description"' ] ) ;
160- t . same ( result [ 0 ] . conflict . a , [ 'title: "title"' , 'description: "description changed"' ] ) ;
161- t . same ( result [ 0 ] . conflict . b , [ 'title: "title changed"' , 'description: "description"' ] ) ;
162- t . end ( ) ;
150+ assert . deepEqual ( result [ 0 ] . ok , undefined ) ;
151+ assert . deepEqual ( result [ 0 ] . conflict . o , [ 'title: "title"' , 'description: "description"' ] ) ;
152+ assert . deepEqual ( result [ 0 ] . conflict . a , [ 'title: "title"' , 'description: "description changed"' ] ) ;
153+ assert . deepEqual ( result [ 0 ] . conflict . b , [ 'title: "title changed"' , 'description: "description"' ] ) ;
163154 } ) ;
164-
165- t . end ( ) ;
166155} ) ;
0 commit comments