From 41d92371ae57f6e163e82ba036937e21b89c1e4d Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 18 Mar 2017 20:08:56 +0100 Subject: Add tests for setting the right locale in icons.zsh --- test/functions/icons.spec | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 test/functions/icons.spec (limited to 'test') diff --git a/test/functions/icons.spec b/test/functions/icons.spec new file mode 100755 index 00000000..0a6d5942 --- /dev/null +++ b/test/functions/icons.spec @@ -0,0 +1,74 @@ +#!/usr/bin/env zsh +#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 + +# Required for shunit2 to run correctly +setopt shwordsplit +SHUNIT_PARENT=$0 + +function setUp() { + # Store old value for LC_CTYPE + _OLD_LC_CTYPE="${LC_CTYPE}" + # Reset actual LC_CTYPE + unset LC_CTYPE + + # Store old P9K mode + _OLD_P9K_MODE="${POWERLEVEL9K_MODE}" +} + +function tearDown() { + # Restore LC_CTYPE + LC_CTYPE="${_OLD_LC_CTYPE}" + + # Restore old P9K mode + POWERLEVEL9K_MODE="${_OLD_P9K_MODE}" +} + +function testLcCtypeIsSetCorrectlyInDefaultMode() { + POWERLEVEL9K_MODE="default" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() { + POWERLEVEL9K_MODE="awesome-patched" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() { + POWERLEVEL9K_MODE="awesome-fontconfig" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() { + POWERLEVEL9K_MODE="nerdfont-fontconfig" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +function testLcCtypeIsSetCorrectlyInFlatMode() { + POWERLEVEL9K_MODE="flat" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +function testLcCtypeIsSetCorrectlyInCompatibleMode() { + POWERLEVEL9K_MODE="compatible" + # Load Powerlevel9k + source functions/icons.zsh + + assertEquals 'en_US.UTF-8' "${LC_CTYPE}" +} + +source shunit2/source/2.1/src/shunit2 \ No newline at end of file -- cgit v1.2.3 From 5b266c7a135f731a31abc1e837731979587a4b96 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Mon, 20 Mar 2017 00:07:35 +0100 Subject: Add tests to ensure all icon keys are set in all modes This tests do compare icons from all modes (except for flat and compatible) with all other modes. --- test/functions/icons.spec | 252 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) (limited to 'test') diff --git a/test/functions/icons.spec b/test/functions/icons.spec index 0a6d5942..8c1f93ef 100755 --- a/test/functions/icons.spec +++ b/test/functions/icons.spec @@ -71,4 +71,256 @@ function testLcCtypeIsSetCorrectlyInCompatibleMode() { assertEquals 'en_US.UTF-8' "${LC_CTYPE}" } +# Go through all icons defined in default mode, and +# check if all of them are defined in the other modes. +function testAllIconsAreDefinedLikeInDefaultMode() { + # Always compare against this mode + local _P9K_TEST_MODE="default" + POWERLEVEL9K_MODE="${_P9K_TEST_MODE}" + source functions/icons.zsh + # _ICONS_UNDER_TEST is an array of just the keys of $icons. + # We later check via (r) "subscript" flag that our key + # is in the values of our flat array. + local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + + # Switch to "awesome-patched" mode + POWERLEVEL9K_MODE="awesome-patched" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + # Iterate over all keys found in the _ICONS_UNDER_TEST + # array and compare it with the icons array of the + # current POWERLEVEL9K_MODE. + # Use parameter expansion, to directly check if the + # key exists in the flat current array of keys. That + # is quite complicated, but there seems no easy way + # to check the mere existance of a key in an array. + # The usual way would always return the value, so that + # would do the wrong thing as we have some (on purpose) + # empty values. + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "awesome-fontconfig" mode + POWERLEVEL9K_MODE="awesome-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "nerdfont-fontconfig" mode + POWERLEVEL9K_MODE="nerdfont-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "flat" mode + POWERLEVEL9K_MODE="flat" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "compatible" mode + POWERLEVEL9K_MODE="compatible" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done +} + +# Go through all icons defined in awesome-patched mode, and +# check if all of them are defined in the other modes. +function testAllIconsAreDefinedLikeInAwesomePatchedMode() { + # Always compare against this mode + local _P9K_TEST_MODE="awesome-patched" + POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + source functions/icons.zsh + # _ICONS_UNDER_TEST is an array of just the keys of $icons. + # We later check via (r) "subscript" flag that our key + # is in the values of our flat array. + local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + + # Switch to "default" mode + POWERLEVEL9K_MODE="default" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + # Iterate over all keys found in the _ICONS_UNDER_TEST + # array and compare it with the icons array of the + # current POWERLEVEL9K_MODE. + # Use parameter expansion, to directly check if the + # key exists in the flat current array of keys. That + # is quite complicated, but there seems no easy way + # to check the mere existance of a key in an array. + # The usual way would always return the value, so that + # would do the wrong thing as we have some (on purpose) + # empty values. + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "awesome-fontconfig" mode + POWERLEVEL9K_MODE="awesome-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "nerdfont-fontconfig" mode + POWERLEVEL9K_MODE="nerdfont-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "flat" mode + POWERLEVEL9K_MODE="flat" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "compatible" mode + POWERLEVEL9K_MODE="compatible" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done +} + +# Go through all icons defined in awesome-fontconfig mode, and +# check if all of them are defined in the other modes. +function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { + # Always compare against this mode + local _P9K_TEST_MODE="awesome-fontconfig" + POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + source functions/icons.zsh + # _ICONS_UNDER_TEST is an array of just the keys of $icons. + # We later check via (r) "subscript" flag that our key + # is in the values of our flat array. + local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + + # Switch to "default" mode + POWERLEVEL9K_MODE="default" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + # Iterate over all keys found in the _ICONS_UNDER_TEST + # array and compare it with the icons array of the + # current POWERLEVEL9K_MODE. + # Use parameter expansion, to directly check if the + # key exists in the flat current array of keys. That + # is quite complicated, but there seems no easy way + # to check the mere existance of a key in an array. + # The usual way would always return the value, so that + # would do the wrong thing as we have some (on purpose) + # empty values. + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "awesome-patched" mode + POWERLEVEL9K_MODE="awesome-patched" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "nerdfont-fontconfig" mode + POWERLEVEL9K_MODE="nerdfont-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "flat" mode + POWERLEVEL9K_MODE="flat" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "compatible" mode + POWERLEVEL9K_MODE="compatible" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done +} + +# Go through all icons defined in nerdfont-fontconfig mode, and +# check if all of them are defined in the other modes. +function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { + # Always compare against this mode + local _P9K_TEST_MODE="nerdfont-fontconfig" + POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + source functions/icons.zsh + # _ICONS_UNDER_TEST is an array of just the keys of $icons. + # We later check via (r) "subscript" flag that our key + # is in the values of our flat array. + local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + + # Switch to "default" mode + POWERLEVEL9K_MODE="default" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + # Iterate over all keys found in the _ICONS_UNDER_TEST + # array and compare it with the icons array of the + # current POWERLEVEL9K_MODE. + # Use parameter expansion, to directly check if the + # key exists in the flat current array of keys. That + # is quite complicated, but there seems no easy way + # to check the mere existance of a key in an array. + # The usual way would always return the value, so that + # would do the wrong thing as we have some (on purpose) + # empty values. + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "awesome-patched" mode + POWERLEVEL9K_MODE="awesome-patched" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "awesome-fontconfig" mode + POWERLEVEL9K_MODE="awesome-fontconfig" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "flat" mode + POWERLEVEL9K_MODE="flat" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done + + # Switch to "compatible" mode + POWERLEVEL9K_MODE="compatible" + source functions/icons.zsh + local -a current_icons=(${(k)icons[@]}) + for key in ${_ICONS_UNDER_TEST}; do + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + done +} + source shunit2/source/2.1/src/shunit2 \ No newline at end of file -- cgit v1.2.3 From 56af9bb3c3af7fde10d5bdf291173644bf99546c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Mon, 20 Mar 2017 00:21:49 +0100 Subject: Fix tests on TravisCI TravisCI runs ubuntu 14.04 which has ZSH 5.0.2 on it. --- test/functions/icons.spec | 84 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/functions/icons.spec b/test/functions/icons.spec index 8c1f93ef..c8d88644 100755 --- a/test/functions/icons.spec +++ b/test/functions/icons.spec @@ -81,12 +81,14 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key # is in the values of our flat array. - local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + typeset -ah _ICONS_UNDER_TEST + _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "awesome-patched" mode POWERLEVEL9K_MODE="awesome-patched" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the @@ -104,7 +106,8 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # Switch to "awesome-fontconfig" mode POWERLEVEL9K_MODE="awesome-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -112,7 +115,8 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # Switch to "nerdfont-fontconfig" mode POWERLEVEL9K_MODE="nerdfont-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -120,7 +124,8 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # Switch to "flat" mode POWERLEVEL9K_MODE="flat" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -128,10 +133,14 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # Switch to "compatible" mode POWERLEVEL9K_MODE="compatible" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done + + unset current_icons + unset _ICONS_UNDER_TEST } # Go through all icons defined in awesome-patched mode, and @@ -144,12 +153,14 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key # is in the values of our flat array. - local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + typeset -ah _ICONS_UNDER_TEST + _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode POWERLEVEL9K_MODE="default" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the @@ -167,7 +178,8 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # Switch to "awesome-fontconfig" mode POWERLEVEL9K_MODE="awesome-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -175,7 +187,8 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # Switch to "nerdfont-fontconfig" mode POWERLEVEL9K_MODE="nerdfont-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -183,7 +196,8 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # Switch to "flat" mode POWERLEVEL9K_MODE="flat" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -191,10 +205,14 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # Switch to "compatible" mode POWERLEVEL9K_MODE="compatible" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done + + unset current_icons + unset _ICONS_UNDER_TEST } # Go through all icons defined in awesome-fontconfig mode, and @@ -207,12 +225,14 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key # is in the values of our flat array. - local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + typeset -ah _ICONS_UNDER_TEST + _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode POWERLEVEL9K_MODE="default" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the @@ -230,7 +250,8 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # Switch to "awesome-patched" mode POWERLEVEL9K_MODE="awesome-patched" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -238,7 +259,8 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # Switch to "nerdfont-fontconfig" mode POWERLEVEL9K_MODE="nerdfont-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -246,7 +268,8 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # Switch to "flat" mode POWERLEVEL9K_MODE="flat" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -254,10 +277,14 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # Switch to "compatible" mode POWERLEVEL9K_MODE="compatible" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done + + unset current_icons + unset _ICONS_UNDER_TEST } # Go through all icons defined in nerdfont-fontconfig mode, and @@ -270,12 +297,14 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key # is in the values of our flat array. - local -a _ICONS_UNDER_TEST=(${(k)icons[@]}) + typeset -ah _ICONS_UNDER_TEST + _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode POWERLEVEL9K_MODE="default" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the @@ -293,7 +322,8 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # Switch to "awesome-patched" mode POWERLEVEL9K_MODE="awesome-patched" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -301,7 +331,8 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # Switch to "awesome-fontconfig" mode POWERLEVEL9K_MODE="awesome-fontconfig" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -309,7 +340,8 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # Switch to "flat" mode POWERLEVEL9K_MODE="flat" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done @@ -317,10 +349,14 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # Switch to "compatible" mode POWERLEVEL9K_MODE="compatible" source functions/icons.zsh - local -a current_icons=(${(k)icons[@]}) + typeset -ah current_icons + current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done + + unset current_icons + unset _ICONS_UNDER_TEST } source shunit2/source/2.1/src/shunit2 \ No newline at end of file -- cgit v1.2.3