App-NDTools

 view release on metacpan or  search on metacpan

t/bin/ndquery.t  view on Meta::CPAN

    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "md5";
run_ok(
    name => $test,
    cmd => [ @cmd, '--md5', "_menu.a.json", "_menu.b.json", "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "md5_path";
run_ok(
    name => $test,
    cmd => [ @cmd, '--md5', '--path', '[0]{File}[0]{label}', "_menu.a.json", "_menu.b.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "md5_stdin";
run_ok(
    name => $test,
    cmd => [ "$^X $bin --md5 --path [0]{File}[0]{label} < _menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "nopretty";
run_ok(
    name => $test,
    cmd => [ @cmd, '--nopretty', "_cfg.alpha.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "path_0";
run_ok(
    name => $test,
    cmd => [ @cmd, '--path', '{files}{"/etc/hosts"}', "_cfg.alpha.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "path_1";
run_ok(
    name => $test,
    cmd => [ @cmd, '--path', '[]', "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "path_2";
run_ok(
    name => $test,
    cmd => [ @cmd, '--path', '[1]{Edit}[]{id}(eq "edit_paste")(back)', "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "path_3";
run_ok(
    name => $test,
    cmd => [ @cmd, '--path', '[1]{Edit}[](not defined)', "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

SKIP: {
    skip "non utf8 locale", 1 unless (exists $ENV{LC_ALL} and $ENV{LC_ALL} =~ /UTF-8/);

    $test = "path_utf8";
    run_ok(
        name => $test,
        cmd => [ @cmd, '--path', '{"текст"}', "_text-utf8.a.json" ],
        stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test, { encoding => 'UTF-8' }) },
    );
}

$test = "ofmt_yaml";
run_ok(
    name => $test,
    cmd => [ @cmd, '--ofmt', 'yaml', "_cfg.alpha.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "ofmt_yaml_bool";
run_ok(
    name => $test,
    cmd => [ @cmd, '--ofmt', 'yaml', "_bool.a.json" ],
    stdout => sub { file_contents_eq_or_diff(
        (eval { YAML::XS->VERSION(0.67) } ? "$test.exp" : "$test.num.exp"), shift, $test
    )},
);

$test = "ofmt_yaml_bool_nonref_false";
run_ok(
    name => $test,
    cmd => [ @cmd, '--ofmt', 'yaml', "$test.json" ],
    stdout => sub { file_contents_eq_or_diff(
        (eval { YAML::XS->VERSION(0.67) } ? "$test.exp" : "$test.num.exp"), shift, $test
    )},
);

$test = "ofmt_yaml_bool_nonref_true";
run_ok(
    name => $test,
    cmd => [ @cmd, '--ofmt', 'yaml', "$test.json" ],
    stdout => sub { file_contents_eq_or_diff(
        (eval { YAML::XS->VERSION(0.67) } ? "$test.exp" : "$test.num.exp"), shift, $test
    )},
);

$test = "raw_output_object";
run_ok(
    name => $test,
    cmd => [ @cmd, '--raw-output', '--path', '[0]{File}[1]', "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "raw_output_string";
run_ok(
    name => $test,
    cmd => [ @cmd, '--raw-output', '--path', '[0]{File}[1]{label}', "_menu.a.json" ],
    stdout => sub { file_contents_eq_or_diff("$test.exp", shift, $test) },
);

$test = "replace_list";
run_ok(
    name => $test,



( run in 0.949 second using v1.01-cache-2.11-cpan-ceb78f64989 )