From b41d6e177b44f13b2bfb190a7aae3dd2d5faf4ef Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 30 Mar 1998 09:41:20 +0000 Subject: instance_eva/module_eval git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/ruby-mode.el | 19 +++++++++++-------- sample/test.rb | 21 ++++++++++++++++++--- 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'sample') diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el index 0d94df0fc8..5d5af3437d 100644 --- a/sample/ruby-mode.el +++ b/sample/ruby-mode.el @@ -361,6 +361,9 @@ The variable ruby-indent-level controls the amount of indentation. ))))))) (list in-string (car nest) depth (car (car pcol)))))) +(defun ruby-indent-size (pos nest) + (+ pos (* (if nest nest 1) ruby-indent-level))) + (defun ruby-calculate-indent (&optional parse-start) (save-excursion (beginning-of-line) @@ -388,19 +391,19 @@ The variable ruby-indent-level controls the amount of indentation. ((and (nth 2 s) (> (nth 2 s) 0)) (goto-char (cdr (nth 1 s))) (forward-word -1) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (setq indent (current-column))))) (cond ((nth 3 state) (goto-char (nth 3 state)) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (goto-char parse-start) (back-to-indentation) - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) + (setq indent (ruby-indent-size (current-column) (nth 2 state))))) )) - + ((and (nth 2 state)(> (nth 2 state) 0)) ; in nest (if (null (cdr (nth 1 state))) (error "invalid nest")) @@ -411,17 +414,17 @@ The variable ruby-indent-level controls the amount of indentation. (cond ((nth 3 state) (goto-char (nth 3 state)) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (goto-char parse-start) (back-to-indentation) - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level)))))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))))) (t (setq indent (+ (current-column) ruby-indent-level))))) ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) - + (setq indent (ruby-indent-size (current-column) (nth 2 state))))) + (cond (indent (goto-char indent-point) diff --git a/sample/test.rb b/sample/test.rb index a3f23a6d24..69a168f2c4 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -109,8 +109,8 @@ tmp.close $bad = false tmp = open("while_tmp", "r") while tmp.gets() - next if /vt100/; - $bad = 1 if /vt100/; + next if /vt100/; + $bad = 1 if /vt100/; end ok(!(!tmp.eof? || /vt100/ || $bad)) tmp.close @@ -240,6 +240,18 @@ while true end ok(!$bad) +ok(catch(:foo) { + loop do + loop do + throw :foo, true + break + end + break + ok(false) # should no reach here + end + false + }) + check "array" ok([1, 2] + [3, 4] == [1, 2, 3, 4]) ok([1, 2] * 2 == [1, 2, 1, 2]) @@ -287,7 +299,8 @@ ok($x == [7,5,3,2,1]) # split test $x = "The Book of Mormon" -ok($x.split(//).reverse!.join == "nomroM fo kooB ehT") +ok($x.split(//).reverse!.join == $x.reverse) +ok($x.reverse == $x.reverse!) ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1") $x = "a b c d" ok($x.split == ['a', 'b', 'c', 'd']) @@ -539,6 +552,8 @@ ok(?\M-\C-a == 129) ok("a".upcase![0] == ?A) ok("A".downcase![0] == ?a) ok("abc".tr!("a-z", "A-Z") == "ABC") +ok("aabbcccc".tr_s!("a-z", "A-Z") == "ABC") +ok("abc".tr!("0-9", "A-Z") == nil) ok("abcc".squeeze!("a-z") == "abc") ok("abcd".delete!("bc") == "ad") -- cgit v1.2.3