#!/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 # # https://chatgpt.com/c/695232e9-febc-8331-88c0-b47020948e5b 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 = <<~BASH # Function recursion demo factorial() { local n="$1" if ((n <= 1)); then echo 1 else local prev prev=$(factorial $((n - 1))) echo $((n * prev)) fi } log INFO "factorial(5) = $(factorial 5)" BASH 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 This is a multi-line comment. It spans multiple lines. Good for testing highlighting. This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, =end # Constants PI = 3.14159 MAX_ITER = 5 # Module module Utilities def self.random_greeting ["Hello", "Hi", "Hey", "Hola", "Bonjour", "Merhaba"].sample end def self.factorial(n) return 1 if n <= 1 n * factorial(n - 1) end end # Class class TestObject attr_accessor :name, :value def initialize(name, value) @name = name @value = value end def display puts "#{@name}: #{@value}" end def double_value @value * 2 end end # Inheritance class SpecialObject < TestObject def triple_value @value * 3 end end # Lambda adder = ->(x, y) { x + y } # Array and hash numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] hash = { a: 1, b: 2, c: 3 } # Iteration numbers.each do |n| puts "Number: #{n}" end # Hash iteration hash.each do |key, value| puts "#{key} => #{value}" end # Conditional numbers.each do |n| if n.even? puts "#{n} is even" else puts "#{n} is odd" end end # Method definition def greet_person(name) puts "#{Utilities.random_greeting}, #{name}!" if (name == "harry") return true else return "s" end end # Calling methods greet_person("Alice") greet_person("Bob") # Loops i = 0 while i < 5 puts "Loop iteration #{i}" i += 1 end for j in 1..3 puts "For loop #{j}" end # Begin-rescue-ensure begin risky = 10 / 2 puts "Risky operation succeeded: #{risky}" rescue ZeroDivisionError => e puts "Caught an error: #{e}" ensure puts "This runs no matter what" end # Arrays of objects objs = [] 5.times do |k| objs << TestObject.new("Obj#{k}", k) end objs.each(&:display) # Nested arrays nested = [[1, 2], [3, 4], [5, 6]] nested.each do |arr| arr.each { |x| print "#{x} " } puts end # Case statement numbers.each do |n| case n when 1..3 puts "#{n} is small" when 4..7 puts "#{n} is medium" else puts "#{n} is large" end end # Using factorial (0..5).each do |n| puts "Factorial of #{n} is #{Utilities.factorial(n)}" end # Special objects so = SpecialObject.new("Special", 10) puts "Double: #{so.double_value}, Triple: #{so.triple_value}" # String interpolation and formatting puts "PI is approximately #{PI.round(2)}" # Multi-line strings multi_line = <<~TEXT This is a multi-line string. It spans multiple lines. Good for testing highlighting. TEXT puts multi_line # Symbols and strings sym = :my_symbol str = "my string" puts "Symbol: #{sym}, String: #{str}" # Random numbers rand_nums = Array.new(5) { rand(100) } puts "Random numbers: #{rand_nums.join(', ')}" # More loops rand_nums.each_with_index do |num, idx| puts "Index #{idx} has number #{num}" end # Ternary operator rand_nums.each do |num| puts num.even? ? "#{num} is even" : "#{num} is odd" end # Block with yield def wrapper puts "Before block" yield if block_given? puts "After block" end wrapper { puts "Inside block" } # Sorting sorted = rand_nums.sort puts "Sorted: #{sorted.join(', ')}" # Regex sample_text = "The quick brown fox jumps over the lazy dog" puts "Match 'fox'?" if sample_text =~ /fox/ # End of test script puts "Ruby syntax highlighting test complete."