Skip to content

Commit

Permalink
call the library JSON for now, even though that will not last
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Aug 27, 2010
1 parent b66fcf3 commit 5fcae29
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test.html
Expand Up @@ -3,20 +3,20 @@
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Repeatable JSON Serialization Test</title>
<script src="cjson.js"></script>
<script src="c2j.js"></script>
<script type="text/javascript" charset="utf-8">
T = fireunit.ok;

// tests for repeatable serializations
var c = CJSON.stringify({foo : "bar"});
var c = JSON.stringify({foo : "bar"});
T(c == '{"foo":"bar"}', "basic");

var obj = {
"foo" : "bar",
"baz" : "bam",
"zam" : "zing"
};
c = CJSON.stringify(obj);
c = JSON.stringify(obj);
T(c == '{"baz":"bam","foo":"bar","zam":"zing"}',
"sorted by key");

Expand All @@ -29,19 +29,19 @@
},
"zam" : "zing"
};
var c = CJSON.stringify(obj);
var c = JSON.stringify(obj);
T(c == '{"baz":{"abba":1,"fabba":2,"zabba":3},"foo":"bar","zam":"zing"}',
"sorted recursively");

CJSON.floatPrecision = 2;
JSON.floatPrecision = 2;
var obj = {
tiny : (1/99999999999999999999999999),
third : (1/3),
sixes : (2/3),
integer : 5,
dec : 4.1
};
var c = CJSON.stringify(obj);
var c = JSON.stringify(obj);

T(c == '{"dec":4.1,"integer":5,"sixes":0.67,"third":0.33,"tiny":0}',
"floats are rounded by precision");
Expand Down

0 comments on commit 5fcae29

Please sign in to comment.