File: test_set.rb

package info (click to toggle)
ruby-psych 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 864 kB
  • sloc: ruby: 7,947; ansic: 925; java: 846; makefile: 14; sh: 4
file content (36 lines) | stat: -rw-r--r-- 718 bytes parent folder | download
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
# encoding: UTF-8
# frozen_string_literal: true
require_relative 'helper'
require 'set' unless defined?(Set)

module Psych
  class TestSet < TestCase
    def setup
      @set = ::Set.new([1, 2, 3])
    end

    def test_dump
      assert_equal <<~YAML, Psych.dump(@set)
        --- !ruby/object:Set
        hash:
          1: true
          2: true
          3: true
      YAML
    end

    def test_load
      assert_equal @set, Psych.load(<<~YAML, permitted_classes: [::Set])
        --- !ruby/object:Set
        hash:
          1: true
          2: true
          3: true
      YAML
    end

    def test_roundtrip
      assert_equal @set, Psych.load(Psych.dump(@set), permitted_classes: [::Set])
    end
  end
end