FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lua-diff/tests/basic.lua at master · yuri/lua-diff · GitHub
yuri
/
lua-diff
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
15
Code
Issues
1
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
lua-diff
/
tests
/
basic.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
83 lines (62 loc) · 2.27 KB
Breadcrumbs
lua-diff
/
tests
/
basic.lua
Copy path
File metadata and controls
83 lines (62 loc) · 2.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require
"
diff
"
--
Print test split
TO_BE
=
[[
To <b>be</b>, or not to be:
that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them?
]]
TO_BE_2
=
[[
To <b>be</b>, and <i>not</i> to be:
that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take legs against a sea of troubles,
And by opposing end them?
]]
HTML_DIFF
=
[[
To <b>be</b>, <del>or</del><ins>and</ins> <del>not</del><ins><i>not</i></ins> to be:
that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take <del>arms</del><ins>legs</ins> against a sea of troubles,
And by opposing end them?
]]
SPLIT_1
=
{
"
To
"
,
"
"
,
"
<b>be</b>,
"
,
"
"
,
"
or
"
,
"
"
,
"
not
"
,
"
"
,
"
to
"
,
"
"
,
"
be:
"
,
"
\
"
,
"
that
"
,
"
"
,
"
is
"
,
"
"
,
"
the
"
,
"
"
,
"
question:
"
,
"
\
"
,
"
Whether
"
,
"
"
,
"
'tis
"
,
"
"
,
"
nobler
"
,
"
"
,
"
in
"
,
"
"
,
"
the
"
,
"
"
,
"
mind
"
,
"
"
,
"
to
"
,
"
"
,
"
suffer
"
,
"
\
"
,
"
The
"
,
"
"
,
"
slings
"
,
"
"
,
"
and
"
,
"
"
,
"
arrows
"
,
"
"
,
"
of
"
,
"
"
,
"
outrageous
"
,
"
"
,
"
fortune,
"
,
"
\
"
,
"
Or
"
,
"
"
,
"
to
"
,
"
"
,
"
take
"
,
"
"
,
"
arms
"
,
"
"
,
"
against
"
,
"
"
,
"
a
"
,
"
"
,
"
sea
"
,
"
"
,
"
of
"
,
"
"
,
"
troubles,
"
,
"
\
"
,
"
And
"
,
"
"
,
"
by
"
,
"
"
,
"
opposing
"
,
"
"
,
"
end
"
,
"
"
,
"
them?
"
,
"
\
"
}
SPLIT_2
=
{
"
To <b>be</b>, or not to be:
"
,
"
that is the question:
"
,
"
Whether 'tis nobler in the mind to suffer
"
,
"
The slings and arrows of outrageous fortune,
"
,
"
Or to take arms against a sea of troubles,
"
,
"
And by opposing end them?
"
}
local
result
=
diff
.
split
(
TO_BE
)
for
i
,
v
in
ipairs
(
result
)
do
--
print(string.format("[%s], [%s]", v, SPLIT_1[i]))
assert
(
v
==
SPLIT_1
[
i
])
end
local
result
=
diff
.
split
(
TO_BE
,
"
\n
"
,
true
)
for
i
,
v
in
ipairs
(
result
)
do
--
print(string.format("[%s], [%s]", v, SPLIT_1[i]))
assert
(
v
==
SPLIT_2
[
i
])
end
--
for i, v in ipairs(diff.diff(TO_BE, TO_BE_2)) do
--
if v[2]~="same" then
--
print (v[1], v[2])
--
end
--
end
d
=
diff
.
diff
(
TO_BE
,
TO_BE_2
):
to_html
()
assert
(
d
==
HTML_DIFF
)
--
buffer = ""
--
for i,v in ipairs(result) do
--
buffer = buffer..string.format(" %q,", v)
--
end
--
print (buffer)
Back
|
FazBrowse Home
|
New Git URL