]> git.lizzy.rs Git - rust.git/commitdiff
Correctly parse commands for rusti
authorAlex Crichton <alex@alexcrichton.com>
Fri, 14 Jun 2013 04:46:17 +0000 (21:46 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 14 Jun 2013 04:48:16 +0000 (21:48 -0700)
Closes #7120

src/librusti/rusti.rc

index 90a5a350b7fa4b2b9af68edf50731d70f8ea4c28..7d221ce378890113e0091b8aa00c5f01d8802505 100644 (file)
@@ -424,7 +424,7 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
         use std::iterator::IteratorUtil;
 
         // drop the : and the \n (one byte each)
-        let full = line.slice(1, line.len() - 1);
+        let full = line.slice(1, line.len());
         let split: ~[~str] = full.word_iter().transform(|s| s.to_owned()).collect();
         let len = split.len();
 
@@ -649,4 +649,14 @@ mod tests {
             f()
         ");
     }
+
+    #[test]
+    fn exit_quits() {
+        let mut r = repl();
+        assert!(r.running);
+        let result = run_line(&mut r, io::stdin(), io::stdout(),
+                              ~":exit", false);
+        assert!(result.is_none());
+        assert!(!r.running);
+    }
 }