quickdraw/compilation_equivalence_cases/conditional_values.rb

Lines

0%

0 of 56 covered

Branches

0%

0 of 78 covered

Methods

0%

0 of 6 covered

Not run
3-68-913-1518-3739-525457-5962-6568-707375
Never called
1# frozen_string_literal: true
2
30module EquivalenceCases
40 module ConditionalValues
50 class ConditionalValues < Phlex::HTML
60 def self.equivalence_scenarios
7 {
80 "inactive" => -> (klass) { klass.new(active: false).call },
90 "nil name" => -> (klass) { klass.new(name: nil).call },
10 }
11 end
12
130 def initialize(active: true, name: "<name>")
140 @active = active
150 @name = name
16 end
17
180 def view_template
190 div(class: @active ? "on" : "off") { "ternary" }
200 div(class: active? ? "on" : "off") { "method predicate" }
210 div(class: (@active ? "on" : nil), id: "static")
220 div(class: @active ? "on" : "off", id: dom_id)
230 div(class: @active && "on")
240 div(class: @name || "anonymous")
250 div(class: (@active ? "a" : "b") && (@name || "c"))
260 div(class: @active ? (@name ? "named" : "anonymous") : "off")
270 div(class: @active ? (active? ? "named" : "anonymous") : "off")
280 div(class: (plain("before"); @active) ? "on" : "off")
290 div(hidden: @active ? true : nil, tabindex: @active ? 0 : -1)
300 a(href: @active ? "javascript:alert(1)" : "/ok") { "guarded" }
310 div(class: if @active then "on" end)
320 div(class: unless @active then "off" end)
330 div(class: if @active then "on" elsif @name then "named" else "off" end)
340 div(class: ("on" if @active))
350 div(class: ("off" unless @active), id: dom_id)
360 div(class: @active ? (@name ? "named" : "anonymous") : "off", id: clear_name)
370 div(class: (if @active then "on" elsif @name then "named" else "off" end), id: clear_name)
38
390 span { @active ? "on" : "off" }
400 span { active? ? "on" : "off" }
410 span { @active ? "<on>" : :"<off>" }
420 span { @active ? "on" : nil }
430 span { @active && "on" }
440 span { @name || "anonymous" }
450 span { (@active ? "a" : "b") }
460 span { @active ? (@name ? "named" : "anonymous") : "off" }
470 span { @active ? (active? ? "named" : "anonymous") : "off" }
480 span do
490 if @active
500 "on"
510 elsif @name
520 "named"
53 else
540 "off"
55 end
56 end
570 span do
580 unless @active
590 "off"
60 end
61 end
620 span { (plain("before"); @active) ? "on" : "off" }
630 span { @active ? "on" : @name }
640 span { "on" if @active }
650 span { "off" unless @active }
66 end
67
680 def clear_name
690 @name = nil
700 "cleared"
71 end
72
730 def active? = @active
74
750 def dom_id = "generated"
76 end
77 end
78end