mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-03-06 14:09:32 +00:00
Merge branch 'master' into more-encompassing-number-skips
This commit is contained in:
6
test/fixtures/Data/Modelines/fundamentalEmacs.c
vendored
Normal file
6
test/fixtures/Data/Modelines/fundamentalEmacs.c
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// -*- fundamental -*-
|
||||
|
||||
int main(int argc, char * argc[])
|
||||
{
|
||||
this should not be syntax highlighted, even though it looks like c.
|
||||
}
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs1
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs1
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*-c++-*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs2
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs2
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- c++ -*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs3
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs3
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- mode:C++ -*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs4
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs4
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- font:bar;mode:c++ -*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs5
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs5
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*-foo:bar;mode:c++;bar:foo-*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs6
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs6
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- foo : bar ; mode : c++ ; bar : foo -*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs7
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs7
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- mode : c++ ; bar : foo -*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs8
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs8
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*- font:x;foo : bar ; mode : C++ ; bar : foo ; foooooo:baaaaar;fo:ba-*-
|
||||
template <typename X> class { X i; };
|
||||
2
test/fixtures/Data/Modelines/seeplusplusEmacs9
vendored
Normal file
2
test/fixtures/Data/Modelines/seeplusplusEmacs9
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// -*-foo:bar;mode:c++;bar:foo;tyrell:corp-*-
|
||||
template <typename X> class { X i; };
|
||||
12
test/fixtures/Data/sourcemap.v1.map
vendored
Normal file
12
test/fixtures/Data/sourcemap.v1.map
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/** Begin line maps. **/{ “file”:”out.js”, "count": 2 }
|
||||
[0,0,0,0,0,0,1,1,1,1,2]
|
||||
[2,2,2,2,2,2,3,4,4,4,4,4]
|
||||
/** Begin file information. **/
|
||||
[“a.js”, “b.js”]
|
||||
[“b.js”, “c.js”, “d.js”]
|
||||
/** Begin mapping definitions. **/
|
||||
["a.js", 1, 34]
|
||||
["a.js", 5, 2]
|
||||
["b.js", 1, 3, "event"]
|
||||
["c.js", 1, 4]
|
||||
["d.js", 3, 78, "foo"]
|
||||
1
test/fixtures/Data/sourcemap.v3.map
vendored
Normal file
1
test/fixtures/Data/sourcemap.v3.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"out.js","sourceRoot":"","sources":["foo.js","bar.js"],"sourcesContent":[null,null],"names":["src","maps","are","fun"],"mappings":"A,AAAB;;ABCDE;"}
|
||||
50
test/fixtures/Generated/ABM8G.mod
vendored
Normal file
50
test/fixtures/Generated/ABM8G.mod
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
PCBNEW-LibModule-V1 Wed 10 Aug 2011 05:57:27 PM COT
|
||||
# encoding utf-8
|
||||
$INDEX
|
||||
ABM8G
|
||||
$EndINDEX
|
||||
$MODULE ABM8G
|
||||
Po 0 0 0 15 4E430CBD 4E430CC5 ~~
|
||||
Li ABM8G
|
||||
Sc 4E430CC5
|
||||
AR
|
||||
Op 0 0 0
|
||||
T0 591 -1378 354 354 0 39 N V 21 N "ABM8G"
|
||||
T1 0 787 354 354 0 39 N V 21 N "VAL**"
|
||||
DS -591 394 1299 394 79 21
|
||||
DS 1299 394 1299 -1063 79 21
|
||||
DS 1299 -1063 -472 -1063 79 21
|
||||
DS -472 -1063 -472 472 79 21
|
||||
DS -472 472 -472 551 79 21
|
||||
DS -472 551 -591 551 79 21
|
||||
DS -591 551 -591 433 79 21
|
||||
$PAD
|
||||
Sh "1" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 0 0
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "2" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 866 0
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "3" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 866 -669
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "4" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 0 -669
|
||||
$EndPAD
|
||||
$EndMODULE ABM8G
|
||||
$EndLIBRARY
|
||||
19
test/fixtures/Generated/ms2.mod
vendored
Normal file
19
test/fixtures/Generated/ms2.mod
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
GFORTRAN module version '0' created from ms2.f90 on Thu Sep 5 10:09:19 2013
|
||||
MD5:8a80cd5db1bc612a28603959302dbf37 -- If you edit this, you'll get what you deserve.
|
||||
|
||||
(() () () () () () () () () () () () () () () () () () () () () () () ()
|
||||
() () ())
|
||||
|
||||
()
|
||||
|
||||
()
|
||||
|
||||
()
|
||||
|
||||
()
|
||||
|
||||
(2 'ms2' 'ms2' 'ms2' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
|
||||
UNKNOWN) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
|
||||
)
|
||||
|
||||
('ms2' 0 2)
|
||||
1
test/fixtures/SVG/alg_schema.link.svg
vendored
Symbolic link
1
test/fixtures/SVG/alg_schema.link.svg
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
alg_schema.svg
|
||||
269
test/fixtures/SVG/alg_schema.svg
vendored
Normal file
269
test/fixtures/SVG/alg_schema.svg
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.0 r9654"
|
||||
sodipodi:docname="alg_schema.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.834386"
|
||||
inkscape:cx="409.42881"
|
||||
inkscape:cy="681.83774"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="g3759"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="993"
|
||||
inkscape:window-x="1280"
|
||||
inkscape:window-y="31"
|
||||
inkscape:window-maximized="0"
|
||||
showguides="true"
|
||||
inkscape:snap-global="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3914" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g3759"
|
||||
transform="translate(-3.3909149,-21.218048)">
|
||||
<rect
|
||||
ry="11.855058"
|
||||
rx="14.468504"
|
||||
y="138.58023"
|
||||
x="108.08632"
|
||||
height="66.263969"
|
||||
width="247.48737"
|
||||
id="rect2985"
|
||||
style="fill:#1f3d55;fill-opacity:1;fill-rule:evenodd;stroke:#3f5d75;stroke-width:5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755"
|
||||
y="163.58023"
|
||||
x="238.39091"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:24px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"
|
||||
y="163.58023"
|
||||
x="238.39091"
|
||||
id="tspan3757"
|
||||
sodipodi:role="line">Sequence KEY</tspan><tspan
|
||||
style="font-size:24px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"
|
||||
y="193.58023"
|
||||
x="238.39091"
|
||||
sodipodi:role="line"
|
||||
id="tspan4055">256 bits</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g3870"
|
||||
transform="translate(-0.73178617,29.27145)">
|
||||
<g
|
||||
id="g3759-5"
|
||||
transform="translate(-0.40143056,286.32219)">
|
||||
<rect
|
||||
style="fill:#1f3d55;fill-opacity:1;fill-rule:evenodd;stroke:#3f5d75;stroke-width:5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="rect2985-5"
|
||||
width="247.48737"
|
||||
height="74.751289"
|
||||
x="108.08632"
|
||||
y="130.09291"
|
||||
rx="14.468504"
|
||||
ry="13.373494" />
|
||||
<flowRoot
|
||||
transform="translate(2.4712344,-292.01415)"
|
||||
style="font-size:24px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
id="flowRoot3797"
|
||||
xml:space="preserve"><flowRegion
|
||||
id="flowRegion3799"><rect
|
||||
style="font-size:24px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"
|
||||
y="428.79074"
|
||||
x="125"
|
||||
height="58.346195"
|
||||
width="86.479271"
|
||||
id="rect3801" /></flowRegion><flowPara
|
||||
id="flowPara3805">Salt</flowPara><flowPara
|
||||
id="flowPara3841">96 bits</flowPara></flowRoot> <flowRoot
|
||||
transform="translate(115.26831,-291.40674)"
|
||||
style="font-size:24px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
id="flowRoot3797-6"
|
||||
xml:space="preserve"><flowRegion
|
||||
id="flowRegion3799-5"><rect
|
||||
style="font-size:24px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"
|
||||
y="428.79074"
|
||||
x="125"
|
||||
height="60.933453"
|
||||
width="104.07261"
|
||||
id="rect3801-6" /></flowRegion><flowPara
|
||||
id="flowPara3805-9">Counter</flowPara><flowPara
|
||||
id="flowPara3809-3">32 bits</flowPara></flowRoot> <path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3845"
|
||||
d="m 229.11476,138.88943 0,57.95451"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.6979728,0,0,0.6979728,71.363842,197.71804)"
|
||||
id="g3759-7">
|
||||
<rect
|
||||
ry="13.373494"
|
||||
rx="14.297379"
|
||||
y="130.09291"
|
||||
x="108.08632"
|
||||
height="74.751289"
|
||||
width="244.56023"
|
||||
id="rect2985-4"
|
||||
style="fill:#1f3d55;fill-opacity:1;fill-rule:evenodd;stroke:#3f5d75;stroke-width:7.16360283;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755-5"
|
||||
y="178.58023"
|
||||
x="141.31805"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#beff83;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:32px;fill:#beff83;fill-opacity:1"
|
||||
y="178.58023"
|
||||
x="141.31805"
|
||||
id="tspan3757-2"
|
||||
sodipodi:role="line">AES Cipher</tspan></text>
|
||||
</g>
|
||||
<path
|
||||
style="fill:#6ea1cc;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
|
||||
d="m 225,437.36218 0,-50 -15,5 25,-35 25,35 -15,-5 0,50 z"
|
||||
id="path3912"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<path
|
||||
style="fill:#6ea1cc;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 340,302.36218 50,0 -5,-15 35,25 -35,25 5,-15 -50,0 z"
|
||||
id="path3912-5"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<path
|
||||
style="fill:#6ea1cc;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 245,192.36218 0,50 15,-5 -25,35 -25,-35 15,5 0,-50 z"
|
||||
id="path3912-4"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<g
|
||||
transform="matrix(0.6979728,0,0,0.6979728,361.36384,197.71804)"
|
||||
id="g3759-7-7">
|
||||
<rect
|
||||
ry="13.373494"
|
||||
rx="17.857012"
|
||||
y="130.09291"
|
||||
x="108.08632"
|
||||
height="74.751289"
|
||||
width="305.44867"
|
||||
id="rect2985-4-4"
|
||||
style="fill:#1f3d55;fill-opacity:1;fill-rule:evenodd;stroke:#3f5d75;stroke-width:7.16360283;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3755-5-4"
|
||||
y="159.80484"
|
||||
x="255.9357"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#beff83;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:25.78897095px;text-align:center;text-anchor:middle;fill:#beff83;fill-opacity:1"
|
||||
y="159.80484"
|
||||
x="255.9357"
|
||||
sodipodi:role="line"
|
||||
id="tspan3979">Secure random data</tspan><tspan
|
||||
style="font-size:25.78897095px;text-align:center;text-anchor:middle;fill:#beff83;fill-opacity:1"
|
||||
y="192.04105"
|
||||
x="255.9357"
|
||||
sodipodi:role="line"
|
||||
id="tspan3983">128 bits</tspan></text>
|
||||
</g>
|
||||
<path
|
||||
style="fill:#6ea1cc;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;opacity:0.45614035"
|
||||
d="m 550,352.36218 0,50 15,-5 -25,35 -25,-35 15,5 0,-50 z"
|
||||
id="path3912-5-0"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="540"
|
||||
y="382.36218"
|
||||
id="text4003"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
x="540"
|
||||
y="382.36218"
|
||||
id="tspan4007"
|
||||
style="font-size:16px;text-align:center;text-anchor:middle">Division by alphabet length</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="540"
|
||||
y="402.36218"
|
||||
style="font-size:16px;text-align:center;text-anchor:middle"
|
||||
id="tspan4053">repeated passcode-length times.</tspan></text>
|
||||
<g
|
||||
transform="matrix(0.6979728,0,0,0.6979728,344.55869,369.3865)"
|
||||
id="g3759-7-7-7">
|
||||
<g
|
||||
id="g4045"
|
||||
transform="translate(-1.21417,-6.070852)">
|
||||
<rect
|
||||
style="fill:#1f3d55;fill-opacity:1;fill-rule:evenodd;stroke:#3f5d75;stroke-width:7.16360283;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="rect2985-4-4-8"
|
||||
width="305.44867"
|
||||
height="74.751289"
|
||||
x="131.15555"
|
||||
y="130.09291"
|
||||
rx="17.857012"
|
||||
ry="13.373494" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#beff83;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
|
||||
x="283.77673"
|
||||
y="158.71724"
|
||||
id="text3755-5-4-6"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
id="tspan3983-8"
|
||||
sodipodi:role="line"
|
||||
x="283.77673"
|
||||
y="158.71724"
|
||||
style="font-size:25.78897095px;text-align:center;text-anchor:middle;fill:#beff83;fill-opacity:1">Passcode</tspan><tspan
|
||||
id="tspan4043"
|
||||
sodipodi:role="line"
|
||||
x="283.77673"
|
||||
y="190.95346"
|
||||
style="font-size:25.78897095px;text-align:center;text-anchor:middle;fill:#beff83;fill-opacity:1">2-16 characters</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
175
test/fixtures/Shell/_bashrc
vendored
Normal file
175
test/fixtures/Shell/_bashrc
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
# vim: set ft=sh:
|
||||
|
||||
# encoding
|
||||
export LC_CTYPE='en_US.UTF-8'
|
||||
# terminal color
|
||||
export TERM=xterm-256color
|
||||
# prompt setup
|
||||
current_branch() {
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
||||
}
|
||||
parse_branch() {
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
|
||||
}
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\e[00;32m\]\u@\h:\[\e[01;34m\]\W\[\033[01;35m\]$(parse_branch)\[\e[01;35m\]\[\e[0m\] $ '
|
||||
|
||||
google () {
|
||||
search=""
|
||||
echo "Googling: $@"
|
||||
for term in $@; do
|
||||
search="$search%20$term"
|
||||
done
|
||||
xdg-open "http://www.google.com/search?q=$search"
|
||||
}
|
||||
|
||||
# alias
|
||||
alias emacs='emacs -nw'
|
||||
alias eshell='emacs --execute "(term \"`which zsh`\")"'
|
||||
- () {
|
||||
cd -
|
||||
}
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias _=sudo
|
||||
alias afind='ack-grep -il'
|
||||
alias c=clear
|
||||
alias cd..='cd ..'
|
||||
alias cd...='cd ../..'
|
||||
alias cd....='cd ../../..'
|
||||
alias cd.....='cd ../../../..'
|
||||
alias d='dirs -v | head -10'
|
||||
alias emacs='emacs -nw'
|
||||
alias g=git
|
||||
alias ga='git add'
|
||||
alias gap='git add --patch'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
alias gbr='git branch --remote'
|
||||
alias gc='git commit -v'
|
||||
alias 'gc!'='git commit -v --amend'
|
||||
alias gca='git commit -v -a'
|
||||
alias 'gca!'='git commit -v -a --amend'
|
||||
alias gcl='git config --list'
|
||||
alias gclean='git reset --hard && git clean -dfx'
|
||||
alias gcln='git clone'
|
||||
alias gcm='git checkout master'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gco='git checkout'
|
||||
alias gcount='git shortlog -sn'
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcs='git commit -S'
|
||||
alias gd='git diff'
|
||||
alias gdc='git diff --cached'
|
||||
alias gdt='git difftool'
|
||||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
|
||||
alias ggpull='git pull origin $(current_branch)'
|
||||
alias ggpur='git pull --rebase origin $(current_branch)'
|
||||
alias ggpush='git push origin $(current_branch)'
|
||||
alias gmpush='git push wkentaro $(current_branch)'
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
alias git=hub
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
alias gk='gitk --all --branches'
|
||||
alias gl='git pull'
|
||||
alias glg='git log --stat --max-count=10'
|
||||
alias glgg='git log --graph --max-count=10'
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
alias glo='git log --oneline --decorate --color'
|
||||
alias globurl='noglob urlglobber '
|
||||
alias glog='git log --oneline --decorate --color --graph'
|
||||
alias glp=_git_log_prettily
|
||||
alias gm='git merge'
|
||||
alias gmt='git mergetool --no-prompt'
|
||||
alias gp='git push'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
alias gr='git remote'
|
||||
alias grba='git rebase --abort'
|
||||
alias grbc='git rebase --continue'
|
||||
alias grbi='git rebase -i'
|
||||
alias grh='git reset HEAD'
|
||||
alias grhh='git reset HEAD --hard'
|
||||
alias grmv='git remote rename'
|
||||
alias grrm='git remote remove'
|
||||
alias grset='git remote set-url'
|
||||
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
|
||||
alias grup='git remote update'
|
||||
alias grv='git remote -v'
|
||||
alias gsd='git svn dcommit'
|
||||
alias gsps='git show --pretty=short --show-signature'
|
||||
alias gsr='git svn rebase'
|
||||
alias gss='git status -s'
|
||||
alias gst='git status'
|
||||
alias gsta='git stash'
|
||||
alias gstd='git stash drop'
|
||||
alias gstp='git stash pop'
|
||||
alias gsts='git stash show --text'
|
||||
alias gts='git tag -s'
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
|
||||
alias gup='git pull --rebase'
|
||||
alias gvt='git verify-tag'
|
||||
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit -m "--wip--"'
|
||||
alias h=history
|
||||
alias history='fc -l 1'
|
||||
alias ipy=ipython
|
||||
alias sl='ls'
|
||||
alias l='ls -lah'
|
||||
alias la='ls -lAh'
|
||||
alias ll='ls -lh'
|
||||
alias lsa='ls -lah'
|
||||
alias md='mkdir -p'
|
||||
alias py=python
|
||||
alias please=sudo
|
||||
alias po=popd
|
||||
alias pu=pushd
|
||||
alias pyfind='find . -name "*.py"'
|
||||
alias pygrep='grep --include="*.py"'
|
||||
alias rd=rmdir
|
||||
alias v=vim
|
||||
alias vi=vim
|
||||
alias which-command=whence
|
||||
# hub
|
||||
if which hub >/dev/null 2>&1; then
|
||||
eval "$(hub alias -s)"
|
||||
fi
|
||||
# open
|
||||
if which open >/dev/null 2>&1; then
|
||||
alias o='open'
|
||||
alias o.='open .'
|
||||
elif which gnome-open >/dev/null 2>&1; then
|
||||
alias open='gnome-open'
|
||||
alias o='gnome-open'
|
||||
alias o.='gnome-open .'
|
||||
fi
|
||||
# ls
|
||||
if which dircolors >/dev/null 2>&1; then
|
||||
eval `dircolors $HOME/.colorrc`
|
||||
alias ls='ls --color=auto'
|
||||
fi
|
||||
[[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
|
||||
|
||||
cd () {
|
||||
if [[ "x$*" = "x..." ]]
|
||||
then
|
||||
cd ../..
|
||||
elif [[ "x$*" = "x...." ]]
|
||||
then
|
||||
cd ../../..
|
||||
elif [[ "x$*" = "x....." ]]
|
||||
then
|
||||
cd ../../../..
|
||||
elif [[ "x$*" = "x......" ]]
|
||||
then
|
||||
cd ../../../../..
|
||||
elif [ -d ~/.autoenv ]
|
||||
then
|
||||
source ~/.autoenv/activate.sh
|
||||
autoenv_cd "$@"
|
||||
else
|
||||
builtin cd "$@"
|
||||
fi
|
||||
}
|
||||
@@ -2,6 +2,7 @@ require "bundler/setup"
|
||||
require "minitest/autorun"
|
||||
require "mocha/setup"
|
||||
require "linguist"
|
||||
require 'color-proximity'
|
||||
|
||||
def fixtures_path
|
||||
File.expand_path("../fixtures", __FILE__)
|
||||
|
||||
@@ -216,6 +216,16 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob("C++/protocol-buffer.pb.cc").generated?
|
||||
assert sample_blob("Java/ProtocolBuffer.java").generated?
|
||||
assert sample_blob("Python/protocol_buffer_pb2.py").generated?
|
||||
assert sample_blob("Go/api.pb.go").generated?
|
||||
assert sample_blob("Go/embedded.go").generated?
|
||||
|
||||
# Apache Thrift generated code
|
||||
assert sample_blob("Python/gen-py-linguist-thrift.py").generated?
|
||||
assert sample_blob("Go/gen-go-linguist-thrift.go").generated?
|
||||
assert sample_blob("Java/gen-java-linguist-thrift.java").generated?
|
||||
assert sample_blob("JavaScript/gen-js-linguist-thrift.js").generated?
|
||||
assert sample_blob("Ruby/gen-rb-linguist-thrift.rb").generated?
|
||||
assert sample_blob("Objective-C/gen-cocoa-linguist-thrift.m").generated?
|
||||
|
||||
# Generated JNI
|
||||
assert sample_blob("C/jni_layer.h").generated?
|
||||
@@ -233,12 +243,18 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob("Zephir/filenames/exception.zep.php").generated?
|
||||
assert !sample_blob("Zephir/Router.zep").generated?
|
||||
|
||||
|
||||
assert Linguist::Generated.generated?("node_modules/grunt/lib/grunt.js", nil)
|
||||
assert sample_blob("node_modules/grunt/lib/grunt.js").generated?
|
||||
|
||||
# Godep saved dependencies
|
||||
assert sample_blob("Godeps/Godeps.json").generated?
|
||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
||||
|
||||
# Cython-generated C/C++
|
||||
assert sample_blob("C/sgd_fast.c").generated?
|
||||
assert sample_blob("C++/wrapper_inner.cpp").generated?
|
||||
|
||||
# Unity3D-generated metadata
|
||||
assert sample_blob("Unity3D Asset/Tiles.meta").generated?
|
||||
end
|
||||
|
||||
def test_vendored
|
||||
@@ -263,6 +279,9 @@ class TestBlob < Minitest::Test
|
||||
# Rails vendor/
|
||||
assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
||||
|
||||
# Vendor/
|
||||
assert sample_blob("Vendor/my_great_file.h").vendored?
|
||||
|
||||
# 'thirdparty' directory
|
||||
assert sample_blob("thirdparty/lib/main.c").vendored?
|
||||
|
||||
@@ -274,6 +293,8 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob("deps/http_parser/http_parser.c").vendored?
|
||||
assert sample_blob("deps/v8/src/v8.h").vendored?
|
||||
|
||||
assert sample_blob("tools/something/else.c").vendored?
|
||||
|
||||
# Chart.js
|
||||
assert sample_blob("some/vendored/path/Chart.js").vendored?
|
||||
assert !sample_blob("some/vendored/path/chart.js").vendored?
|
||||
@@ -284,6 +305,9 @@ class TestBlob < Minitest::Test
|
||||
# Debian packaging
|
||||
assert sample_blob("debian/cron.d").vendored?
|
||||
|
||||
# Erlang
|
||||
assert sample_blob("rebar").vendored?
|
||||
|
||||
# Minified JavaScript and CSS
|
||||
assert sample_blob("foo.min.js").vendored?
|
||||
assert sample_blob("foo.min.css").vendored?
|
||||
@@ -292,6 +316,9 @@ class TestBlob < Minitest::Test
|
||||
assert !sample_blob("foomin.css").vendored?
|
||||
assert !sample_blob("foo.min.txt").vendored?
|
||||
|
||||
#.osx
|
||||
assert sample_blob(".osx").vendored?
|
||||
|
||||
# Prototype
|
||||
assert !sample_blob("public/javascripts/application.js").vendored?
|
||||
assert sample_blob("public/javascripts/prototype.js").vendored?
|
||||
@@ -299,6 +326,9 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob("public/javascripts/controls.js").vendored?
|
||||
assert sample_blob("public/javascripts/dragdrop.js").vendored?
|
||||
|
||||
# Samples
|
||||
assert sample_blob("Samples/Ruby/foo.rb").vendored?
|
||||
|
||||
# jQuery
|
||||
assert sample_blob("jquery.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery.js").vendored?
|
||||
@@ -396,6 +426,9 @@ class TestBlob < Minitest::Test
|
||||
# Normalize
|
||||
assert sample_blob("some/asset/path/normalize.css").vendored?
|
||||
|
||||
# Carthage
|
||||
assert sample_blob('Carthage/blah').vendored?
|
||||
|
||||
# Cocoapods
|
||||
assert sample_blob('Pods/blah').vendored?
|
||||
|
||||
@@ -406,6 +439,7 @@ class TestBlob < Minitest::Test
|
||||
# Test fixtures
|
||||
assert sample_blob("test/fixtures/random.rkt").vendored?
|
||||
assert sample_blob("Test/fixtures/random.rkt").vendored?
|
||||
assert sample_blob("tests/fixtures/random.rkt").vendored?
|
||||
|
||||
# Cordova/PhoneGap
|
||||
assert sample_blob("cordova.js").vendored?
|
||||
@@ -439,6 +473,22 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob("activator.bat").vendored?
|
||||
assert sample_blob("subproject/activator").vendored?
|
||||
assert sample_blob("subproject/activator.bat").vendored?
|
||||
|
||||
assert_predicate fixture_blob(".google_apis/bar.jar"), :vendored?
|
||||
assert_predicate fixture_blob("foo/.google_apis/bar.jar"), :vendored?
|
||||
|
||||
# Sphinx docs
|
||||
assert sample_blob("docs/_build/asset.doc").vendored?
|
||||
assert sample_blob("docs/theme/file.css").vendored?
|
||||
|
||||
# Vagrant
|
||||
assert sample_blob("puphpet/file.pp").vendored?
|
||||
|
||||
# Fabric.io
|
||||
assert sample_blob("Fabric.framework/Fabric.h").vendored?
|
||||
|
||||
# Crashlytics
|
||||
assert sample_blob("Crashlytics.framework/Crashlytics.h").vendored?
|
||||
end
|
||||
|
||||
def test_documentation
|
||||
@@ -448,13 +498,36 @@ class TestBlob < Minitest::Test
|
||||
refute_predicate fixture_blob("project/docs/foo.html"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("Documentation/foo.md"), :documentation?
|
||||
refute_predicate fixture_blob("project/Documentation/foo.md"), :documentation?
|
||||
assert_predicate fixture_blob("documentation/foo.md"), :documentation?
|
||||
assert_predicate fixture_blob("project/Documentation/foo.md"), :documentation?
|
||||
assert_predicate fixture_blob("project/documentation/foo.md"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("javadoc/foo.html"), :documentation?
|
||||
assert_predicate fixture_blob("project/javadoc/foo.html"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("man/foo.html"), :documentation?
|
||||
refute_predicate fixture_blob("project/man/foo.html"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("README"), :documentation?
|
||||
assert_predicate fixture_blob("README.md"), :documentation?
|
||||
assert_predicate fixture_blob("README.txt"), :documentation?
|
||||
assert_predicate fixture_blob("foo/README"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("CHANGE"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGE.md"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGE.txt"), :documentation?
|
||||
assert_predicate fixture_blob("foo/CHANGE"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("CHANGELOG"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGELOG.md"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGELOG.txt"), :documentation?
|
||||
assert_predicate fixture_blob("foo/CHANGELOG"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("CHANGES"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGES.md"), :documentation?
|
||||
assert_predicate fixture_blob("CHANGES.txt"), :documentation?
|
||||
assert_predicate fixture_blob("foo/CHANGES"), :documentation?
|
||||
|
||||
assert_predicate fixture_blob("CONTRIBUTING"), :documentation?
|
||||
assert_predicate fixture_blob("CONTRIBUTING.md"), :documentation?
|
||||
assert_predicate fixture_blob("CONTRIBUTING.txt"), :documentation?
|
||||
@@ -502,6 +575,8 @@ class TestBlob < Minitest::Test
|
||||
blob = fixture_blob(filepath)
|
||||
if language == 'Data'
|
||||
assert blob.language.nil?, "A language was found for #{filepath}"
|
||||
elsif language == 'Generated'
|
||||
assert blob.generated?, "#{filepath} is not a generated file"
|
||||
else
|
||||
assert blob.language, "No language for #{filepath}"
|
||||
assert_equal language, blob.language.name, blob.name
|
||||
|
||||
23
test/test_color_proximity.rb
Normal file
23
test/test_color_proximity.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require_relative "./helper"
|
||||
|
||||
class TestColorProximity < Minitest::Test
|
||||
include Linguist
|
||||
|
||||
def cut_hash(color)
|
||||
color[1..-1] if color.start_with?('#')
|
||||
end
|
||||
|
||||
def test_color_proximity
|
||||
langs_with_colors = Language.all.reject { |language| language.color.nil? }
|
||||
cp = ColorProximity.new(0.05, langs_with_colors.map { |lang| cut_hash(lang.color) })
|
||||
failing_threshold = langs_with_colors.map do |lang|
|
||||
state = cp.past_threshold?(cut_hash(lang.color))
|
||||
if !state.first && lang.color != "##{state.last.first}"
|
||||
"- #{lang} (#{lang.color}) is too close to #{state.last}"
|
||||
end
|
||||
end.compact
|
||||
message = "The following #{failing_threshold.length} languages have failing color thresholds. Please modify the hex color.\n#{failing_threshold.join("\n")}"
|
||||
|
||||
assert failing_threshold.empty?, message
|
||||
end
|
||||
end
|
||||
@@ -5,47 +5,69 @@ class TestGenerated < Minitest::Test
|
||||
|
||||
class DataLoadedError < StandardError; end
|
||||
|
||||
def generated_without_loading_data(name)
|
||||
blob = File.join(samples_path, name)
|
||||
def generated_without_loading_data(blob)
|
||||
begin
|
||||
assert Generated.generated?(blob, lambda { raise DataLoadedError.new }), "#{name} was not recognized as a generated file"
|
||||
assert Generated.generated?(blob, lambda { raise DataLoadedError.new }), "#{blob} was not recognized as a generated file"
|
||||
rescue DataLoadedError
|
||||
assert false, "Data was loaded when calling generated? on #{name}"
|
||||
assert false, "Data was loaded when calling generated? on #{blob}"
|
||||
end
|
||||
end
|
||||
|
||||
def generated_loading_data(name)
|
||||
blob = File.join(samples_path, name)
|
||||
assert_raises(DataLoadedError, "Data wasn't loaded when calling generated? on #{name}") do
|
||||
def generated_loading_data(blob)
|
||||
assert_raises(DataLoadedError, "Data wasn't loaded when calling generated? on #{blob}") do
|
||||
Generated.generated?(blob, lambda { raise DataLoadedError.new })
|
||||
end
|
||||
end
|
||||
|
||||
def test_check_generated_without_loading_data
|
||||
def generated_fixture_without_loading_data(name)
|
||||
generated_without_loading_data(File.join(fixtures_path, name))
|
||||
end
|
||||
|
||||
def generated_fixture_loading_data(name)
|
||||
generated_loading_data(File.join(fixtures_path, name))
|
||||
end
|
||||
|
||||
def generated_sample_without_loading_data(name)
|
||||
generated_without_loading_data(File.join(samples_path, name))
|
||||
end
|
||||
|
||||
def generated_sample_loading_data(name)
|
||||
generated_loading_data(File.join(samples_path, name))
|
||||
end
|
||||
|
||||
def test_check_generated
|
||||
# Xcode project files
|
||||
generated_without_loading_data("Binary/MainMenu.nib")
|
||||
generated_without_loading_data("Dummy/foo.xcworkspacedata")
|
||||
generated_without_loading_data("Dummy/foo.xcuserstate")
|
||||
generated_sample_without_loading_data("Binary/MainMenu.nib")
|
||||
generated_sample_without_loading_data("Dummy/foo.xcworkspacedata")
|
||||
generated_sample_without_loading_data("Dummy/foo.xcuserstate")
|
||||
|
||||
# .NET designer file
|
||||
generated_without_loading_data("Dummu/foo.designer.cs")
|
||||
generated_sample_without_loading_data("Dummu/foo.designer.cs")
|
||||
|
||||
# Composer generated composer.lock file
|
||||
generated_without_loading_data("JSON/composer.lock")
|
||||
generated_sample_without_loading_data("JSON/composer.lock")
|
||||
|
||||
# Node modules
|
||||
generated_without_loading_data("Dummy/node_modules/foo.js")
|
||||
generated_sample_without_loading_data("Dummy/node_modules/foo.js")
|
||||
|
||||
# Godep saved dependencies
|
||||
generated_without_loading_data("Godeps/Godeps.json")
|
||||
generated_without_loading_data("Godeps/_workspace/src/github.com/kr/s3/sign.go")
|
||||
generated_sample_without_loading_data("Godeps/Godeps.json")
|
||||
generated_sample_without_loading_data("Godeps/_workspace/src/github.com/kr/s3/sign.go")
|
||||
|
||||
# Generated by Zephir
|
||||
generated_without_loading_data("C/exception.zep.c")
|
||||
generated_without_loading_data("C/exception.zep.h")
|
||||
generated_without_loading_data("PHP/exception.zep.php")
|
||||
generated_sample_without_loading_data("C/exception.zep.c")
|
||||
generated_sample_without_loading_data("C/exception.zep.h")
|
||||
generated_sample_without_loading_data("PHP/exception.zep.php")
|
||||
|
||||
# Minified files
|
||||
generated_loading_data("JavaScript/jquery-1.6.1.min.js")
|
||||
generated_sample_loading_data("JavaScript/jquery-1.6.1.min.js")
|
||||
|
||||
# Source Map
|
||||
generated_fixture_without_loading_data("Data/bootstrap.css.map")
|
||||
generated_fixture_loading_data("Data/sourcemap.v3.map")
|
||||
generated_fixture_loading_data("Data/sourcemap.v1.map")
|
||||
|
||||
# Specflow
|
||||
generated_fixture_without_loading_data("Features/BindingCulture.feature.cs")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,8 +13,7 @@ class TestGrammars < Minitest::Test
|
||||
# These grammars have no license but have been grandfathered in. New grammars
|
||||
# must have a license that allows redistribution.
|
||||
"vendor/grammars/Sublime-Lasso",
|
||||
"vendor/grammars/Sublime-REBOL",
|
||||
"vendor/grammars/x86-assembly-textmate-bundle",
|
||||
"vendor/grammars/x86-assembly-textmate-bundle"
|
||||
].freeze
|
||||
|
||||
def setup
|
||||
|
||||
@@ -22,6 +22,17 @@ class TestHeuristcs < Minitest::Test
|
||||
assert_equal [], results
|
||||
end
|
||||
|
||||
def assert_heuristics(hash)
|
||||
candidates = hash.keys.map { |l| Language[l] }
|
||||
|
||||
hash.each do |language, blobs|
|
||||
Array(blobs).each do |blob|
|
||||
result = Heuristics.call(file_blob(blob), candidates)
|
||||
assert_equal [Language[language]], result, "Failed for #{blob}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Candidate languages = ["C++", "Objective-C"]
|
||||
def test_obj_c_by_heuristics
|
||||
# Only calling out '.h' filenames as these are the ones causing issues
|
||||
@@ -47,8 +58,9 @@ class TestHeuristcs < Minitest::Test
|
||||
# Candidate languages = ["Perl", "Prolog"]
|
||||
def test_pl_prolog_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Prolog" => "Prolog/turing.pl",
|
||||
"Perl" => ["Perl/perl-test.t", "Perl/use5.pl"]
|
||||
"Prolog" => all_fixtures("Prolog/*.pl"),
|
||||
"Perl" => all_fixtures("Perl/*.pl") + ["Perl/perl-test.t"],
|
||||
"Perl6" => all_fixtures("Perl6/*.pl")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -60,11 +72,13 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["IDL", "Prolog"]
|
||||
def test_pro_prolog_idl_by_heuristics
|
||||
# Candidate languages = ["IDL", "Prolog", "QMake", "INI"]
|
||||
def test_pro_by_heuristics
|
||||
assert_heuristics({
|
||||
"Prolog" => "Prolog/logic-problem.pro",
|
||||
"IDL" => "IDL/mg_acosh.pro"
|
||||
"Prolog" => all_fixtures("Prolog", "*.pro"),
|
||||
"IDL" => all_fixtures("IDL", "*.pro"),
|
||||
"INI" => all_fixtures("INI", "*.pro"),
|
||||
"QMake" => all_fixtures("QMake", "*.pro")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -73,7 +87,7 @@ class TestHeuristcs < Minitest::Test
|
||||
assert_heuristics({
|
||||
"AsciiDoc" => "AsciiDoc/list.asc",
|
||||
"AGS Script" => "AGS Script/GlobalScript.asc",
|
||||
"Public Key" => "Public Key/sunCert.asc"
|
||||
"Public Key" => all_fixtures("Public Key", "*.asc")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -119,7 +133,7 @@ class TestHeuristcs < Minitest::Test
|
||||
assert_heuristics({
|
||||
"Frege" => all_fixtures("Frege"),
|
||||
"Forth" => all_fixtures("Forth"),
|
||||
"Text" => all_fixtures("Text")
|
||||
"Text" => all_fixtures("Text", "*.fr")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -144,17 +158,6 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
def assert_heuristics(hash)
|
||||
candidates = hash.keys.map { |l| Language[l] }
|
||||
|
||||
hash.each do |language, blobs|
|
||||
Array(blobs).each do |blob|
|
||||
result = Heuristics.call(file_blob(blob), candidates)
|
||||
assert_equal [Language[language]], result, "Failed for #{blob}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_ls_by_heuristics
|
||||
assert_heuristics({
|
||||
"LiveScript" => "LiveScript/hello.ls",
|
||||
@@ -168,4 +171,10 @@ class TestHeuristcs < Minitest::Test
|
||||
"XML" => all_fixtures("XML", "*.ts")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ch_by_heuristics
|
||||
assert_heuristics({
|
||||
"xBase" => all_fixtures("xBase")
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
50
test/test_instrumentation.rb
Normal file
50
test/test_instrumentation.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
require_relative "./helper"
|
||||
|
||||
class TestInstrumentation < Minitest::Test
|
||||
include Linguist
|
||||
|
||||
class LocalInstrumenter
|
||||
Event = Struct.new(:name, :args)
|
||||
|
||||
attr_reader :events
|
||||
|
||||
def initialize
|
||||
@events = []
|
||||
end
|
||||
|
||||
def instrument(name, *args)
|
||||
@events << Event.new(name, args)
|
||||
yield if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
Linguist.instrumenter = LocalInstrumenter.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
Linguist.instrumenter = nil
|
||||
end
|
||||
|
||||
def test_detection_instrumentation_with_binary_blob
|
||||
binary_blob = fixture_blob("Binary/octocat.ai")
|
||||
Language.detect(binary_blob)
|
||||
|
||||
# Shouldn't instrument this (as it's binary)
|
||||
assert_equal 0, Linguist.instrumenter.events.size
|
||||
end
|
||||
|
||||
def test_modeline_instrumentation
|
||||
blob = fixture_blob("Data/Modelines/ruby")
|
||||
Language.detect(blob)
|
||||
|
||||
detect_event = Linguist.instrumenter.events.last
|
||||
detect_event_payload = detect_event[:args].first
|
||||
|
||||
assert_equal 3, Linguist.instrumenter.events.size
|
||||
assert_equal "linguist.detected", detect_event.name
|
||||
assert_equal Language['Ruby'], detect_event_payload[:language]
|
||||
assert_equal blob, detect_event_payload[:blob]
|
||||
assert_equal Linguist::Strategy::Modeline, detect_event_payload[:strategy]
|
||||
end
|
||||
end
|
||||
@@ -79,7 +79,6 @@ class TestLanguage < Minitest::Test
|
||||
assert_equal Language['Java'], Language['Java Server Pages'].group
|
||||
assert_equal Language['Python'], Language['Cython'].group
|
||||
assert_equal Language['Python'], Language['NumPy'].group
|
||||
assert_equal Language['Shell'], Language['Batchfile'].group
|
||||
assert_equal Language['Shell'], Language['Gentoo Ebuild'].group
|
||||
assert_equal Language['Shell'], Language['Gentoo Eclass'].group
|
||||
assert_equal Language['Shell'], Language['Tcsh'].group
|
||||
@@ -155,10 +154,6 @@ class TestLanguage < Minitest::Test
|
||||
assert_equal :prose, Language['Org'].type
|
||||
end
|
||||
|
||||
def test_other
|
||||
assert_nil Language['Brainfuck'].type
|
||||
end
|
||||
|
||||
def test_searchable
|
||||
assert Language['Ruby'].searchable?
|
||||
assert !Language['Gettext Catalog'].searchable?
|
||||
@@ -192,7 +187,7 @@ class TestLanguage < Minitest::Test
|
||||
assert_equal [], Language.find_by_extension('foo.rb')
|
||||
assert_equal [Language['Ruby']], Language.find_by_extension('rb')
|
||||
assert_equal [Language['Ruby']], Language.find_by_extension('.rb')
|
||||
assert_equal [Language['M'], Language['Mathematica'], Language['Matlab'], Language['Mercury'], Language['Objective-C']], Language.find_by_extension('.m')
|
||||
assert_equal [Language['Limbo'], Language['M'], Language['MUF'], Language['Mathematica'], Language['Matlab'], Language['Mercury'], Language['Objective-C']], Language.find_by_extension('.m')
|
||||
end
|
||||
|
||||
def test_find_all_by_extension
|
||||
@@ -290,9 +285,9 @@ class TestLanguage < Minitest::Test
|
||||
|
||||
def test_color
|
||||
assert_equal '#701516', Language['Ruby'].color
|
||||
assert_equal '#3581ba', Language['Python'].color
|
||||
assert_equal '#3572A5', Language['Python'].color
|
||||
assert_equal '#f1e05a', Language['JavaScript'].color
|
||||
assert_equal '#31859c', Language['TypeScript'].color
|
||||
assert_equal '#2b7489', Language['TypeScript'].color
|
||||
assert_equal '#3d9970', Language['LSL'].color
|
||||
end
|
||||
|
||||
@@ -358,6 +353,15 @@ class TestLanguage < Minitest::Test
|
||||
assert missing.empty?, message
|
||||
end
|
||||
|
||||
def test_all_languages_have_type
|
||||
missing = Language.all.select { |language| language.type.nil? }
|
||||
message = "The following languages do not have a type listed in grammars.yml. Please add types for all new languages.\n"
|
||||
|
||||
width = missing.map { |language| language.name.length }.max
|
||||
message << missing.map { |language| sprintf("%-#{width}s", language.name) }.sort.join("\n")
|
||||
assert missing.empty?, message
|
||||
end
|
||||
|
||||
def test_all_languages_have_a_valid_ace_mode
|
||||
ace_fixture_path = File.join('test', 'fixtures', 'ace_modes.json')
|
||||
skip("No ace_modes.json file") unless File.exist?(ace_fixture_path)
|
||||
|
||||
@@ -10,6 +10,16 @@ class TestModelines < Minitest::Test
|
||||
def test_modeline_strategy
|
||||
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplus")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs3")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs4")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs5")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs6")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8")
|
||||
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9")
|
||||
assert_modeline Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c")
|
||||
assert_modeline Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl")
|
||||
assert_modeline Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md")
|
||||
assert_modeline Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc")
|
||||
@@ -18,6 +28,16 @@ class TestModelines < Minitest::Test
|
||||
def test_modeline_languages
|
||||
assert_equal Language["Ruby"], fixture_blob("Data/Modelines/ruby").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplus").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs3").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs4").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs5").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs6").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8").language
|
||||
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9").language
|
||||
assert_equal Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c").language
|
||||
assert_equal Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl").language
|
||||
assert_equal Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md").language
|
||||
assert_equal Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc").language
|
||||
|
||||
@@ -12,7 +12,7 @@ class TestPedantic < Minitest::Test
|
||||
def test_extensions_are_sorted
|
||||
LANGUAGES.each do |name, language|
|
||||
extensions = language['extensions']
|
||||
assert_sorted extensions[1..-1] if extensions && extensions.size > 1
|
||||
assert_sorted extensions[1..-1].map(&:downcase) if extensions && extensions.size > 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,6 +34,14 @@ class TestSamples < Minitest::Test
|
||||
assert !data["interpreters"].empty?
|
||||
end
|
||||
|
||||
def test_ext_or_shebang
|
||||
Samples.each do |sample|
|
||||
if sample[:extname].to_s.empty? && !sample[:filename]
|
||||
assert sample[:interpreter], "#{sample[:path]} should have a file extension or a shebang, maybe it belongs in filenames/ subdir"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Check that there aren't samples with extensions or interpreters that
|
||||
# aren't explicitly defined in languages.yml
|
||||
languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
|
||||
@@ -42,16 +50,15 @@ class TestSamples < Minitest::Test
|
||||
options['extensions'] ||= []
|
||||
if extnames = Samples.cache['extnames'][name]
|
||||
extnames.each do |extname|
|
||||
next if extname == '.script!'
|
||||
assert options['extensions'].index { |x| x.end_with? extname }, "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
|
||||
assert options['extensions'].index { |x| x.downcase.end_with? extname.downcase }, "#{name} has a sample with extension (#{extname.downcase}) that isn't explicitly defined in languages.yml"
|
||||
end
|
||||
end
|
||||
|
||||
options['interpreters'] ||= []
|
||||
if interpreters = Samples.cache['interpreters'][name]
|
||||
interpreters.each do |interpreter|
|
||||
# next if extname == '.script!'
|
||||
assert options['interpreters'].include?(interpreter), "#{name} has a sample with an interpreter (#{interpreter}) that isn't explicitly defined in languages.yml"
|
||||
assert options['interpreters'].include?(interpreter),
|
||||
"#{name} has a sample with an interpreter (#{interpreter}) that isn't explicitly defined in languages.yml"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,7 +74,7 @@ class TestSamples < Minitest::Test
|
||||
if language_matches.length > 1
|
||||
language_matches.each do |match|
|
||||
samples = "samples/#{match.name}/*#{extension}"
|
||||
assert Dir.glob(samples).any?, "Missing samples in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
|
||||
assert Dir.glob(samples, File::FNM_CASEFOLD).any?, "Missing samples in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,7 @@ class TestShebang < Minitest::Test
|
||||
assert_interpreter "perl", "#! perl"
|
||||
|
||||
assert_interpreter "ruby", "#!/bin/sh\n\n\nexec ruby $0 $@"
|
||||
end
|
||||
|
||||
assert_interpreter "sh", "#! /usr/bin/env A=003 B=149 C=150 D=xzd E=base64 F=tar G=gz H=head I=tail sh"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,6 +35,8 @@ class TestTokenizer < Minitest::Test
|
||||
assert_equal %w(foo), tokenize("foo\n# Comment")
|
||||
assert_equal %w(foo bar), tokenize("foo\n# Comment\nbar")
|
||||
assert_equal %w(foo), tokenize("foo\n// Comment")
|
||||
assert_equal %w(foo), tokenize("foo\n-- Comment")
|
||||
assert_equal %w(foo), tokenize("foo\n\" Comment")
|
||||
assert_equal %w(foo), tokenize("foo /* Comment */")
|
||||
assert_equal %w(foo), tokenize("foo /* \nComment\n */")
|
||||
assert_equal %w(foo), tokenize("foo <!-- Comment -->")
|
||||
@@ -86,16 +88,16 @@ class TestTokenizer < Minitest::Test
|
||||
end
|
||||
|
||||
def test_shebang
|
||||
assert_equal "SHEBANG#!sh", tokenize(:"Shell/sh.script!")[0]
|
||||
assert_equal "SHEBANG#!bash", tokenize(:"Shell/bash.script!")[0]
|
||||
assert_equal "SHEBANG#!zsh", tokenize(:"Shell/zsh.script!")[0]
|
||||
assert_equal "SHEBANG#!perl", tokenize(:"Perl/perl.script!")[0]
|
||||
assert_equal "SHEBANG#!python", tokenize(:"Python/python.script!")[0]
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby.script!")[0]
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby2.script!")[0]
|
||||
assert_equal "SHEBANG#!node", tokenize(:"JavaScript/js.script!")[0]
|
||||
assert_equal "SHEBANG#!php", tokenize(:"PHP/php.script!")[0]
|
||||
assert_equal "SHEBANG#!escript", tokenize(:"Erlang/factorial.script!")[0]
|
||||
assert_equal "SHEBANG#!sh", tokenize(:"Shell/sh")[0]
|
||||
assert_equal "SHEBANG#!bash", tokenize(:"Shell/bash")[0]
|
||||
assert_equal "SHEBANG#!zsh", tokenize(:"Shell/zsh")[0]
|
||||
assert_equal "SHEBANG#!perl", tokenize(:"Perl/perl")[0]
|
||||
assert_equal "SHEBANG#!python", tokenize(:"Python/python")[0]
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby")[0]
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby2")[0]
|
||||
assert_equal "SHEBANG#!node", tokenize(:"JavaScript/js")[0]
|
||||
assert_equal "SHEBANG#!php", tokenize(:"PHP/php")[0]
|
||||
assert_equal "SHEBANG#!escript", tokenize(:"Erlang/factorial")[0]
|
||||
assert_equal "echo", tokenize(:"Shell/invalid-shebang.sh")[0]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user