diff --git a/README.md b/README.md index cbb22a1..faf47e3 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,25 @@ bundle exec ruby bin/sucheme -e '(+ 1 2 3)' bundle exec ruby web/app.rb ``` +### Windows (PowerShell) + +```powershell +# REPL起動 +bundle exec ruby bin/sucheme + +# ファイル実行 +bundle exec ruby bin/sucheme samples\01_basics\variables.scm + +# 式の評価(シングルクォートの代わりにダブルクォートを使用) +bundle exec ruby bin/sucheme -e "(+ 1 2 3)" + +# バッチラッパー経由(bin\sucheme.bat) +.\bin\sucheme.bat -e "(+ 1 2 3)" + +# Web UI +bundle exec ruby web\app.rb +``` + ## クイックスタート ```scheme diff --git a/spec/sucheme/evaluator_spec.rb b/spec/sucheme/evaluator_spec.rb index 933ff53..43c15e5 100644 --- a/spec/sucheme/evaluator_spec.rb +++ b/spec/sucheme/evaluator_spec.rb @@ -420,4 +420,52 @@ def eval_str(source, e = env) expect(eval_str('x', env)).to eq(1) end end + + describe 'make_sandbox_env' do + let(:sandbox) { described_class.make_sandbox_env } + + it 'allows normal arithmetic in sandbox' do + expect(described_class.eval_source('(+ 1 2)', sandbox)).to eq(3) + end + + it 'blocks open-input-file in sandbox' do + expect { described_class.eval_source('(open-input-file "test.txt")', sandbox) } + .to raise_error(Sucheme::EvalError, /open-input-file.*not available in sandbox/) + end + + it 'blocks open-output-file in sandbox' do + expect { described_class.eval_source('(open-output-file "test.txt")', sandbox) } + .to raise_error(Sucheme::EvalError, /open-output-file.*not available in sandbox/) + end + + it 'blocks load in sandbox' do + expect { described_class.eval_source('(load "file.scm")', sandbox) } + .to raise_error(Sucheme::EvalError, /load.*not available in sandbox/) + end + + it 'blocks exit in sandbox' do + expect { described_class.eval_source('(exit)', sandbox) } + .to raise_error(Sucheme::EvalError, /exit.*not available in sandbox/) + end + + it 'blocks call-with-input-file in sandbox' do + expect { described_class.eval_source('(call-with-input-file "f" (lambda (p) #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /call-with-input-file.*not available in sandbox/) + end + + it 'blocks call-with-output-file in sandbox' do + expect { described_class.eval_source('(call-with-output-file "f" (lambda (p) #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /call-with-output-file.*not available in sandbox/) + end + + it 'blocks with-input-from-file in sandbox' do + expect { described_class.eval_source('(with-input-from-file "f" (lambda () #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /with-input-from-file.*not available in sandbox/) + end + + it 'blocks with-output-to-file in sandbox' do + expect { described_class.eval_source('(with-output-to-file "f" (lambda () #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /with-output-to-file.*not available in sandbox/) + end + end end