lib/phlex/compiler/break_scanner.rb

Lines

100%

10 of 10 covered

Branches

—

0 of 0 covered

Methods

83%

5 of 6 covered

Never called
1# frozen_string_literal: true
2
3# Detects a `break` belonging to a block, which makes the call it's passed to
4# return the break's value.
51class Phlex::Compiler::BreakScanner < Refract::Visitor
61 def self.breaks?(node)
7235 catch(:break) do
8235 new.visit(node)
9231 false
10 end
11 end
12
131 visit Refract::BreakNode do |node|
144 throw :break, true
15 end
16
17 # A `break` in these belongs to them.
181 [Refract::BlockNode, Refract::LambdaNode, Refract::WhileNode, Refract::UntilNode].each do |node_class|
194 visit node_class do |node|
2040 nil
21 end
22 end
23end