Skip to content

Commit b4e6199

Browse files
committed
---
yaml --- r: 79860 b: refs/heads/master c: 491ce71 h: refs/heads/master v: v3
1 parent 32f1f51 commit b4e6199

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4ed5fcb122870d5b0876b32e2dffeb4ea2bd6aed
2+
refs/heads/master: 491ce71453499f61eeb24d891b28a07ea9ae532b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 54ae2800ffb30513f89ce13d27ac3c8d095d98ac
55
refs/heads/try: 71bebebc37fbb229877da88dde13c2f35913bd77
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast no compile flags for check-fast
12+
13+
// we want this to be compiled to avoid bitrot, but the actual test
14+
//has to be conducted by a human, i.e. someone (you?) compiling this
15+
//file with a plain rustc invocation and running it and checking it
16+
//works.
17+
18+
// compile-flags: --cfg robot_mode
19+
20+
extern mod extra;
21+
use extra::rl;
22+
23+
static HISTORY_FILE: &'static str = "rl-human-test-history.txt";
24+
25+
fn main() {
26+
// don't run this in robot mode, but still typecheck it.
27+
if !cfg!(robot_mode) {
28+
println("~~ Welcome to the rl test \"suite\". ~~");
29+
println!("Operations:
30+
- restrict the history to 2 lines,
31+
- set the tab-completion to suggest three copies of each of the last 3 letters (or 'empty'),
32+
- add 'one' and 'two' to the history,
33+
- save it to `{0}`,
34+
- add 'three',
35+
- prompt & save input (check the history & completion work and contains only 'two', 'three'),
36+
- load from `{0}`
37+
- prompt & save input (history should be 'one', 'two' again),
38+
- prompt once more.
39+
40+
The bool return values of each step are printed.",
41+
HISTORY_FILE);
42+
43+
println!("restricting history length: {}", rl::set_history_max_len(3));
44+
45+
do rl::complete |line, suggest| {
46+
if line.is_empty() {
47+
suggest(~"empty")
48+
} else {
49+
for c in line.rev_iter().take(3) {
50+
suggest(format!("{0}{1}{1}{1}", line, c))
51+
}
52+
}
53+
}
54+
55+
println!("adding 'one': {}", rl::add_history("one"));
56+
println!("adding 'two': {}", rl::add_history("two"));
57+
58+
println!("saving history: {}", rl::save_history(HISTORY_FILE));
59+
60+
println!("adding 'three': {}", rl::add_history("three"));
61+
62+
match rl::read("> ") {
63+
Some(s) => println!("saving input: {}", rl::add_history(s)),
64+
None => return
65+
}
66+
println!("loading history: {}", rl::load_history(HISTORY_FILE));
67+
68+
match rl::read("> ") {
69+
Some(s) => println!("saving input: {}", rl::add_history(s)),
70+
None => return
71+
}
72+
73+
rl::read("> ");
74+
}
75+
}

0 commit comments

Comments
 (0)