Skip to content

Commit

Permalink
feat(test) create extra YAML test check key is not number
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezzzhak committed Feb 25, 2021
1 parent bb34ebd commit 6427865
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
37 changes: 37 additions & 0 deletions Tests/DeviceDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,43 @@ public function testCheckRegexRestrictionEndCondition(): void
$this->assertTrue($this->checkRegexRestrictionEndCondition('TestValue(?:[;)/]|$)'), 'pass condition');
}

public function testCheckYamlExtraLint(): void
{
$files = \array_merge(
\glob(__DIR__ . '/../regexes/client/*.yml'),
\glob(__DIR__ . '/../regexes/device/*.yml')
);

foreach ($files as $file) {
$fn = \fopen($file, 'r');
$n = 0;

while (!\feof($fn)) {
$line = \fgets($fn);

if (false === $line) {
break;
}

if (\preg_match('~^\s+[0-9\.]+:~si', $line)) {
$message = \sprintf(
"Key is number format, need wrap key in string. Example \"'number': 'value'\"\n" .
"File: %s\nLine: %s\nString: %s",
$file,
$n,
$line
);

throw new \Exception($message);
}

$n++;
}

\fclose($fn);
}
}

/**
* check the regular expression for the vertical line closing the group
* @param string $regexString
Expand Down
12 changes: 6 additions & 6 deletions regexes/client/browsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@
engine:
default: 'WebKit'
versions:
28: 'Blink'
'28': 'Blink'

#Atomic Web Browser
- regex: 'AtomicBrowser(?:/(\d+[\.\d]+))?'
Expand Down Expand Up @@ -908,7 +908,7 @@
engine:
default: 'Gecko'
versions:
3: 'WebKit'
'3': 'WebKit'

# Jig Browser Plus (https://jig.jp/)
- regex: 'JigBrowserPlus/(?:(\d+[\.\d]+))?'
Expand Down Expand Up @@ -1199,8 +1199,8 @@
default: ''
versions:
'3.5': 'Elektra'
7: 'Presto'
15: 'Blink'
'7': 'Presto'
'15': 'Blink'

#Rekonq
- regex: 'rekonq(?:/(\d+[\.\d]+))?'
Expand All @@ -1223,7 +1223,7 @@
engine:
default: 'WebKit'
versions:
28: 'Blink'
'28': 'Blink'

#ChromePlus
- regex: 'ChromePlus(?:/(\d+[\.\d]+))?'
Expand Down Expand Up @@ -1407,7 +1407,7 @@
# This browser (http://coccoc.vn/) is built on top of Chromium with
# additional features for Vietnamese users. Its regex has to be placed
# before generic Chrome regex, or Chrome regex will match first and
# the browser is mistaken as "Chrome".
# the browser is mistaken as 'Chrome".
- regex: '(?:coc_coc_browser|coccocbrowser|CocCoc)(?:/(\d+[\.\d]+))?'
name: 'Coc Coc'
version: '$1'
Expand Down

0 comments on commit 6427865

Please sign in to comment.