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
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
{ 
    "description": "Javascript Code with Scope", 
    "bson_type": "0x0F", 
    "test_key": "a", 
    "valid": [ 
        { 
            "description": "Empty code string, empty scope", 
            "canonical_bson": "160000000F61000E0000000100000000050000000000", 
            "canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}" 
        }, 
        { 
            "description": "Non-empty code string, empty scope", 
            "canonical_bson": "1A0000000F610012000000050000006162636400050000000000", 
            "canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}" 
        }, 
        { 
            "description": "Empty code string, non-empty scope", 
            "canonical_bson": "1D0000000F61001500000001000000000C000000107800010000000000", 
            "canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}" 
        }, 
        { 
            "description": "Non-empty code string and non-empty scope", 
            "canonical_bson": "210000000F6100190000000500000061626364000C000000107800010000000000", 
            "canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}" 
        }, 
        { 
            "description": "Unicode and embedded null in code string, empty scope", 
            "canonical_bson": "1A0000000F61001200000005000000C3A9006400050000000000", 
            "canonical_extjson": "{\"a\" : {\"$code\" : \"é\\u0000d\", \"$scope\" : {}}}" 
        } 
    ], 
    "decodeErrors": [ 
        { 
            "description": "field length zero", 
            "bson": "280000000F6100000000000500000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "field length negative", 
            "bson": "280000000F6100FFFFFFFF0500000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "field length too short (less than minimum size)", 
            "bson": "160000000F61000D0000000100000000050000000000" 
        }, 
        { 
            "description": "field length too short (truncates scope)", 
            "bson": "280000000F61001F0000000500000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "field length too long (clips outer doc)", 
            "bson": "280000000F6100210000000500000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "field length too long (longer than outer doc)", 
            "bson": "280000000F6100FF0000000500000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "bad code string: length too short", 
            "bson": "280000000F6100200000000400000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "bad code string: length too long (clips scope)", 
            "bson": "280000000F6100200000000600000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "bad code string: negative length", 
            "bson": "280000000F610020000000FFFFFFFF61626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "bad code string: length longer than field", 
            "bson": "280000000F610020000000FF00000061626364001300000010780001000000107900010000000000" 
        }, 
        { 
            "description": "bad scope doc (field has bad string length)", 
            "bson": "1C0000000F001500000001000000000C000000020000000000000000" 
        } 
    ] 
}