jscript_test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2006 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Mock JScript functions
  15. goog.provide('goog.userAgent.jscriptTest');
  16. goog.setTestOnly('goog.userAgent.jscriptTest');
  17. goog.require('goog.testing.jsunit');
  18. goog.require('goog.userAgent.jscript');
  19. function ScriptEngine() {
  20. return 'JScript';
  21. }
  22. function ScriptEngineMajorVersion() {
  23. return 1;
  24. }
  25. function ScriptEngineMinorVersion() {
  26. return 2;
  27. }
  28. function ScriptEngineBuildVersion() {
  29. return 3456;
  30. }
  31. function testHasJscript() {
  32. assertTrue('Should have jscript', goog.userAgent.jscript.HAS_JSCRIPT);
  33. }
  34. function testVersion() {
  35. assertEquals(
  36. 'Version should be 1.2.3456', '1.2.3456', goog.userAgent.jscript.VERSION);
  37. }
  38. function testIsVersion() {
  39. assertTrue(
  40. 'Should be version 1.2.3456 or larger',
  41. goog.userAgent.jscript.isVersion('1.2.3456'));
  42. assertTrue(
  43. 'Should be version 1.2 or larger',
  44. goog.userAgent.jscript.isVersion('1.2'));
  45. assertFalse(
  46. 'Should not be version 8.9 or larger',
  47. goog.userAgent.jscript.isVersion('8.9'));
  48. }