File: json-singlequote.t

package info (click to toggle)
libyaml-syck-perl 1.20-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 932 kB
  • sloc: ansic: 3,987; perl: 3,387; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use t::TestYAML ();
use Test::More tests => 5;
use JSON::Syck;

{
    $JSON::Syck::SingleQuote = 1;

    my $dump;

    $dump = JSON::Syck::Dump(q{Some string});
    is($dump, q{'Some string'});

    #Test escaping
    my $thing = q{I'm sorry, Dave.};
    $dump = JSON::Syck::Dump($thing);
    is(JSON::Syck::Load($dump), $thing);
}

{
    $JSON::Syck::SingleQuote = 0;

    my $dump;

    $dump = JSON::Syck::Dump(q{Some string});
    is($dump, q{"Some string"});

    #Test escaping
    my $thing = q{I'm sorry, Dave.};
    $dump = JSON::Syck::Dump($thing);
    is(JSON::Syck::Load($dump), $thing);
}

{
    my $url = 'http://www.pugscode.org';
    my $var = JSON::Syck::Load(<<"_EOC_");
    { url: '$url' }
_EOC_

    is $var->{url}, $url, "no extra space in the URL";
}