Add wide character support (tabs/emojis) and other minor fixes
This commit is contained in:
@@ -1,4 +1,87 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Unicode / Emoji / CJK stress-test Ruby file
|
||||
# Purpose: Test syntax highlighting + width calculation in your editor
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
# Basic output
|
||||
def greet
|
||||
puts "Hello, 世界! 👋🌏"
|
||||
end
|
||||
|
||||
# Emoji-heavy strings
|
||||
emojis = "👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏"
|
||||
|
||||
# Mixed-width CJK blocks
|
||||
cjk_samples = [
|
||||
"漢字テスト",
|
||||
"測試中文字串",
|
||||
"한국어 테스트",
|
||||
"ひらがなカタカナ😀混合",
|
||||
"大量の文字列🚀🚀🚀",
|
||||
]
|
||||
|
||||
# Ruby regex with unicode
|
||||
unicode_regex = /[一-龯ぁ-んァ-ヶー々〆〤]/
|
||||
|
||||
# Unicode identifiers (valid in Ruby)
|
||||
变量 = 123
|
||||
π = 3.14159
|
||||
挨拶 = -> { "こんにちは" }
|
||||
|
||||
# Method using unicode variable names
|
||||
def math_test
|
||||
puts "π * 2 = #{π * 2}"
|
||||
end
|
||||
|
||||
# Iterate through CJK samples
|
||||
cjk_samples.each_with_index do |str, idx|
|
||||
puts "CJK[#{idx}] => #{str} (len=#{str.length})"
|
||||
end
|
||||
|
||||
# Test emoji width behaviors
|
||||
puts "Emoji count: #{emojis.length}"
|
||||
|
||||
# Multi-line string with unicode
|
||||
multi = <<~EOF
|
||||
これは複数行テキストです。
|
||||
Emojis inside heredoc: 🎉🔥✨💀❤️🧡💛💚💙💜🖤🤍🤎
|
||||
End of block.
|
||||
EOF
|
||||
|
||||
puts multi
|
||||
|
||||
# Arrays mixing everything
|
||||
mixed = [
|
||||
"🐍 Ruby + Python? sacrilege! 🐍",
|
||||
"日本語とEnglishと🔧mix",
|
||||
"Spacing test →→→→→→→",
|
||||
"Zero-width joiner test: 👨👩👧👦 family emoji",
|
||||
]
|
||||
|
||||
mixed.each { |m| puts m }
|
||||
|
||||
# Unicode in comments — highlight me!
|
||||
# コメント:エディタのハイライトを確認します✨
|
||||
# Emojis should not break formatting: 🦀🦊🐱👤🤖
|
||||
|
||||
# Dummy Ruby logic
|
||||
5.times do |i|
|
||||
puts "Loop #{i}: 🌟 #{cjk_samples[i % cjk_samples.size]}"
|
||||
end
|
||||
|
||||
# String escape sequences + unicode
|
||||
escaped = "Line1\nLine2\tTabbed 😀"
|
||||
puts escaped
|
||||
|
||||
# Frozen string literal test
|
||||
# frozen_string_literal: true
|
||||
const_str = "定数文字列🔒".freeze
|
||||
puts const_str
|
||||
|
||||
# End marker
|
||||
puts "--- END OF UNICODE TEST FILE ---"
|
||||
|
||||
# Ruby syntax highlighting test
|
||||
|
||||
=begin
|
||||
|
||||
Reference in New Issue
Block a user