baseballlover723

Untitled

Jul 21st, 2021
1,122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require "colorize"
  2. FILE = 'golf.rb'
  3.  
  4. a = nil
  5. b = nil
  6.  
  7. file_contents = File.read(FILE)
  8. eval(file_contents)
  9.  
  10. golfed_lower = eval("a")
  11. golfed_upper = eval("b")
  12.  
  13. lower="a b c d e f g h i j k l m n o p q r s t u v w x y z"
  14. upper="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
  15.  
  16. puts "golfed file has #{file_contents.size} chars"
  17. puts "golfed file has #{file_contents.bytesize} bytes"
  18. puts ""
  19.  
  20. if golfed_lower != lower
  21.   puts "golfed lower does not give the right value".light_red
  22.   puts "value was \"#{golfed_lower}\""
  23.   puts "expected  \"#{lower}\""
  24.   puts
  25. else
  26.   puts "golfed lower does match".light_green
  27. end
  28.  
  29. if golfed_upper != upper
  30.   puts "golfed upper does not give the right value".light_red
  31.   puts "value was \"#{golfed_upper}\""
  32.   puts "expected  \"#{upper}\""
  33.   puts
  34. else
  35.   puts "golfed upper does match".light_green
  36. end
  37.  
  38.  
RAW Paste Data