quickdraw/compilation_equivalence_cases/fused_enclosures.rb

Lines

95%

22 of 23 covered

Branches

100%

4 of 4 covered

Methods

75%

3 of 4 covered

Not run
6
Never called
1# frozen_string_literal: true
2
31module EquivalenceCases
41 module FusedEnclosures
51 class Loud < String
60 def to_str = raise("loud")
7 end
8
91 class FusedEnclosures < Phlex::HTML
101 register_element :snow, tag: "雪"
11
12 VALUES = [
131 "plain <b>",
14 :a_symbol,
15 1,
16 nil,
17 Object.new,
18 Loud.new("loud"),
19 "safe".dup.extend(Phlex::SGML::SafeObject),
20 Phlex::SGML::SafeValue.new("<i>"),
21 "é".encode(Encoding::ISO_8859_1),
22 "x".encode(Encoding::UTF_16LE),
23 ].freeze
24
251 def self.equivalence_scenarios
262 VALUES.each_with_index.to_h do |value, index|
2740 ["value #{index}", -> (klass) { klass.new(value).call }]
28 end.merge(
292 "after binary" => -> (klass) { klass.new("é", binary: true).call },
302 "fragment" => -> (klass) { klass.new("x").call(fragments: [:f]) },
31 )
32 end
33
341 def initialize(value, binary: false)
3524 @value = value
3624 @binary = binary
37 end
38
391 def view_template
4012 raw safe("\xFF".b) if @binary
4158 div(class: "card") { div(class: "header") { h3 { @value } }; p { "after" } }
4238 section { snow { span { @value } } }
4336 catch(:out) { div { article { throw :out } } }
4472 ul { [1, 2].each { |i| li { em { break if i == 2 } } } }
4536 fragment(:f) { aside { nav { @value } } }
46 rescue => error
473 plain "rescued #{error.class}"
48 end
49 end
50 end
51end