Anonymous user
Validate International Securities Identification Number: Difference between revisions
Validate International Securities Identification Number (view source)
Revision as of 08:17, 5 February 2017
, 7 years agoupdated Tcl to use new examples
(Added Kotlin) |
(updated Tcl to use new examples) |
||
Line 1,001:
run;</lang>
=={{header|Tcl}}==
<lang Tcl>package require Tcl 8.6 ;# mostly needed for [assert]. Substitute a simpler one or a NOP if required.</lang>
Line 1,034 ⟶ 1,032:
}
# copied from "Luhn test of credit card numbers"
proc cksum {isin} {▼
# included here for ease of testing, and because it is short
foreach ch [lreverse [split $digitString {}]] {
{0 1 2 3 4 5 6 7 8 9}
{0 2 4 6 8 1 3 5 7 9}
}
▲ incr sum [expr {$o + ($e * 2) % 9}]
}▼
}
proc validate {isin} {
▲ expr {$sum eq [cksum $body]}
}
}</lang>
To run the test suite, we use the tcltest framework included with Tcl:
<lang Tcl>package require tcltest
tcltest::test isin-1 "Test isin validation" -body {
foreach {
FR0000988040 yes
} {
assert {
▲ } else {
▲ assert {![isin::validate $str$sum]}
}
return ok
} -result ok</lang>
=={{header|Visual Basic}}==
|