Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/proto2/util.js
2868 views
1
// Copyright 2009 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
15
/**
16
* @fileoverview Utility methods for Protocol Buffer 2 implementation.
17
*/
18
19
goog.provide('goog.proto2.Util');
20
21
goog.require('goog.asserts');
22
23
24
/**
25
* @define {boolean} Defines a PBCHECK constant that can be turned off by
26
* clients of PB2. This for is clients that do not want assertion/checking
27
* running even in non-COMPILED builds.
28
*/
29
goog.define('goog.proto2.Util.PBCHECK', !COMPILED);
30
31
32
/**
33
* Asserts that the given condition is true, if and only if the PBCHECK
34
* flag is on.
35
*
36
* @param {*} condition The condition to check.
37
* @param {string=} opt_message Error message in case of failure.
38
* @throws {Error} Assertion failed, the condition evaluates to false.
39
*/
40
goog.proto2.Util.assert = function(condition, opt_message) {
41
if (goog.proto2.Util.PBCHECK) {
42
goog.asserts.assert(condition, opt_message);
43
}
44
};
45
46
47
/**
48
* Returns true if debug assertions (checks) are on.
49
*
50
* @return {boolean} The value of the PBCHECK constant.
51
*/
52
goog.proto2.Util.conductChecks = function() {
53
return goog.proto2.Util.PBCHECK;
54
};
55
56