File:  [parser3project] / parser3 / tests / 407.html
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Jan 13 22:22:09 2021 UTC (5 years, 4 months ago) by moko
Branches: MAIN
CVS tags: release_3_5_1, release_3_5_0, release_3_4_6, HEAD
test for ^hash.select option $.default(bool) added (related to feature #1172)

# based on ^table:select[] test in 262.html

$log[^table::create{cpu	url
0.2200	/novosibirsk/retail/
0.1600	/nizhninovgorod/
0.0200	/_/rss/_rss.html
0.2233	/retail/credit/.../
0.0000	/_goto.html
0.1500	/sme/accounts/software/
0.1700	/ufa/
0.0100	/address/
0.1367	/omsk/atm/omsk/.../
0.1833	/sochi/retail/cards/.../
0.0033	/
0.1533	/corporate/loans/
0.0100	/retail/
0.0033	/peterburg/
0.1533	/perm/
}]

$log[^log.hash[url;cpu; $.type[string] ]]

Hit:
$hit[^log.select[;cpu]($cpu<0.05)]
^hit.foreach[url;]{$url}[^#0A]

Limit:
$hit[^log.select[;cpu]($cpu<0.05)[ $.limit(2) ]]
^hit.foreach[url;]{$url}[^#0A]

$hit[^log.select[;cpu]($cpu<0.05)[ $.limit(-1) ]]
^hit.foreach[url;]{$url}[^#0A]

Short:
$short[^log.select[url;](^url.length[]<7)]
^short.foreach[url;]{$url}[^#0A]

Reverse test:
$h[^hash::create[$log] $._default[-]]
default before: "$h.404"
$h[^h.reverse[]]
default after: "$h.404"
^json:string[$h]

$h[^h.select[;](true)[ $.default(true) $.limit(1) ]]
^json:string[$h]
default after select: "$h.404"
$h[^h.select[;](true)]
^json:string[$h]
default after another select: "$h.404"

Hit:
$hit[^log.select[;cpu]($cpu<0.05)[ $.reverse(true) ]]
^hit.foreach[url;]{$url}[^#0A]

Limit:
$hit[^log.select[;cpu]($cpu<0.05)[ $.limit(2) $.reverse(true) ]]
^hit.foreach[url;]{$url}[^#0A]

Short:
$short[^log.select[url;](^url.length[]<7)[ $.reverse(true) ]]
^short.foreach[url;]{$url}[^#0A]

E-mail: