mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Majority of the edits done using the following ruby script:
def update_loops(src)
dst, cnt = '', 0
block_indent, variable = nil, nil
src.each_line do |line|
if block_indent
if line =~ /^#{block_indent}([{}\t])|^\t*$/
block_indent = nil if $1 == '}'
line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
$1.to_s + variable + ($2 == "->" ? "." : "")
end
else
block_indent = nil
end
elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
block_indent, variable = $1, $2
line = "#$1for(auto const& #$2 : #$3\n"
cnt += 1
end
dst << line
end
return dst, cnt
end
paths.each do |path|
src = IO.read(path)
cnt = 1
while cnt != 0
src, cnt = update_loops(src)
STDERR << "#{path}: #{cnt}\n"
end
File.open(path, "w") { |io| io << src }
end
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include <test/jail.h>
|
|
#include <document/document.h>
|
|
|
|
class XAttrTests : public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
void test_bookmarks ()
|
|
{
|
|
test::jail_t jail;
|
|
jail.set_content("test.txt", "foo\nbar\nfud\n");
|
|
path::set_attr(jail.path("test.txt"), "com.macromates.bookmarks", "( '1:1', '1:8', '4:2' )");
|
|
|
|
document::document_ptr doc = document::create(jail.path("test.txt"));
|
|
doc->open();
|
|
|
|
std::map<size_t, std::string> marks = doc->buffer().get_marks(0, doc->buffer().size(), "bookmark");
|
|
TS_ASSERT_EQUALS(marks.size(), 3);
|
|
TS_ASSERT_EQUALS(marks[0], "bookmark");
|
|
TS_ASSERT_EQUALS(marks[3], "bookmark");
|
|
TS_ASSERT_EQUALS(marks[12], "bookmark");
|
|
}
|
|
|
|
void test_selection ()
|
|
{
|
|
test::jail_t jail;
|
|
jail.set_content("test.txt", "foo\nbar\nfud\n");
|
|
path::set_attr(jail.path("test.txt"), "com.macromates.selectionRange", "2:2&3:1");
|
|
|
|
document::document_ptr doc = document::create(jail.path("test.txt"));
|
|
doc->open();
|
|
|
|
TS_ASSERT_EQUALS(doc->selection(), "2:2&3:1");
|
|
|
|
// ng::ranges_t const sel = convert(doc->buffer(), doc->selection());
|
|
// for(auto const& range : sel)
|
|
// fprintf(stderr, "%zu-%zu\n", range.first.index, range.last.index);
|
|
}
|
|
};
|