Skip to content

Commit

Permalink
throw error on duplicate fund ids
Browse files Browse the repository at this point in the history
  • Loading branch information
mmitch committed Feb 7, 2024
1 parent 106f7a5 commit 6a19406
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions depot.pl
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ sub import {
([a-zA-Z0-9_]+) # fund name
/x) {
my ($id) = ($1);
die "duplicate fund `$id' at line $.\n" if exists $funds{$id};
$funds{$id} = new Fund( id => $id );
}
elsif ($line =~ /
Expand Down
4 changes: 4 additions & 0 deletions test/test-9-duplicate-fund.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# define funds

+FUND fund_A
+FUND fund_A
Empty file.
11 changes: 11 additions & 0 deletions test/test-9-verbose-mode-fresh.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# test with mode -verbose and freshly initialized funds
# aaa has no transaction at all
# bbb has only a single transaction
# watch out for divison by zero and other problems

+FUND aaa
+FUND bbb

@@ 01.04.2020

bbb +2 = 20 ! 2
1 change: 1 addition & 0 deletions test/test-depot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ expect_error test-5-unknown-line "unparseable line \`some random unparseable
expect_error test-6-backwards-date "date \`23.11.1962' must be later than previous date"
expect_success test-7-default-mode '-default'
expect_success test-8-verbose-mode '-verbose'
expect_error test-9-duplicate-fund "duplicate fund \`fund_A'"

0 comments on commit 6a19406

Please sign in to comment.