1#!/usr/bin/perl -w
2# vim: set ft=perl:
3
4# Tests generic init_rcfiles method; separate parse_rcfile tests
5
6use strict;
7
8use Test::More;
9use Shell::Base;
10use FindBin qw($Bin);
11use File::Spec::Functions qw(catfile);
12
13my ($sh, $rc, @rc, $tmp);
14
15plan tests => 13;
16
17use_ok("Shell::Base");
18
19$rc = -d "t" ? catfile($Bin, 'shellrc') : catfile($Bin, 't', 'shellrc');
20$sh = Shell::Base->new(RCFILES => [ $rc ]);
21@rc = @{$sh->args("RCFILES")};
22
23ok($sh, "Object with RCFILES defined");
24is(@rc, 1, "RCFILES defined: '@rc'");
25is($tmp = $sh->config("name"), "John Smith", "RC access: name => '$tmp'");
26is($tmp = $sh->config("phone"), "6175551212", "RC access: phone => '$tmp'");
27is($tmp = $sh->config("date_format"), "%Y/%m/%d", "RC access: date_format => '$tmp'");
28is($tmp = $sh->config("lemon"), "meringue", "RC access: lemon => '$tmp'");
29is($tmp = $sh->config("foo"), 1, "RC access: foo => '$tmp'");
30is($tmp = $sh->config("bar"), 0, "RC access: bar => '$tmp'");
31is($tmp = $sh->config("baz"), "quux", "RC access: baz => '$tmp'");
32is($tmp = $sh->config("quote"), "Holy shit w00t!", "RC access: quote => '$tmp'");
33is($tmp = $sh->config("spacetest"), "hello,  world  and  all  that", "RC access: spacetest => '$tmp'");
34is($tmp = $sh->config("quoted"), '"Hello, world"', "RC access: quoted => '$tmp'");
35