Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

garbage output dumped into the file #142

Open
JoshCheek opened this issue Sep 19, 2018 · 1 comment
Open

garbage output dumped into the file #142

JoshCheek opened this issue Sep 19, 2018 · 1 comment

Comments

@JoshCheek
Copy link
Owner

Before running:

def alphabet_position(str)
  str.scan(/\[a-z]/i).map { |c| c.ord & 0b11111 }.join(' ')
end

def assert_equals(actual, expected)
  raise RuntimeError, "#{actual}\n#{expected}", caller unless actual == expected
end

assert_equals(
  alphabet_position("The sunset sets at twelve o' clock."),
  "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
)
assert_equals(
  alphabet_position("The narwhal bacons at midnight."),
  "20 8 5 14 1 18 23 8 1 12 2 1 3 15 14 19 1 20 13 9 4 14 9 7 8 20"
)

After running:

def alphabet_position(str)
  str.scan(/\[a-z]/i).map { |c| c.ord & 0b11111 }.join(' ')
end

def assert_equals(actual, expected)
  raise RuntimeError, "#{actual}\n#{expected}", caller unless actual == expected
end

assert_equals( # ~> RuntimeError: \n20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11
  alphabet_position("The sunset sets at twelve o' clock."),
  "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
)
assert_equals(
  alphabet_position("The narwhal bacons at midnight."),
  "20 8 5 14 1 18 23 8 1 12 2 1 3 15 14 19 1 20 13 9 4 14 9 7 8 20"
)

# ~> RuntimeError
# ~> 
# ~> 20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11
# ~>
# ~> program.rb:9:in `<main>'/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
/Users/josh/.gem/ruby/2.5.1/gems/parser-2.5.1.2/lib/parser/builders/default.rb:1635: warning: regular expression has ']' without escape: /\[a-z]/
@JoshCheek
Copy link
Owner Author

NOTE: The regex accidentally escaped the character set (b/c it used to be /\w/ and I forgot to take out the escape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant