@@ -139,13 +139,21 @@ defmodule Torque.PointerTest do
139139 assert { :ok , "ten" } = Torque . get ( doc , "/10" )
140140 end
141141
142- test "nested numeric string object key id reachable via JSON Pointer" do
142+ test "nested numeric string object key is reachable via JSON Pointer" do
143143 { :ok , doc } = Torque . parse ( ~s( {"k1":"v1","k2":{"10":"ten","n1":"nv1"}}) )
144144 assert { :ok , "v1" } = Torque . get ( doc , "/k1" )
145145 assert { :ok , % { "10" => "ten" , "n1" => "nv1" } } = Torque . get ( doc , "/k2" )
146146 assert { :ok , "ten" } = Torque . get ( doc , "/k2/10" )
147147 assert { :ok , "nv1" } = Torque . get ( doc , "/k2/n1" )
148148 end
149+
150+ test "numeric segment dispatches on node type" do
151+ { :ok , obj_doc } = Torque . parse ( ~s( {"0":"from-object"}) )
152+ { :ok , arr_doc } = Torque . parse ( ~s( ["from-array"]) )
153+
154+ assert { :ok , "from-object" } = Torque . get ( obj_doc , "/0" )
155+ assert { :ok , "from-array" } = Torque . get ( arr_doc , "/0" )
156+ end
149157 end
150158
151159 describe "get_many/2" do
@@ -164,6 +172,11 @@ defmodule Torque.PointerTest do
164172 assert [ ] = Torque . get_many ( doc , [ ] )
165173 end
166174
175+ test "numeric string object keys" do
176+ { :ok , doc } = Torque . parse ( ~s( {"1":"one","2":"two"}) )
177+ assert [ { :ok , "one" } , { :ok , "two" } ] = Torque . get_many ( doc , [ "/1" , "/2" ] )
178+ end
179+
167180 test "all fields" , % { doc: doc } do
168181 paths = [
169182 "/id" ,
0 commit comments