@@ -623,6 +623,14 @@ export class EvaluationContext {
623
623
}
624
624
625
625
private evaluateFunctionCall ( call : FunctionCallExpression ) : Value {
626
+ const assertPassed = ( ) => {
627
+ return int ( 0 ) ;
628
+ } ;
629
+ const assertFailed = ( msg : string ) => {
630
+ // TODO: Include file & line
631
+ this . errors . push ( msg ) ;
632
+ return int ( 1 ) ;
633
+ } ;
626
634
const getArgs = ( min : number , max ?: number ) => {
627
635
if ( max === undefined ) {
628
636
max = min ;
@@ -668,42 +676,56 @@ export class EvaluationContext {
668
676
// eslint-disable-next-line no-bitwise
669
677
return int ( toInt ( x ! ) & toInt ( y ! ) ) ;
670
678
}
671
- // TODO: assert_*()
679
+ case 'assert_beeps' : {
680
+ return assertFailed ( 'VSCodeVim does not support beeps' ) ;
681
+ }
672
682
case 'assert_equal' : {
673
683
const [ expected , actual , msg ] = getArgs ( 2 , 3 ) ;
674
684
if ( this . evaluateComparison ( '==' , true , expected ! , actual ! ) ) {
675
- return int ( 0 ) ;
685
+ return assertPassed ( ) ;
676
686
}
677
- this . errors . push (
687
+ return assertFailed (
678
688
msg
679
689
? toString ( msg )
680
- : `Expected ${ displayValue ( expected ! ) } but got ${ displayValue ( actual ! ) } ` , // TODO: Include file & line
690
+ : `Expected ${ displayValue ( expected ! ) } but got ${ displayValue ( actual ! ) } ` ,
691
+ ) ;
692
+ }
693
+ // TODO: assert_equalfile()
694
+ // TODO: assert_exception()
695
+ // TODO: assert_fails()
696
+ case 'assert_false' : {
697
+ const [ actual , msg ] = getArgs ( 1 , 2 ) ;
698
+ if ( this . evaluateComparison ( '==' , true , bool ( false ) , actual ! ) ) {
699
+ return assertPassed ( ) ;
700
+ }
701
+ return assertFailed (
702
+ msg ? toString ( msg ) : `Expected False but got ${ displayValue ( actual ! ) } ` ,
681
703
) ;
682
- return int ( 1 ) ;
704
+ }
705
+ // TODO: assert_inrange()
706
+ // TODO: assert_match()
707
+ case 'assert_nobeep' : {
708
+ return assertPassed ( ) ;
683
709
}
684
710
case 'assert_notequal' : {
685
711
const [ expected , actual , msg ] = getArgs ( 2 , 3 ) ;
686
712
if ( this . evaluateComparison ( '!=' , true , expected ! , actual ! ) ) {
687
- return int ( 0 ) ;
713
+ return assertPassed ( ) ;
688
714
}
689
- this . errors . push (
690
- msg ? toString ( msg ) : `Expected not equal to ${ displayValue ( expected ! ) } ` , // TODO: Include file & line
715
+ return assertFailed (
716
+ msg ? toString ( msg ) : `Expected not equal to ${ displayValue ( expected ! ) } ` ,
691
717
) ;
692
- return int ( 1 ) ;
693
718
}
719
+ // TODO: assert_notmatch()
694
720
case 'assert_report' : {
695
- this . errors . push ( toString ( getArgs ( 1 ) [ 0 ] ! ) ) ;
696
- return int ( 1 ) ;
721
+ return assertFailed ( toString ( getArgs ( 1 ) [ 0 ] ! ) ) ;
697
722
}
698
723
case 'assert_true' : {
699
724
const [ actual , msg ] = getArgs ( 2 , 3 ) ;
700
725
if ( this . evaluateComparison ( '==' , true , bool ( true ) , actual ! ) ) {
701
- return int ( 0 ) ;
726
+ return assertPassed ( ) ;
702
727
}
703
- this . errors . push (
704
- msg ? toString ( msg ) : `Expected True but got ${ displayValue ( actual ! ) } ` , // TODO: Include file & line
705
- ) ;
706
- return int ( 1 ) ;
728
+ return assertFailed ( msg ? toString ( msg ) : `Expected True but got ${ displayValue ( actual ! ) } ` ) ;
707
729
}
708
730
// TODO: call()
709
731
case 'ceil' : {
0 commit comments