mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
c4fdfabcc8
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
#! /usr/local/bin/ruby -vd
|
|
# frozen_string_literal: false
|
|
|
|
# tcltklib ライブラリのテスト
|
|
|
|
require "tcltklib"
|
|
|
|
def test
|
|
# インタプリタを生成する
|
|
ip1 = TclTkIp.new()
|
|
|
|
# 評価してみる
|
|
print ip1._return_value().inspect, "\n"
|
|
print ip1._eval("puts {abc}").inspect, "\n"
|
|
|
|
# ボタンを作ってみる
|
|
print ip1._return_value().inspect, "\n"
|
|
print ip1._eval("button .lab -text exit -command \"destroy .\"").inspect,
|
|
"\n"
|
|
print ip1._return_value().inspect, "\n"
|
|
print ip1._eval("pack .lab").inspect, "\n"
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
# インタプリタから ruby コマンドを評価してみる
|
|
# print ip1._eval(%q/ruby {print "print by ruby\n"}/).inspect, "\n"
|
|
print ip1._eval(%q+puts [ruby {print "print by ruby\n"; "puts by tcl/tk"}]+).inspect, "\n"
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
# もう一つインタプリタを生成してみる
|
|
ip2 = TclTkIp.new()
|
|
ip2._eval("button .lab -text test -command \"puts test ; destroy .\"")
|
|
ip2._eval("pack .lab")
|
|
|
|
TclTkLib.mainloop
|
|
end
|
|
|
|
test
|
|
GC.start
|
|
|
|
print "exit\n"
|