Sha256: a7f1fdb9b74dc41f9022f11cdc69df2336c54fb335311fed3cc1fdd0bbbf67bc

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require "spec_helper"

RSpec.describe Code::Parser::Dictionnary do
  subject { described_class.new.parse(input) }

  [
    [
      '{name: "Dorian"}',
      {
        dictionnary: [{ key: { name: "name" }, value: [{ string: "Dorian" }] }]
      }
    ],
    [
      '{a: true, "b": false}',
      {
        dictionnary: [
          { key: { name: "a" }, value: [{ boolean: "true" }] },
          { key: { string: "b" }, value: [{ boolean: "false" }] }
        ]
      }
    ],
    [
      "{ true => 1, false => 2}",
      {
        dictionnary: [
          {
            key: [{ boolean: "true" }],
            value: [{ number: { base_10: { integer: { whole: "1" } } } }]
          },
          {
            key: [{ boolean: "false" }],
            value: [{ number: { base_10: { integer: { whole: "2" } } } }]
          }
        ]
      }
    ]
  ].each do |(input, expected)|
    context input.inspect do
      let(:input) { input }

      it "succeeds" do
        expect(subject).to eq(expected)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
template-ruby-0.1.0 spec/code/parser/dictionnary_spec.rb