[前][次][番号順一覧][スレッド一覧]

ruby-changes:30271

From: charliesome <ko1@a...>
Date: Fri, 2 Aug 2013 10:40:40 +0900 (JST)
Subject: [ruby-changes:30271] charliesome:r42323 (trunk): * parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch

charliesome	2013-08-02 10:40:27 +0900 (Fri, 02 Aug 2013)

  New Revision: 42323

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42323

  Log:
    * parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch
      statement, and call rb_bug() if an unknown type is passed to
      negate_lit(). [ruby-core:56316] [Bug #8717]
    
    * bootstraptest/test_literal_suffix.rb (assert_equal): add test

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_literal_suffix.rb
    trunk/parse.y

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42322)
+++ ChangeLog	(revision 42323)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug  2 10:39:00 2013  Charlie Somerville  <charliesome@r...>
+
+	* parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch
+	  statement, and call rb_bug() if an unknown type is passed to
+	  negate_lit(). [ruby-core:56316] [Bug #8717]
+
+	* bootstraptest/test_literal_suffix.rb (assert_equal): add test
+
 Fri Aug  2 09:14:47 2013  Eric Hodel  <drbrain@s...>
 
 	* doc/syntax/refinements.rdoc:  Improve description of where you may
Index: bootstraptest/test_literal_suffix.rb
===================================================================
--- bootstraptest/test_literal_suffix.rb	(revision 42322)
+++ bootstraptest/test_literal_suffix.rb	(revision 42323)
@@ -3,6 +3,8 @@ assert_equal '0/1',             '0r' https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_literal_suffix.rb#L3
 assert_equal 'Rational',        '0r.class'
 assert_equal '1/1',             '1r'
 assert_equal 'Rational',        '1r.class'
+assert_equal '-1/1',            '-1r'
+assert_equal 'Rational',        '(-1r).class'
 assert_equal '1/1',             '0x1r'
 assert_equal 'Rational',        '0x1r.class'
 assert_equal '1/1',             '0b1r'
@@ -15,6 +17,8 @@ assert_equal '1/1',             '01r' https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_literal_suffix.rb#L17
 assert_equal 'Rational',        '01r.class'
 assert_equal '6/5',             '1.2r'
 assert_equal 'Rational',        '1.2r.class'
+assert_equal '-6/5',            '-1.2r'
+assert_equal 'Rational',        '(-1.2r).class'
 assert_equal '0+0i',            '0i'
 assert_equal 'Complex',         '0i.class'
 assert_equal '0+1i',            '1i'
Index: parse.y
===================================================================
--- parse.y	(revision 42322)
+++ parse.y	(revision 42323)
@@ -9402,6 +9402,8 @@ negate_lit(NODE *node) https://github.com/ruby/ruby/blob/trunk/parse.y#L9402
 	node->nd_lit = LONG2FIX(-FIX2LONG(node->nd_lit));
 	break;
       case T_BIGNUM:
+      case T_RATIONAL:
+      case T_COMPLEX:
 	node->nd_lit = rb_funcall(node->nd_lit,tUMINUS,0,0);
 	break;
       case T_FLOAT:
@@ -9417,6 +9419,7 @@ negate_lit(NODE *node) https://github.com/ruby/ruby/blob/trunk/parse.y#L9419
 #endif
 	break;
       default:
+	rb_bug("unknown literal type passed to negate_lit");
 	break;
     }
     return node;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]