pvincent
2 months ago
5 changed files with 25 additions and 83 deletions
-
2bin/sprod
-
4config/environments/production.rb
-
34config/initializers/instrumentalizing.rb
-
4lib/live/definable.rb
-
64test/formatters/wrapper2_test.rb
@ -0,0 +1,2 @@ |
|||||
|
#!/bin/bash |
||||
|
|
@ -1,64 +0,0 @@ |
|||||
require_relative '../../lib/formatters/ansi_wrapper' |
|
||||
|
|
||||
require 'minitest/autorun' |
|
||||
|
|
||||
class Wrapper2Test < Minitest::Test |
|
||||
def test_wrap_score |
|
||||
assert_wrap("\ |
|
||||
********************\e[0m\n\ |
|
||||
********************\e[0m\n\ |
|
||||
**********\e[0m", |
|
||||
('*' * 50), 20) |
|
||||
|
|
||||
assert_wrap("\ |
|
||||
> ******************\e[0m\n\ |
|
||||
> ******************\e[0m\n\ |
|
||||
> **************\e[0m", |
|
||||
('*' * 50), 20, '> ') |
|
||||
end |
|
||||
|
|
||||
def test_wrap_sql |
|
||||
assert_wrap("\ |
|
||||
\e[0m\e[0;36mELECT \"scores\".* FRO\e[0m |
|
||||
+\e[0m\e[0;36mM \"scores\" WHERE \"sc\e[0m |
|
||||
+\e[0m\e[0;36mores\".\"id\" = $1 LIMI\e[0m |
|
||||
+\e[0m\e[0;36mT $2\e[0m [[\"id\", 2], [\"L |
|
||||
IMIT\", 1]] |
|
||||
|
|
||||
\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mS\e[0m\n\ |
|
||||
\e[0;36mELECT \"scores\".* FRO\e[0m\n\ |
|
||||
\e[0;36mM \"scores\" WHERE \"sc\e[0m\n\ |
|
||||
\e[0;36mores\".\"id\" = $1 LIMI\e[0m\n\ |
|
||||
\e[0;36mT $2\e[0m [[\"id\", 2], [\"L\n\ |
|
||||
IMIT\", 1]]", "\ |
|
||||
\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mSELECT \"scores\".* FROM \"scores\" WHERE \"scores\".\"id\" = $1 LIMIT $2\e[0m [[\"id\", 2], [\"LIMIT\", 1]]", |
|
||||
20) |
|
||||
end |
|
||||
|
|
||||
# def test_carriage_return |
|
||||
# assert_wrap('text', "text\n\n", 10) |
|
||||
# assert_wrap('first ', "first \n", 10) |
|
||||
# assert_wrap('first ', "first \n", 10) |
|
||||
# assert_wrap('first ', "first \n", 10) |
|
||||
# assert_wrap("first \n second ", "first\n second\n", 10) |
|
||||
|
|
||||
# assert_wrap("\e[0;35mhello\e[0m \n\e[0;35m\e[0m\n\e[0;35myop", "\e[0;35mhello\n\nyop", 10) |
|
||||
# end |
|
||||
|
|
||||
private |
|
||||
|
|
||||
def assert_wrap(expectation, text, length, prefix = '') |
|
||||
show_with_style(text, length, prefix) |
|
||||
assert_equal(expectation, prefix + AnsiWrapper.wrap(text, length - prefix.length, prefix)) |
|
||||
end |
|
||||
|
|
||||
def show_with_style(text, length, prefix = '') |
|
||||
expectation = AnsiWrapper.wrap(text, length - prefix.length, prefix) |
|
||||
puts "original_o is:\n#{prefix}[#{text}]\e[0m" |
|
||||
puts "original_i is:\n#{prefix}[#{text.inspect}]\e[0m" |
|
||||
puts |
|
||||
puts "final_o is:\n#{prefix}[#{expectation}]\e[0m" |
|
||||
puts "final_i is:\n#{prefix}[#{expectation.inspect}]\e[0m" |
|
||||
puts |
|
||||
end |
|
||||
end |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue