File: test_unindent.rb

package info (click to toggle)
ruby-unindent 1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 100 kB
  • ctags: 6
  • sloc: ruby: 42; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 765 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'test/test_helper'

## simple indentation

assert { "\s\sabc"  .unindent == "abc" } # removes space indentation
assert { "\tabc"    .unindent == "abc" } # removes tab indentation
assert { "\t\s\sabc".unindent == "abc" } # removes space/tab indentation
assert { ""         .unindent == ""    } # handles empty strings

## multi-line indentation

assert { "\tabc\n\tabc"        .unindent == "abc\nabc"         } # removes space/tab indentation
assert { "\tabc\n\t\tabc"      .unindent == "abc\n\tabc"       } # keeps relative indentation
assert { "\n\tabc\n\n\t\tabc\n".unindent == "\nabc\n\n\tabc\n" } # ignores blank lines for indent calculation

## unindent!

# test: modifies string in place
source = "\s\sabc"
source.unindent!
assert { source == "abc" }