defined.test 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --TEST--
  2. "defined" test
  3. --TEMPLATE--
  4. {{ definedVar is defined ? 'ok' : 'ko' }}
  5. {{ definedVar is not defined ? 'ko' : 'ok' }}
  6. {{ undefinedVar is defined ? 'ko' : 'ok' }}
  7. {{ undefinedVar is not defined ? 'ok' : 'ko' }}
  8. {{ zeroVar is defined ? 'ok' : 'ko' }}
  9. {{ nullVar is defined ? 'ok' : 'ko' }}
  10. {{ nested.definedVar is defined ? 'ok' : 'ko' }}
  11. {{ nested['definedVar'] is defined ? 'ok' : 'ko' }}
  12. {{ nested.definedVar is not defined ? 'ko' : 'ok' }}
  13. {{ nested.undefinedVar is defined ? 'ko' : 'ok' }}
  14. {{ nested['undefinedVar'] is defined ? 'ko' : 'ok' }}
  15. {{ nested.undefinedVar is not defined ? 'ok' : 'ko' }}
  16. {{ nested.zeroVar is defined ? 'ok' : 'ko' }}
  17. {{ nested.nullVar is defined ? 'ok' : 'ko' }}
  18. {{ nested.definedArray.0 is defined ? 'ok' : 'ko' }}
  19. {{ nested['definedArray'][0] is defined ? 'ok' : 'ko' }}
  20. {{ object.foo is defined ? 'ok' : 'ko' }}
  21. {{ object.undefinedMethod is defined ? 'ko' : 'ok' }}
  22. {{ object.getFoo() is defined ? 'ok' : 'ko' }}
  23. {{ object.getFoo('a') is defined ? 'ok' : 'ko' }}
  24. {{ object.undefinedMethod() is defined ? 'ko' : 'ok' }}
  25. {{ object.undefinedMethod('a') is defined ? 'ko' : 'ok' }}
  26. {{ object.self.foo is defined ? 'ok' : 'ko' }}
  27. {{ object.self.undefinedMethod is defined ? 'ko' : 'ok' }}
  28. {{ object.undefinedMethod.self is defined ? 'ko' : 'ok' }}
  29. --DATA--
  30. return array(
  31. 'definedVar' => 'defined',
  32. 'zeroVar' => 0,
  33. 'nullVar' => null,
  34. 'nested' => array(
  35. 'definedVar' => 'defined',
  36. 'zeroVar' => 0,
  37. 'nullVar' => null,
  38. 'definedArray' => array(0),
  39. ),
  40. 'object' => new Foo(),
  41. );
  42. --EXPECT--
  43. ok
  44. ok
  45. ok
  46. ok
  47. ok
  48. ok
  49. ok
  50. ok
  51. ok
  52. ok
  53. ok
  54. ok
  55. ok
  56. ok
  57. ok
  58. ok
  59. ok
  60. ok
  61. ok
  62. ok
  63. ok
  64. ok
  65. ok
  66. ok
  67. ok
  68. --DATA--
  69. return array(
  70. 'definedVar' => 'defined',
  71. 'zeroVar' => 0,
  72. 'nullVar' => null,
  73. 'nested' => array(
  74. 'definedVar' => 'defined',
  75. 'zeroVar' => 0,
  76. 'nullVar' => null,
  77. 'definedArray' => array(0),
  78. ),
  79. 'object' => new Foo(),
  80. );
  81. --CONFIG--
  82. return array('strict_variables' => false)
  83. --EXPECT--
  84. ok
  85. ok
  86. ok
  87. ok
  88. ok
  89. ok
  90. ok
  91. ok
  92. ok
  93. ok
  94. ok
  95. ok
  96. ok
  97. ok
  98. ok
  99. ok
  100. ok
  101. ok
  102. ok
  103. ok
  104. ok
  105. ok
  106. ok
  107. ok
  108. ok